OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
FieldSolver.h
Go to the documentation of this file.
1 //
2 // Class FieldSolver
3 // The class for the OPAL FIELDSOLVER command.
4 // A FieldSolver definition is used by most physics commands to define the
5 // particle charge and the reference momentum, together with some other data.
6 //
7 // Copyright (c) 200x - 2022, Paul Scherrer Institut, Villigen PSI, Switzerland
8 //
9 // All rights reserved
10 //
11 // This file is part of OPAL.
12 //
13 // OPAL is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20 //
21 #ifndef OPAL_FieldSolver_HH
22 #define OPAL_FieldSolver_HH
23 
25 #include "Algorithms/PartData.h"
26 #include "Solvers/PoissonSolver.h"
27 #ifdef ENABLE_AMR
28  #include "Amr/AmrObject.h"
30  #include <memory>
31 #endif
32 
33 #include <string>
34 
35 template <class T, unsigned Dim>
36 class PartBunchBase;
37 
38 enum class FieldSolverType: short {
39  NONE = -1,
40  FFT,
41  FFTBOX,
42  SAAMG,
43  P3M,
44  FMG,
45  ML,
46  AMRMG,
47  HYPRE,
48  HPGMG
49 };
50 
51 
52 class FieldSolver: public Definition {
53 
54 public:
56  FieldSolver();
57 
58  virtual ~FieldSolver();
59 
61  virtual FieldSolver* clone(const std::string& name);
62 
64  static FieldSolver* find(const std::string& name);
65 
66  std::string getType();
67 
69  double getMX() const;
70 
72  double getMY() const;
73 
75  double getMT() const;
76 
78  void setMX(double);
79 
81  void setMY(double);
82 
84  void setMT(double);
85 
87  virtual void update();
88 
90  virtual void execute();
91 
92  void initCartesianFields();
93 
95 
96  bool hasValidSolver();
97 
98  void setFieldSolverType();
100 
101  inline Layout_t& getParticleLayout() { return* PL_m; }
102 
104 
105  Inform& printInfo(Inform& os) const;
106 
107  unsigned int getInteractionRadius() {return (unsigned int) rpp_m; }
108 
109  bool hasPeriodicZ();
110 
111  bool isAmrSolverType() const;
112 
113 #ifdef ENABLE_AMR
115  return itsAmrObject_mp.get();
116  }
117 
118  const AmrObject* getAmrObject() const {
119  return itsAmrObject_mp.get();
120  }
121 #endif
122 
125 
126 private:
127 #ifdef ENABLE_AMR
128 
129  std::string getTagging_m() const;
130 
131  void initAmrObject_m();
132 
133  void initAmrSolver_m();
134 
135  std::unique_ptr<AmrObject> itsAmrObject_mp;
136 #endif
137 
138  // Not implemented.
139  FieldSolver(const FieldSolver&);
140  void operator=(const FieldSolver&);
141 
142  // Clone constructor.
143  FieldSolver(const std::string& name, FieldSolver* parent);
144 
147 
150 
152  std::unique_ptr<Layout_t> PL_m;
153 
156 
157  std::string fsName_m;
159 
160  double rpp_m;
161 };
162 
163 inline
165  return fsType_m;
166 }
167 
168 inline
170  return fs.printInfo(os);
171 }
172 
173 #endif // OPAL_FieldSolver_HH
void setFieldSolverType()
double getMY() const
Return meshsize.
virtual ~FieldSolver()
AmrObject * getAmrObject()
Definition: FieldSolver.h:114
double rpp_m
Definition: FieldSolver.h:160
Inform & printInfo(Inform &os) const
void setMT(double)
Store emittance for mode 3.
std::ostream & operator<<(std::ostream &os, const Attribute &attr)
Definition: Attribute.cpp:169
unsigned int getInteractionRadius()
Definition: FieldSolver.h:107
void initAmrSolver_m()
bool hasValidSolver()
FieldLayout_t * FL_m
The field layout f.
Definition: FieldSolver.h:149
virtual void update()
Update the field solver data.
std::string getType()
std::string getTagging_m() const
std::unique_ptr< Layout_t > PL_m
The particle layout.
Definition: FieldSolver.h:152
void initCartesianFields()
static FieldSolver * find(const std::string &name)
Find named FieldSolver.
FieldSolverType fsType_m
Definition: FieldSolver.h:158
Mesh_t * mesh_m
The cartesian mesh.
Definition: FieldSolver.h:146
FRONT * fs
Definition: hypervolume.cpp:59
FieldLayout_t * getFieldLayout()
Definition: FieldSolver.h:103
Definition: Inform.h:42
FieldSolverType getFieldSolverType() const
Definition: FieldSolver.h:164
double getMT() const
Return meshsize.
PartBunchBase< double, 3 > * itsBunch_m
all the particles are here ...
Definition: FieldSolver.h:155
void initSolver(PartBunchBase< double, 3 > *b)
FieldSolverType
Definition: FieldSolver.h:38
void setMX(double)
Store emittance for mode 1.
FieldSolver()
Exemplar constructor.
bool isAmrSolverType() const
const std::string name
Layout_t & getParticleLayout()
Definition: FieldSolver.h:101
void initAmrObject_m()
std::unique_ptr< AmrObject > itsAmrObject_mp
Definition: FieldSolver.h:135
virtual void execute()
Execute (init) the field solver data.
const AmrObject * getAmrObject() const
Definition: FieldSolver.h:118
The base class for all OPAL definitions.
Definition: Definition.h:30
std::string fsName_m
Definition: FieldSolver.h:157
virtual FieldSolver * clone(const std::string &name)
Make clone.
double getMX() const
Return meshsize.
bool hasPeriodicZ()
PoissonSolver * solver_m
the actual solver, should be a base object
Definition: FieldSolver.h:124
void setMY(double)
Store emittance for mode 2.
void operator=(const FieldSolver &)