23 #ifdef HAVE_SAAMG_SOLVER
39 #ifdef AMREX_ENABLE_FBASELIB
51 #ifdef HAVE_AMR_MG_SOLVER
112 #ifdef HAVE_AMR_MG_SOLVER
132 "The \"FIELDSOLVER\" statement defines data for a the field solver ") {
135 {
"FFT",
"FFTPERIODIC",
"SAAMG",
"NONE"});
142 "True, dimension 0 i.e x is parallelized",
146 "True, dimension 1 i.e y is parallelized",
150 "True, dimension 2 i.e z(t) is parallelized",
155 "Boundary conditions in x.",
156 {
"OPEN",
"DIRICHLET",
"PERIODIC"},
160 "Boundary conditions in y.",
161 {
"OPEN",
"DIRICHLET",
"PERIODIC"},
165 "Boundary conditions in z(t).",
166 {
"OPEN",
"DIRICHLET",
"PERIODIC"},
170 "Boundary conditions in z(t).",
171 {
"OPEN",
"DIRICHLET",
"PERIODIC"},
175 "Which Greensfunction to be used.",
176 {
"STANDARD",
"INTEGRATED"},
180 "Increase of bounding box in % ",
185 "cutoff radius for PP interactions",
189 "Green’s function splitting parameter",
193 "regularization for PP interaction",
198 "GEOMETRY to be used as domain boundary",
202 "Type of iterative solver.",
203 {
"CG",
"BICGSTAB",
"GMRES"},
207 "interpolation used for boundary points.",
208 {
"CONSTANT",
"LINEAR",
"QUADRATIC"},
212 "Tolerance for iterative solver",
216 "Maximum number of iterations of iterative solver",
220 "Preconditioner Mode.",
221 {
"STD",
"HIERARCHY",
"REUSE"},
227 "Maximum number of levels in AMR",
231 "Refinement ration in x-direction in AMR",
235 "Refinement ration in y-direction in AMR",
239 "Refinement ration in z-direction in AMR",
243 "Maximum grid size in x for AMR",
247 "Maximum grid size in y for AMR",
251 "Maximum grid size in z for AMR",
255 "Blocking factor in x for AMR (AMR_MAXGRIDX needs to be a multiple)",
259 "Blocking factor in y for AMR (AMR_MAXGRIDY needs to be a multiple)",
263 "Blocking factor in y for AMR (AMR_MAXGRIDZ needs to be a multiple)",
267 "Refinement criteria [CHARGE_DENSITY | POTENTIAL | EFIELD]",
271 "Tagging value for charge density refinement [C / cell volume]",
275 "Tagging value for max. #particles",
279 "Tagging value for min. #particles",
283 "Scaling value for maximum value tagging "
284 "(only POTENTIAL / CHARGE_DENSITY / "
288 "Box ratio of AMR computation domain. Default: [-1, 1]^3");
294 #ifdef HAVE_AMR_MG_SOLVER
296 "Smoothing of level solution.",
297 {
"GS",
"SGS",
"JACOBI"},
"GS");
300 "Number of relaxation steps",
304 "Preconditioner of bottom solver.",
305 {
"NONE",
"ILUT",
"CHEBYSHEV",
"RILUK",
"JACOBI",
"BLOCK_JACOBI",
"GS",
"BLOCK_GS",
"SA"},
309 "Interpolater between levels.",
310 {
"TRILINEAR",
"LAGRANGE",
"PC"},
314 "Norm for convergence criteria.",
315 {
"L1_NORM",
"L2_NORM",
"LINF_NORM"},
319 "Write solver info in SDDS format (*.solver)",
323 "Rebalancing of Smoothed Aggregation "
328 "Reuse type of Smoothed Aggregation.",
329 {
"NONE",
"RP",
"RAP"},
333 "AMR MG solver tolerance (default: 1.0e-10)",
384 throw OpalException(
"FieldSolver::find()",
"FieldSolver \"" +
name +
"\" not found.");
438 decomp[0] = decomp[1] =
SERIAL;
454 if (
itsAttr[deprecated::BCFFTT])
476 Inform m(
"FieldSolver::initAmrSolver");
485 bool sinTrafo = ((bcx ==
"DIRICHLET") && (bcy ==
"DIRICHLET") && (bcz ==
"DIRICHLET"));
487 std::cout <<
"FFTBOX ACTIVE" <<
std::endl;
490 std::string tmp =
"";
492 std::vector<BoundaryGeometry *> geometries;
493 for(
unsigned int i = 0; i <= geoms.length(); i++) {
494 if(i == geoms.length() || geoms[i] ==
',') {
497 geometries.push_back(geom);
518 PL_m->enableCaching();
521 #ifdef HAVE_SAAMG_SOLVER
524 std::string tmp =
"";
526 std::vector<BoundaryGeometry *> geometries;
527 for(
unsigned int i = 0; i <= geoms.length(); i++) {
528 if(i == geoms.length() || geoms[i] ==
',') {
531 geometries.push_back(geom);
547 "SAAMG Solver not enabled! Please build OPAL with -DENABLE_SAAMG_SOLVER=1");
562 os <<
"* ************* F I E L D S O L V E R ********************************************** " <<
endl;
564 <<
"* TYPE " << fsType <<
'\n'
577 if (fsType ==
"FFT") {
579 }
else if (fsType ==
"SAAMG") {
605 os <<
"* AMR_DOMAIN_RATIO ( ";
606 for (
auto& l : length) {
613 #ifdef HAVE_AMR_MG_SOLVER
614 if (fsType ==
"AMR_MG") {
615 os <<
"* ITSOLVER (AMR_MG) "
619 <<
"* AMR_MG_REBALANCE "
623 <<
"* AMR_MG_SMOOTHER "
625 <<
"* AMR_MG_NSWEEPS "
627 <<
"* AMR_MG_INTERP "
633 <<
"* AMR_MG_VERBOSE "
639 if (
itsAttr[deprecated::BCFFTT]) {
640 os <<
"* BCFFTT (deprec.) "
650 os <<
"* XDIM parallel " <<
endl;
652 os <<
"* XDIM serial " <<
endl;
655 os <<
"* YDIM parallel " <<
endl;
657 os <<
"* YDIM serial " <<
endl;
660 os <<
"* Z(T)DIM parallel " <<
endl;
662 os <<
"* Z(T)DIM serial " <<
endl;
671 os <<
"* ********************************************************************************** " <<
endl;
679 std::function<bool(
const std::string&)> all_digits = [](
const std::string& s) {
682 return std::all_of(s.begin(), s.end(),
683 [](
char c) { return std::isdigit(c); });
686 if ( all_digits(tagging) )
737 if ( fsType ==
"ML" ) {
740 "ML solver requires AMReX.");
742 #ifdef AMREX_ENABLE_FBASELIB
743 }
else if (fsType ==
"FMG") {
747 "FMultiGrid solver requires AMReX.");
751 }
else if (fsType ==
"HYPRE") {
753 "HYPRE solver not yet implemented.");
754 }
else if (fsType ==
"HPGMG") {
756 "HPGMG solver not yet implemented.");
757 }
else if (fsType ==
"AMR_MG") {
758 #ifdef HAVE_AMR_MG_SOLVER
761 "FMultiGrid solver requires AMReX.");
787 "Multigrid solver not enabled! "
788 "Please build OPAL with -DENABLE_AMR_MG_SOLVER=1");
792 "Unknown solver " + fsType +
".");
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.
constexpr double e
The value of.
constexpr double c
The velocity of light in m/s.
bool amr
Enable AMR if true.
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)
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 enum2string(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)
The FieldSolver definition.
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.
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
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.