23 #ifdef HAVE_SAAMG_SOLVER
40 #ifdef AMREX_ENABLE_FBASELIB
52 #ifdef HAVE_AMR_MG_SOLVER
56 using namespace Expressions;
57 using namespace Physics;
66 namespace deprecated {
113 #ifdef HAVE_AMR_MG_SOLVER
132 "The \"FIELDSOLVER\" statement defines data for a the field solver ") {
135 "Name of the attached field solver: FFT, FFTPERIODIC, SAAMG, AMR, and 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: open, dirichlet (box), periodic",
"OPEN");
158 "Boundary conditions in y: open, dirichlet (box), periodic",
"OPEN");
161 "Boundary conditions in z(t): open, periodic",
"OPEN");
164 "Boundary conditions in z(t): open, periodic",
"OPEN");
167 "Which Greensfunction to be used [STANDARD | INTEGRATED]",
171 "Increase of bounding box in % ",
176 "cutoff radius for PP interactions",
180 "Green’s function splitting parameter",
184 "regularization for PP interaction",
189 "GEOMETRY to be used as domain boundary",
193 "Type of iterative solver [CG | BiCGSTAB | GMRES]",
197 "interpolation used for boundary points [CONSTANT | LINEAR | QUADRATIC]",
201 "Tolerance for iterative solver",
205 "Maximum number of iterations of iterative solver",
209 "Preconditioner Mode [STD | HIERARCHY | REUSE]",
215 "Maximum number of levels in AMR",
219 "Refinement ration in x-direction in AMR",
223 "Refinement ration in y-direction in AMR",
227 "Refinement ration in z-direction in AMR",
231 "Maximum grid size in x for AMR",
235 "Maximum grid size in y for AMR",
239 "Maximum grid size in z for AMR",
243 "Blocking factor in x for AMR (AMR_MAXGRIDX needs to be a multiple",
247 "Blocking factor in y for AMR (AMR_MAXGRIDY needs to be a multiple",
251 "Blocking factor in y for AMR (AMR_MAXGRIDZ needs to be a multiple",
255 "Refinement criteria [CHARGE_DENSITY | POTENTIAL | EFIELD]",
259 "Tagging value for charge density refinement [C / cell volume]",
263 "Tagging value for max. #particles",
267 "Tagging value for min. #particles",
271 "Scaling value for maximum value tagging "
272 "(only POTENTIAL / CHARGE_DENSITY / "
276 "Box ratio of AMR computation domain. Default: [-1, 1]^3");
282 #ifdef HAVE_AMR_MG_SOLVER
284 "Smoothing of level solution",
"GS");
287 "Number of relaxation steps",
291 "Preconditioner of bottom solver",
295 "Interpolater between levels",
299 "Norm for convergence criteria",
303 "Write solver info in SDDS format (*.solver)",
307 "Rebalancing of Smoothed Aggregation "
312 "Reuse type of Smoothed Aggregation",
363 throw OpalException(
"FieldSolver::find()",
"FieldSolver \"" + name +
"\" not found.");
417 decomp[0] = decomp[1] =
SERIAL;
437 if (
itsAttr[deprecated::BCFFTT])
462 Inform m(
"FieldSolver::initAmrSolver");
473 bool sinTrafo = ((bcx ==
"DIRICHLET") && (bcy ==
"DIRICHLET") && (bcz ==
"DIRICHLET"));
475 std::cout <<
"FFTBOX ACTIVE" <<
std::endl;
478 std::string tmp =
"";
480 std::vector<BoundaryGeometry *> geometries;
481 for(
unsigned int i = 0; i <= geoms.length(); i++) {
482 if(i == geoms.length() || geoms[i] ==
',') {
485 geometries.push_back(geom);
506 PL_m->enableCaching();
509 #ifdef HAVE_SAAMG_SOLVER
512 std::string tmp =
"";
514 std::vector<BoundaryGeometry *> geometries;
515 for(
unsigned int i = 0; i <= geoms.length(); i++) {
516 if(i == geoms.length() || geoms[i] ==
',') {
519 geometries.push_back(geom);
535 "SAAMG Solver not enabled! Please build OPAL with -DENABLE_SAAMG_SOLVER=1");
550 os <<
"* ************* F I E L D S O L V E R ********************************************** " <<
endl;
552 <<
"* TYPE " << fsType <<
'\n'
565 if(fsType ==
"FFT") {
567 }
else if (fsType ==
"SAAMG") {
594 os <<
"* AMR_DOMAIN_RATIO ( ";
595 for (
auto& l : length) {
602 #ifdef HAVE_AMR_MG_SOLVER
603 if (fsType ==
"AMR_MG") {
604 os <<
"* ITSOLVER (AMR_MG) "
608 <<
"* AMR_MG_REBALANCE "
612 <<
"* AMR_MG_SMOOTHER "
614 <<
"* AMR_MG_NSWEEPS "
616 <<
"* AMR_MG_INTERP "
620 <<
"* AMR_MG_VERBOSE "
626 if (
itsAttr[deprecated::BCFFTT]) {
627 os <<
"* BCFFTT (deprec.) "
637 os <<
"* XDIM parallel " <<
endl;
639 os <<
"* XDIM serial " <<
endl;
642 os <<
"* YDIM parallel " <<
endl;
644 os <<
"* YDIM serial " <<
endl;
647 os <<
"* Z(T)DIM parallel " <<
endl;
649 os <<
"* Z(T)DIM serial " <<
endl;
662 os <<
"* ********************************************************************************** " <<
endl;
670 std::function<bool(const std::string&)> all_digits = [](
const std::string& s) {
673 return std::all_of(s.begin(), s.end(),
674 [](
char c) {
return std::isdigit(
c); });
677 if ( all_digits(tagging) )
728 if ( fsType ==
"ML" ) {
731 "ML solver requires AMReX.");
733 #ifdef AMREX_ENABLE_FBASELIB
734 }
else if (fsType ==
"FMG") {
738 "FMultiGrid solver requires AMReX.");
742 }
else if (fsType ==
"HYPRE") {
744 "HYPRE solver not yet implemented.");
745 }
else if (fsType ==
"HPGMG") {
747 "HPGMG solver not yet implemented.");
748 }
else if (fsType ==
"AMR_MG") {
749 #ifdef HAVE_AMR_MG_SOLVER
752 "FMultiGrid solver requires AMReX.");
775 "Multigrid solver not enabled! "
776 "Please build OPAL with -DENABLE_AMR_MG_SOLVER=1");
780 "Unknown solver " + fsType +
".");
void setReal(Attribute &attr, double val)
Set real value.
static FieldSolver * find(const std::string &name)
Find named FieldSolver.
static std::unique_ptr< AmrBoxLib > create(const AmrInfo &info, AmrPartBunch *bunch_p)
constexpr double e
The value of .
The base class for all OPAL definitions.
double getMT() const
Return meshsize.
The FieldSolver definition.
virtual void set_meshEnlargement(double dh)
static std::string enum2string(int number)
The base class for all OPAL exceptions.
CenteredFieldLayout< 3, Mesh_t, Center_t > FieldLayout_t
virtual void execute()
Execute (init) the field solver data.
std::string toUpper(const std::string &str)
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
void initSolver(PartBunchBase< double, 3 > *b)
double getMY() const
Return meshsize.
int refratio[3]
Mesh refinement ratio in x-, y- and z-direction.
bool getBool(const Attribute &attr)
Return logical value.
int grid[3]
Number of grid points in x-, y- and z-direction.
static OpalData * getInstance()
void setMX(double)
Store emittance for mode 1.
const std::string & getOpalName() const
Return object name.
PoissonSolver * solver_m
the actual solver, should be a base object
constexpr double c
The velocity of light in m/s.
std::unique_ptr< Layout_t > PL_m
The particle layout.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
static BoundaryGeometry * find(const std::string &name)
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
void setRealArray(Attribute &attr, const std::vector< double > &value)
Set array value.
virtual void update()
Update the field solver data.
virtual FieldSolver * clone(const std::string &name)
Make clone.
void setMT(double)
Store emittance for mode 3.
FieldSolver()
Exemplar constructor.
Mesh_t * mesh_m
The cartesian mesh.
std::string getTagging_m() const
std::unique_ptr< AmrObject > itsAmrObject_mp
Object * find(const std::string &name)
Find entry.
PartBunchBase< double, 3 > * itsBunch_m
all the particles are here ...
void clear()
Clear the occurrence counter.
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
void initCartesianFields()
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
double getMX() const
Return meshsize.
Inform & level3(Inform &inf)
void setMY(double)
Store emittance for mode 2.
double getReal(const Attribute &attr)
Return real value.
ParticleSpatialLayout< double, 3, Mesh_t > Layout_t
Inform & printInfo(Inform &os) const
int maxlevel
Maximum level for AMR (0: single-level)
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
UniformCartesian< 3, double > Mesh_t
bool isAmrSolverType() const
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
FieldLayout_t * FL_m
The field layout f.
int bf[3]
Grid blocking factor in x-, y- and z-direction.
Inform & endl(Inform &inf)
BoundaryGeometry * getGlobalGeometry()
std::string getString(const Attribute &attr)
Get string value.
int maxgrid[3]
Maximum grid size in x-, y- and z-direction.