33#ifdef HAVE_SAAMG_SOLVER
42#ifdef AMREX_ENABLE_FBASELIB
50#ifdef HAVE_AMR_MG_SOLVER
69 FSTYPE = deprecated::SIZE,
113#ifdef HAVE_AMR_MG_SOLVER
133 "The \"FIELDSOLVER\" statement defines data for a the field solver") {
136 {
"FFT",
"FFTPERIODIC",
"SAAMG",
"FMG",
"ML",
"AMR_MG",
"NONE",
"P3M"});
143 "True, dimension 0 i.e x is parallelized",
147 "True, dimension 1 i.e y is parallelized",
151 "True, dimension 2 i.e z(t) is parallelized",
156 "Boundary conditions in x.",
157 {
"OPEN",
"DIRICHLET",
"PERIODIC"},
161 "Boundary conditions in y.",
162 {
"OPEN",
"DIRICHLET",
"PERIODIC"},
166 "Boundary conditions in z(t).",
167 {
"OPEN",
"DIRICHLET",
"PERIODIC"},
171 "Boundary conditions in z(t).",
172 {
"OPEN",
"DIRICHLET",
"PERIODIC"},
177 "Which Greensfunction to be used.",
178 {
"STANDARD",
"INTEGRATED"},
182 "Increase of bounding box in % ",
187 "Particles the space-charge mesh is fitted to: "
188 "ALL, or the CORE of the bunch.",
193 "MESHFIT=CORE: half-width of the core in clipped "
194 "rms widths, in every axis of the local frame",
198 "MESHFIT=CORE: clip half-width of the clipped rms "
203 "MESHFIT=CORE: far charge fraction in % above "
204 "which the mesh is fitted to all particles",
208 "MESHFIT=CORE: field of the particles "
209 "outside the core mesh.",
210 {
"FULL",
"QUADRUPOLE",
"MONOPOLE"},
215 "cutoff radius for PP interactions",
219 "Standard Ewald Green’s function splitting parameter",
223 "GEOMETRY to be used as domain boundary",
227 "Type of iterative solver.",
246 "interpolation used for boundary points.",
247 {
"CONSTANT",
"LINEAR",
"QUADRATIC"},
251 "Tolerance for iterative solver",
255 "Maximum number of iterations of iterative solver",
259 "Preconditioner Mode.",
260 {
"STD",
"HIERARCHY",
"REUSE"},
266 "Maximum number of levels in AMR",
270 "Refinement ration in x-direction in AMR",
274 "Refinement ration in y-direction in AMR",
278 "Refinement ration in z-direction in AMR",
282 "Maximum grid size in x for AMR",
286 "Maximum grid size in y for AMR",
290 "Maximum grid size in z for AMR",
294 "Blocking factor in x for AMR (AMR_MAXGRIDX needs to be a multiple)",
298 "Blocking factor in y for AMR (AMR_MAXGRIDY needs to be a multiple)",
302 "Blocking factor in y for AMR (AMR_MAXGRIDZ needs to be a multiple)",
306 "Refinement criteria [CHARGE_DENSITY | POTENTIAL | EFIELD | MIN_NUM_PARTICLES | MAX_NUM_PARTICLES]",
310 "Tagging value for charge density refinement [C / cell volume]",
314 "Tagging value for max. #particles",
318 "Tagging value for min. #particles",
322 "Scaling value for maximum value tagging "
323 "(only POTENTIAL / CHARGE_DENSITY / "
327 "Box ratio of AMR computation domain. Default: [-1, 1]^3");
333#ifdef HAVE_AMR_MG_SOLVER
335 "Smoothing of level solution.",
336 {
"GS",
"SGS",
"JACOBI"},
"GS");
339 "Number of relaxation steps",
343 "Preconditioner of bottom solver.",
344 {
"NONE",
"ILUT",
"CHEBYSHEV",
"RILUK",
"JACOBI",
"BLOCK_JACOBI",
"GS",
"BLOCK_GS",
"SA"},
348 "Interpolater between levels.",
349 {
"TRILINEAR",
"LAGRANGE",
"PC"},
353 "Norm for convergence criteria.",
354 {
"L1_NORM",
"L2_NORM",
"LINF_NORM"},
358 "Write solver info in SDDS format (*.solver)",
362 "Rebalancing of Smoothed Aggregation "
367 "Reuse type of Smoothed Aggregation.",
368 {
"NONE",
"RP",
"RAP",
"SYMBOLIC",
"FULL"},
372 "AMR MG solver tolerance (default: 1.0e-10)",
423 throw OpalException(
"FieldSolver::find()",
"FieldSolver \"" +
name +
"\" not found.");
477 decomp[0] = decomp[1] =
SERIAL;
493 if (
itsAttr[BCFFTZ].defaultUsed() &&
494 !
itsAttr[deprecated::BCFFTT].defaultUsed()) {
495 return itsAttr[deprecated::BCFFTT];
504 return (bcz ==
"PERIODIC");
512 "The attribute \"FSTYPE\" has not correct type for AMR solver");
519 static const std::map<std::string, FieldSolverType> stringFSType_s = {
534 "The attribute \"FSTYPE\" isn't set for \"FIELDSOLVER\"!");
549 Inform m(
"FieldSolver::initAmrSolver");
557 bool sinTrafo = ((bcx ==
"DIRICHLET") && (bcy ==
"DIRICHLET") && (bcz ==
"DIRICHLET"));
559 std::cout <<
"FFTBOX ACTIVE" << std::endl;
564 std::vector<BoundaryGeometry*> geometries;
565 for (
unsigned int i = 0; i <= geoms.length(); i++) {
566 if (i == geoms.length() || geoms[i] ==
',') {
569 geometries.push_back(geom);
594#ifdef HAVE_SAAMG_SOLVER
599 std::vector<BoundaryGeometry*> geometries;
600 for (
unsigned int i = 0; i <= geoms.length(); i++) {
601 if (i == geoms.length() || geoms[i] ==
',') {
604 geometries.push_back(geom);
620 "SAAMG Solver not enabled! Please build OPAL with -DENABLE_SAAMG_SOLVER=1");
636 static const std::map<std::string, FarFieldModel> stringFarField_s = {
647 if (!(meshFit.
nSigma > 0.0) || !(meshFit.
clip > 0.0)) {
649 "MESHFITNSIGMA and MESHFITCLIP must be positive.");
653 "MESHFITMAXFAR must be larger than 0 and at most 100 (%).");
660 "MESHFIT=\"CORE\" is only available in OPAL-cycl "
661 "(METHOD=\"CYCLOTRON-T\").");
665 "MESHFIT=\"CORE\" is only available with FSTYPE=\"FFT\", "
671 "MESHFIT=\"CORE\" is not available with BCFFTZ=\"PERIODIC\".");
675 "MESHFIT=\"CORE\" is not available with a fixed grid "
676 "or an emitting beam.");
687 os <<
"* ************* F I E L D S O L V E R ********************************************** " <<
endl;
737 os <<
"* AMR_DOMAIN_RATIO ( ";
738 for (
auto& l : length) {
745#ifdef HAVE_AMR_MG_SOLVER
747 os <<
"* ITSOLVER (AMR_MG) "
751 <<
"* AMR_MG_REBALANCE "
755 <<
"* AMR_MG_SMOOTHER "
757 <<
"* AMR_MG_NSWEEPS "
759 <<
"* AMR_MG_INTERP "
765 <<
"* AMR_MG_VERBOSE "
777 os <<
"* XDIM parallel " <<
endl;
779 os <<
"* XDIM serial " <<
endl;
783 os <<
"* YDIM parallel " <<
endl;
785 os <<
"* YDIM serial " <<
endl;
789 os <<
"* Z(T)DIM parallel " <<
endl;
791 os <<
"* Z(T)DIM serial " <<
endl;
801 os <<
"* ********************************************************************************** " <<
endl;
827 info.grid[0] = (int)this->
getMX();
864 "ML solver requires AMReX.");
866#ifdef AMREX_ENABLE_FBASELIB
871 "FMultiGrid solver requires AMReX.");
877 "HYPRE solver not yet implemented.");
880 "HPGMG solver not yet implemented.");
882#ifdef HAVE_AMR_MG_SOLVER
885 "FMultiGrid solver requires AMReX.");
909 "Multigrid solver not enabled! "
910 "Please build OPAL with -DENABLE_AMR_MG_SOLVER=1");
914 "Unknown solver " +
getType() +
".");
UniformCartesian< 3, double > Mesh_t
ParticleSpatialLayout< double, 3, Mesh_t > Layout_t
CenteredFieldLayout< 3, Mesh_t, Center_t > FieldLayout_t
Inform & endl(Inform &inf)
Inform & level3(Inform &inf)
Representation objects and parsers for attribute expressions.
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
void setRealArray(Attribute &attr, const std::vector< double > &value)
Set array value.
Attribute makeUpperCaseString(const std::string &name, const std::string &help)
Make uppercase string attribute.
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
bool getBool(const Attribute &attr)
Return logical value.
void setReal(Attribute &attr, double val)
Set real value.
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
std::string getString(const Attribute &attr)
Get string value.
bool amr
Enable AMR if true.
bool isAllDigits(const std::string &str)
A representation of an Object attribute.
The base class for all OPAL definitions.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
const std::string & getOpalName() const
Return object name.
void clear()
Clear the occurrence counter.
std::vector< Attribute > itsAttr
The object attributes.
virtual void set_meshEnlargement(double dh)
void setMeshFit(const MeshFitParameters &meshFit)
FIELDSOLVER, MESHFIT: the particles the space-charge mesh is fitted to.
Object * find(const std::string &name)
Find entry.
static OpalData * getInstance()
BoundaryGeometry * getGlobalGeometry()
static std::unique_ptr< AmrBoxLib > create(const AmrInfo &info, AmrPartBunch *bunch_p)
static std::string getTaggingString(int number)
int grid[3]
Number of grid points in x-, y- and z-direction.
int maxgrid[3]
Maximum grid size in x-, y- and z-direction.
static BoundaryGeometry * find(const std::string &name)
Parameters of the mesh fit, passed to the bunch (PartBunchBase::setMeshFit())
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.
void setMT(double)
Store emittance for mode 3.
void initCartesianFields()
double getMY() const
Return meshsize.
std::string getTagging_m() const
Mesh_t * mesh_m
The cartesian mesh.
PartBunchBase< double, 3 > * itsBunch_m
all the particles are here ...
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.
FieldLayout_t * FL_m
The field layout f.
std::unique_ptr< AmrObject > itsAmrObject_mp
const Attribute & getBCZAttribute() const
void setMY(double)
Store emittance for mode 2.
double getMT() const
Return meshsize.
void setMX(double)
Store emittance for mode 1.
virtual FieldSolver * clone(const std::string &name)
Make clone.
void initSolver(PartBunchBase< double, 3 > *b)
The base class for all OPAL exceptions.