27 #include <AMReX_MultiFabUtil.H>
28 #include <AMReX_MLPoisson.H>
29 #include <AMReX_MLMG.H>
40 unsigned short baseLevel,
41 unsigned short finestLevel,
44 for (
int i = 0; i <= finestLevel; ++i) {
45 phi[i]->setVal(0.0, 1);
46 for (
int j = 0; j < AMREX_SPACEDIM; ++j) {
47 efield[i][j]->setVal(0.0, 1);
51 this->
mlmg_m(rho, phi, efield, baseLevel, finestLevel);
86 os <<
"* ************* A M R e X P o i s s o n S o l v e r ************************************ " <<
endl
87 <<
"* relative tolerance " <<
reltol_m <<
'\n'
89 <<
"* ******************************************************************** " <<
endl;
104 info.setAgglomeration(
true);
105 info.setConsolidation(
true);
106 info.setMaxCoarseningLevel(10);
110 int nlevels = finestLevel - baseLevel + 1;
117 for (
int ilev = 0; ilev < nlevels; ++ilev) {
118 geom_p[ilev] = geom[ilev + baseLevel];
119 ba[ilev] = rho[ilev + baseLevel]->boxArray();
120 dm[ilev] = rho[ilev + baseLevel]->DistributionMap();
121 rho_p[ilev] = rho[ilev + baseLevel].get();
122 phi_p[ilev] = phi[ilev + baseLevel].get();
125 amrex::MLPoisson mlpoisson(geom_p, ba, dm,
info);
127 mlpoisson.setMaxOrder(3);
129 mlpoisson.setDomainBC({AMREX_D_DECL(amrex::LinOpBCType::Dirichlet,
130 amrex::LinOpBCType::Dirichlet,
131 amrex::LinOpBCType::Dirichlet)},
132 {AMREX_D_DECL(amrex::LinOpBCType::Dirichlet,
133 amrex::LinOpBCType::Dirichlet,
134 amrex::LinOpBCType::Dirichlet)});
136 for (
int ilev = 0; ilev < nlevels; ++ilev) {
137 mlpoisson.setLevelBC(ilev, phi[ilev].get());
140 amrex::MLMG mlmg(mlpoisson);
141 mlmg.setMaxIter(200);
142 mlmg.setMaxFmgIter(0);
144 mlmg.setCGVerbose(0);
151 amrex::Vector<std::array<AmrField_t*, AMREX_SPACEDIM> > grad(nlevels);
153 for (
int i = 0; i < nlevels; ++i) {
154 for (
int j = 0; j < AMREX_SPACEDIM; ++j) {
155 grad[i][j] = efield[i][j].get();
159 mlmg.getGradSolution(grad);
161 for (
int i = 0; i < nlevels; ++i) {
162 for (
int j = 0; j < AMREX_SPACEDIM; ++j) {
163 efield[i][j]->mult(-1.0, 0, 1, 1);
Inform & endl(Inform &inf)
double getYRangeMin(unsigned short level=0)
AmrBoxLib::AmrScalarFieldContainer_t AmrScalarFieldContainer_t
double getXRangeMax(unsigned short level=0)
double getZRangeMin(unsigned short level=0)
amrex::Vector< AmrBoxLib::AmrField_t * > AmrFieldContainer_pt
double abstol_m
Absolute tolerance for solver.
AmrBoxLib::AmrGridContainer_t AmrGridContainer_t
AmrBoxLib::AmrGeomContainer_t GeomContainer_t
MLPoissonSolver(AmrBoxLib *itsAmrObject_p)
Inform & print(Inform &os) const
void solve(AmrScalarFieldContainer_t &rho, AmrScalarFieldContainer_t &phi, AmrVectorFieldContainer_t &efield, unsigned short baseLevel, unsigned short finestLevel, bool prevAsGuess=true)
amrex::Vector< const AmrBoxLib::AmrField_t * > const_AmrFieldContainer_pt
void mlmg_m(AmrScalarFieldContainer_t &rho, AmrScalarFieldContainer_t &phi, AmrVectorFieldContainer_t &efield, int baseLevel, int finestLevel)
AmrBoxLib::AmrProcMapContainer_t AmrProcMapContainer_t
AmrBoxLib::AmrVectorFieldContainer_t AmrVectorFieldContainer_t
double getZRangeMax(unsigned short level=0)
double getXRangeMin(unsigned short level=0)
double getYRangeMax(unsigned short level=0)
double reltol_m
Relative tolearance for solver.
AmrBoxLib * itsAmrObject_mp