OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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"
27#ifdef ENABLE_AMR
28 #include "Amr/AmrObject.h"
30 #include <memory>
31#endif
32
33#include <string>
34
35template <class T, unsigned Dim>
36class PartBunchBase;
37
38enum 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
52enum class MeshFitType: short {
53 ALL, // all particles
54 CORE // the bunch core (CoreFitSC), OPAL-cycl with the FFT solver only
55};
56
58enum class FarFieldModel: short {
59 MONOPOLE, // monopole of the core charge only
60 QUADRUPOLE, // monopole and quadrupole of the core charge
61 FULL // as QUADRUPOLE, the exact core field where the expansion fails, and
62 // the field of the other particles outside the mesh (far-far)
63};
64
68 double nSigma = 6.0; // core half-width in clipped rms widths (MESHFITNSIGMA)
69 double clip = 4.0; // clip half-width in rms widths (MESHFITCLIP)
70 double maxFarFraction = 0.05; // far charge fraction for the full box (MESHFITMAXFAR)
72};
73
74
75class FieldSolver: public Definition {
76
77public:
80
81 virtual ~FieldSolver();
82
84 virtual FieldSolver* clone(const std::string& name);
85
87 static FieldSolver* find(const std::string& name);
88
89 std::string getType();
90
92 double getMX() const;
93
95 double getMY() const;
96
98 double getMT() const;
99
101 void setMX(double);
102
104 void setMY(double);
105
107 void setMT(double);
108
110 virtual void update();
111
113 virtual void execute();
114
115 void initCartesianFields();
116
118
119 bool hasValidSolver();
120
121 void setFieldSolverType();
123
124 inline Layout_t& getParticleLayout() { return* PL_m; }
125
127
128 Inform& printInfo(Inform& os) const;
129
130 unsigned int getInteractionRadius() {return (unsigned int) rpp_m; }
131
132 const Attribute& getBCZAttribute() const;
133
134 bool hasPeriodicZ();
135
136 bool isAmrSolverType() const;
137
138#ifdef ENABLE_AMR
140 return itsAmrObject_mp.get();
141 }
142
143 const AmrObject* getAmrObject() const {
144 return itsAmrObject_mp.get();
145 }
146#endif
147
150
151private:
152#ifdef ENABLE_AMR
153
154 std::string getTagging_m() const;
155
156 void initAmrObject_m();
157
158 void initAmrSolver_m();
159
160 std::unique_ptr<AmrObject> itsAmrObject_mp;
161#endif
162
165
166 // Not implemented.
168 void operator=(const FieldSolver&);
169
170 // Clone constructor.
171 FieldSolver(const std::string& name, FieldSolver* parent);
172
175
178
180 std::unique_ptr<Layout_t> PL_m;
181
184
185 std::string fsName_m;
187
188 double rpp_m;
189};
190
191inline
195
196inline
198 return fs.printInfo(os);
199}
200
201#endif // OPAL_FieldSolver_HH
FieldSolverType
Definition FieldSolver.h:38
Inform & operator<<(Inform &os, const FieldSolver &fs)
FarFieldModel
Field of the particles outside the core-fitted mesh (MESHFITFARFIELD)
Definition FieldSolver.h:58
MeshFitType
The particles the space-charge mesh is fitted to (MESHFIT)
Definition FieldSolver.h:52
const std::string name
A representation of an Object attribute.
Definition Attribute.h:52
The base class for all OPAL definitions.
Definition Definition.h:30
Parameters of the mesh fit, passed to the bunch (PartBunchBase::setMeshFit())
Definition FieldSolver.h:66
FarFieldModel farField
Definition FieldSolver.h:71
MeshFitType type
Definition FieldSolver.h:67
Layout_t & getParticleLayout()
MeshFitParameters getMeshFitParameters_m() const
MESHFIT and its parameters; throws if they are invalid or CORE is not available.
virtual void update()
Update the field solver data.
std::unique_ptr< Layout_t > PL_m
The particle layout.
FieldSolverType fsType_m
void setMT(double)
Store emittance for mode 3.
unsigned int getInteractionRadius()
void initCartesianFields()
double getMY() const
Return meshsize.
FieldLayout_t * getFieldLayout()
std::string getTagging_m() const
Mesh_t * mesh_m
The cartesian mesh.
const AmrObject * getAmrObject() const
std::string fsName_m
PartBunchBase< double, 3 > * itsBunch_m
all the particles are here ...
std::string getType()
PoissonSolver * solver_m
the actual solver, should be a base object
Inform & printInfo(Inform &os) const
bool isAmrSolverType() const
static FieldSolver * find(const std::string &name)
Find named FieldSolver.
FieldSolver()
Exemplar constructor.
void setFieldSolverType()
virtual void execute()
Execute (init) the field solver data.
double getMX() const
Return meshsize.
void operator=(const FieldSolver &)
FieldLayout_t * FL_m
The field layout f.
FieldSolverType getFieldSolverType() const
bool hasPeriodicZ()
void initAmrObject_m()
AmrObject * getAmrObject()
std::unique_ptr< AmrObject > itsAmrObject_mp
const Attribute & getBCZAttribute() const
void setMY(double)
Store emittance for mode 2.
double getMT() const
Return meshsize.
virtual ~FieldSolver()
FieldSolver(const FieldSolver &)
bool hasValidSolver()
void setMX(double)
Store emittance for mode 1.
virtual FieldSolver * clone(const std::string &name)
Make clone.
void initSolver(PartBunchBase< double, 3 > *b)
void initAmrSolver_m()