22#ifndef AMR_MULTI_GRID_H
23#define AMR_MULTI_GRID_H
29#include <AMReX_MultiFab.H>
30#include <AMReX_Vector.H>
41#define AMR_MG_TIMER true
42#define AMR_MG_WRITE false
69 Teuchos::RCP<matrix_t>,
111#ifdef HAVE_AMESOS2_KLU2
114#ifdef HAVE_AMESOS2_SUPERLU
117#ifdef HAVE_AMESOS2_UMFPACK
120#ifdef HAVE_AMESOS2_PARDISO_MKL
123#ifdef HAVE_AMESOS2_MUMPS
126#ifdef HAVE_AMESOS2_LAPACK
165 const std::string& bsolver,
166 const std::string& prec,
167 const bool& rebalance,
168 const std::string& reuse,
169 const std::string& bcx,
170 const std::string& bcy,
171 const std::string& bcz,
172 const std::string& smoother,
173 const std::size_t& nSweeps,
174 const std::string& interp,
175 const std::string& norm);
190 unsigned short baseLevel,
191 unsigned short finestLevel,
192 bool prevAsGuess =
true);
259 const amrex::Vector<AmrGeometry_t>& geom,
284 std::vector<scalar_t>& resNorms);
294 Teuchos::RCP<vector_t>& r,
295 const Teuchos::RCP<vector_t>& b,
296 const Teuchos::RCP<vector_t>& x);
313 Teuchos::RCP<vector_t>& result,
314 const Teuchos::RCP<vector_t>& rhs,
315 const Teuchos::RCP<vector_t>& crs_rhs,
316 const Teuchos::RCP<vector_t>& b);
322 void writeResidualNorm_m();
338 std::vector<scalar_t>& resNorms);
349 void setup_m(
const amrex::Vector<AmrField_u>& rho,
350 const amrex::Vector<AmrField_u>& phi,
351 const bool& matrices =
true);
357 const amrex::Vector<AmrField_u>& phi,
358 const bool& matrices =
true);
364 const amrex::Vector<AmrField_u>& phi,
365 const bool& matrices =
true);
372 void open_m(
const lo_t& level,
const bool& matrices);
379 void close_m(
const lo_t& level,
const bool& matrices);
428 D_DECL(
const go_t& ii,
525 Teuchos::RCP<vector_t>& mv);
537 const Teuchos::RCP<vector_t>& mv);
556 Teuchos::RCP<vector_t>&
e,
557 Teuchos::RCP<vector_t>& r);
596 const bool& rebalance,
597 const std::string& reuse);
605 const std::string& reuse);
666 std::unique_ptr<AmrInterpolater<AmrMultiGridLevel_t> >
interp_mp;
678 std::vector<std::unique_ptr<AmrMultiGridLevel_t > >
mglevel_m;
amr::AmrScalarFieldContainer_t AmrScalarFieldContainer_t
amr::AmrField_t AmrField_t
amr::AmrVectorFieldContainer_t AmrVectorFieldContainer_t
Inform & operator<<(Inform &os, const AmrMultiGrid &fs)
Tpetra::Map< local_ordinal_t, global_ordinal_t, node_t > dmap_t
Tpetra::Vector< scalar_t, local_ordinal_t, global_ordinal_t, node_t > vector_t
Tpetra::MultiVector< scalar_t, local_ordinal_t, global_ordinal_t, node_t > multivector_t
Tpetra::CrsMatrix< scalar_t, local_ordinal_t, global_ordinal_t, node_t > matrix_t
Teuchos::MpiComm< int > comm_t
constexpr double e
The value of.
void trilinos2amrex_m(const lo_t &level, const lo_t &comp, AmrField_t &mf, const Teuchos::RCP< vector_t > &mv)
void buildCrseBoundaryMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const basefab_t &cfab, const scalar_t *invdx2)
amrex::BaseFab< int > basefab_t
void relax_m(const lo_t &level)
void initGuess_m(bool reset)
void close_m(const lo_t &level, const bool &matrices)
AmrMultiGrid(AmrBoxLib *itsAmrObject_p, const std::string &bsolver, const std::string &prec, const bool &rebalance, const std::string &reuse, const std::string &bcx, const std::string &bcy, const std::string &bcz, const std::string &smoother, const std::size_t &nSweeps, const std::string &interp, const std::string &norm)
double getZRangeMax(unsigned short level=0)
amr::Preconditioner Preconditioner
void restrict_m(const lo_t &level)
Boundary
Supported physical boundaries.
Boundary convertToEnumBoundary_m(const std::string &bc)
std::shared_ptr< bsolver_t > solver_mp
bottom solver
BaseSolver convertToEnumBaseSolver_m(const std::string &bsolver)
void setup_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
AmrMultiGridLevel_t::boundary_t boundary_t
double getXRangeMin(unsigned short level=0)
void initPhysicalBoundary_m(const Boundary *bc)
AmrMultiGridLevel_t::coefficients_t coefficients_t
AmrMultiGridLevel_t::AmrGeometry_t AmrGeometry_t
Teuchos::RCP< comm_t > comm_mp
communicator
std::string fname_m
SDDS filename.
BaseSolver
Supported bottom solvers.
AmrMultiGridLevel_t::umap_t umap_t
amrex::FArrayBox farraybox_t
std::string snorm_m
norm for convergence criteria
std::size_t nSweeps_m
number of smoothing iterations
void map2vector_m(umap_t &map, indices_t &indices, coefficients_t &values)
void buildFineBoundaryMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const basefab_t &rfab)
void writeSDDSHeader_m(std::ofstream &outfile)
std::vector< std::unique_ptr< AmrMultiGridLevel_t > > mglevel_m
container for levels
void amrex2trilinos_m(const lo_t &level, const lo_t &comp, const AmrField_t &mf, Teuchos::RCP< vector_t > &mv)
scalar_t getLevelResidualNorm(lo_t level)
scalar_t evalNorm_m(const Teuchos::RCP< const vector_t > &x)
void buildSingleLevel_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
int lbase_m
base level (currently only 0 supported)
void initPrec_m(const Preconditioner &prec, const std::string &reuse)
void setVerbose(bool verbose)
void initInterpolater_m(const Interpolater &interp)
std::unique_ptr< AmrInterpolater< AmrMultiGridLevel_t > > interp_mp
interpolater without coarse-fine interface
void buildGradientMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const scalar_t *invdx)
AmrMultiGridLevel_t::AmrField_u AmrField_u
BelosBottomSolver< AmrMultiGridLevel_t > BelosSolver_t
void initCrseFineInterp_m(const Interpolater &interface)
std::shared_ptr< preconditioner_t > prec_mp
preconditioner for bottom solver
std::unique_ptr< AmrInterpolater< AmrMultiGridLevel_t > > interface_mp
interpolater for coarse-fine interface
Norm convertToEnumNorm_m(const std::string &norm)
Interpolater convertToEnumInterpolater_m(const std::string &interp)
amr::global_ordinal_t go_t
void averageDown_m(const lo_t &level)
Smoother convertToEnumSmoother_m(const std::string &smoother)
double getZRangeMin(unsigned short level=0)
Amesos2BottomSolver< AmrMultiGridLevel_t > Amesos2Solver_t
void buildPotentialVector_m(const lo_t &level, const AmrField_t &phi)
void residual_no_fine_m(const lo_t &level, Teuchos::RCP< vector_t > &result, const Teuchos::RCP< vector_t > &rhs, const Teuchos::RCP< vector_t > &crs_rhs, const Teuchos::RCP< vector_t > &b)
scalar_t eps_m
rhs scale for convergence
AmrMultiGridLevel_t::AmrField_t AmrField_t
std::size_t nIter_m
number of iterations till convergence
double getXRangeMax(unsigned short level=0)
Inform & print(Inform &os) const
AmrMultiGridLevel_t::AmrIntVect_t AmrIntVect_t
BottomSolver< Teuchos::RCP< matrix_t >, Teuchos::RCP< mv_t >, AmrMultiGridLevel_t > bsolver_t
bool verbose_m
If true, a SDDS file is written.
std::size_t bIter_m
number of iterations of bottom solver
int nlevel_m
number of levelss
amr::local_ordinal_t lo_t
std::ios_base::openmode flag_m
std::ios::out or std::ios::app
void setNumberOfSweeps(const std::size_t &nSweeps)
void initResidual_m(std::vector< scalar_t > &rhsNorms, std::vector< scalar_t > &resNorms)
AmrMultiGridLevel_t::AmrField_s AmrField_s
AmrSmoother::Smoother Smoother
void buildMultiLevel_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
void open_m(const lo_t &level, const bool &matrices)
void buildDensityVector_m(const lo_t &level, const AmrField_t &rho)
MueLuPreconditioner< AmrMultiGridLevel_t > MueLuPreconditioner_t
AmrMultiGridLevel< matrix_t, vector_t > AmrMultiGridLevel_t
std::size_t getNumIters()
std::size_t maxiter_m
maximum number of iterations allowed
void buildNoFinePoissonMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const scalar_t *invdx2)
double getYRangeMin(unsigned short level=0)
void writeSDDSData_m(const scalar_t &error)
int nBcPoints_m
maximum number of stencils points for BC
void setMaxNumberOfIterations(const std::size_t &maxiter)
void initBaseSolver_m(const BaseSolver &solver, const bool &rebalance, const std::string &reuse)
Smoother smootherType_m
type of smoother
Norm
Supported convergence criteria.
amrex::BoxArray boxarray_t
void initLevels_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrGeometry_t > &geom, bool regrid)
void smooth_m(const lo_t &level, Teuchos::RCP< vector_t > &e, Teuchos::RCP< vector_t > &r)
Ifpack2Preconditioner< AmrMultiGridLevel_t > Ifpack2Preconditioner_t
boundary_t bc_m[AMREX_SPACEDIM]
boundary conditions
void residual_m(const lo_t &level, Teuchos::RCP< vector_t > &r, const Teuchos::RCP< vector_t > &b, const Teuchos::RCP< vector_t > &x)
std::vector< std::shared_ptr< AmrSmoother > > smoother_m
error smoother
void buildInterpolationMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &cfab)
void computeEfield_m(AmrVectorFieldContainer_t &efield)
AmrMultiGridLevel_t::indices_t indices_t
Interpolater
Supported interpolaters for prolongation operation.
void prolongate_m(const lo_t &level)
bool isConverged_m(std::vector< scalar_t > &rhsNorms, std::vector< scalar_t > &resNorms)
Norm norm_m
norm for convergence criteria (l1, l2, linf)
double getYRangeMax(unsigned short level=0)
void setTolerance(const scalar_t &eps)
void solve(AmrScalarFieldContainer_t &rho, AmrScalarFieldContainer_t &phi, AmrVectorFieldContainer_t &efield, unsigned short baseLevel, unsigned short finestLevel, bool prevAsGuess=true)
AmrPreconditioner< matrix_t, AmrMultiGridLevel_t > preconditioner_t
MueLuBottomSolver< AmrMultiGridLevel_t > MueLuSolver_t
void buildRestrictionMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, D_DECL(const go_t &ii, const go_t &jj, const go_t &kk), const basefab_t &rfab)
Preconditioner convertToEnumPreconditioner_m(const std::string &prec)
void buildCompositePoissonMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const basefab_t &rfab, const scalar_t *invdx2)
std::unordered_map< go_t, scalar_t > umap_t
std::unique_ptr< AmrField_t > AmrField_u
std::shared_ptr< AmrField_t > AmrField_s
amr::AmrField_t AmrField_t
std::vector< go_t > indices_t
Type for matrix indices.
amr::AmrIntVect_t AmrIntVect_t
amr::AmrGeometry_t AmrGeometry_t
std::shared_ptr< AmrBoundary< AmrMultiGridLevel< MatrixType, VectorType > > > boundary_t
std::vector< scalar_t > coefficients_t
Type for matrix entries.
Smoother
All supported Ifpack2 smoothers.
Timing::TimerRef TimerRef