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;
Smoother convertToEnumSmoother_m(const std::string &smoother)
std::shared_ptr< bsolver_t > solver_mp
bottom solver
void setTolerance(const scalar_t &eps)
AmrMultiGridLevel_t::umap_t umap_t
amr::Preconditioner Preconditioner
void initPhysicalBoundary_m(const Boundary *bc)
Tpetra::CrsMatrix< scalar_t, local_ordinal_t, global_ordinal_t, node_t > matrix_t
void buildFineBoundaryMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const basefab_t &rfab)
AmrMultiGridLevel_t::AmrIntVect_t AmrIntVect_t
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)
AmrMultiGridLevel_t::coefficients_t coefficients_t
void smooth_m(const lo_t &level, Teuchos::RCP< vector_t > &e, Teuchos::RCP< vector_t > &r)
std::unique_ptr< AmrInterpolater< AmrMultiGridLevel_t > > interp_mp
interpolater without coarse-fine interface
amr::AmrField_t AmrField_t
Preconditioner convertToEnumPreconditioner_m(const std::string &prec)
std::vector< std::shared_ptr< AmrSmoother > > smoother_m
error smoother
std::shared_ptr< AmrField_t > AmrField_s
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)
BaseSolver
Supported bottom solvers.
scalar_t evalNorm_m(const Teuchos::RCP< const vector_t > &x)
void trilinos2amrex_m(const lo_t &level, const lo_t &comp, AmrField_t &mf, const Teuchos::RCP< vector_t > &mv)
void buildGradientMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const scalar_t *invdx)
std::shared_ptr< preconditioner_t > prec_mp
preconditioner for bottom solver
AmrMultiGridLevel_t::AmrField_s AmrField_s
void buildSingleLevel_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
std::ostream & operator<<(std::ostream &os, const Attribute &attr)
std::size_t bIter_m
number of iterations of bottom solver
void initResidual_m(std::vector< scalar_t > &rhsNorms, std::vector< scalar_t > &resNorms)
std::size_t maxiter_m
maximum number of iterations allowed
void buildInterpolationMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &cfab)
std::size_t nIter_m
number of iterations till convergence
Inform & print(Inform &os) const
Ifpack2Preconditioner< AmrMultiGridLevel_t > Ifpack2Preconditioner_t
double getYRangeMax(unsigned short level=0)
amr::AmrVectorFieldContainer_t AmrVectorFieldContainer_t
scalar_t getLevelResidualNorm(lo_t level)
AmrSmoother::Smoother Smoother
bool verbose_m
If true, a SDDS file is written.
void setup_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
Smoother smootherType_m
type of smoother
Smoother
All supported Ifpack2 smoothers.
amrex::BoxArray boxarray_t
Norm norm_m
norm for convergence criteria (l1, l2, linf)
void writeSDDSHeader_m(std::ofstream &outfile)
std::vector< std::unique_ptr< AmrMultiGridLevel_t > > mglevel_m
container for levels
void buildMultiLevel_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
std::vector< scalar_t > coefficients_t
Type for matrix entries.
amr::global_ordinal_t go_t
void setMaxNumberOfIterations(const std::size_t &maxiter)
AmrMultiGridLevel_t::indices_t indices_t
Timing::TimerRef TimerRef
Amesos2BottomSolver< AmrMultiGridLevel_t > Amesos2Solver_t
void buildNoFinePoissonMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const scalar_t *invdx2)
void residual_m(const lo_t &level, Teuchos::RCP< vector_t > &r, const Teuchos::RCP< vector_t > &b, const Teuchos::RCP< vector_t > &x)
double getZRangeMax(unsigned short level=0)
bool isConverged_m(std::vector< scalar_t > &rhsNorms, std::vector< scalar_t > &resNorms)
void computeEfield_m(AmrVectorFieldContainer_t &efield)
void initBaseSolver_m(const BaseSolver &solver, const bool &rebalance, const std::string &reuse)
std::string fname_m
SDDS filename.
Boundary convertToEnumBoundary_m(const std::string &bc)
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)
BottomSolver< Teuchos::RCP< matrix_t >, Teuchos::RCP< mv_t >, AmrMultiGridLevel_t > bsolver_t
int lbase_m
base level (currently only 0 supported)
Teuchos::MpiComm< int > comm_t
void writeSDDSData_m(const scalar_t &error)
Tpetra::Vector< scalar_t, local_ordinal_t, global_ordinal_t, node_t > vector_t
void initCrseFineInterp_m(const Interpolater &interface)
Boundary
Supported physical boundaries.
void initLevels_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrGeometry_t > &geom, bool regrid)
BelosBottomSolver< AmrMultiGridLevel_t > BelosSolver_t
void close_m(const lo_t &level, const bool &matrices)
std::unique_ptr< AmrInterpolater< AmrMultiGridLevel_t > > interface_mp
interpolater for coarse-fine interface
Norm convertToEnumNorm_m(const std::string &norm)
MueLuPreconditioner< AmrMultiGridLevel_t > MueLuPreconditioner_t
BaseSolver convertToEnumBaseSolver_m(const std::string &bsolver)
Interpolater
Supported interpolaters for prolongation operation.
std::vector< go_t > indices_t
Type for matrix indices.
amr::AmrField_t AmrField_t
void initInterpolater_m(const Interpolater &interp)
amr::AmrScalarFieldContainer_t AmrScalarFieldContainer_t
Norm
Supported convergence criteria.
std::size_t nSweeps_m
number of smoothing iterations
amrex::BaseFab< int > basefab_t
void buildDensityVector_m(const lo_t &level, const AmrField_t &rho)
Teuchos::RCP< comm_t > comm_mp
communicator
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)
amr::AmrGeometry_t AmrGeometry_t
std::shared_ptr< AmrBoundary< AmrMultiGridLevel< MatrixType, VectorType > > > boundary_t
AmrMultiGridLevel_t::AmrField_u AmrField_u
void setNumberOfSweeps(const std::size_t &nSweeps)
void map2vector_m(umap_t &map, indices_t &indices, coefficients_t &values)
amr::local_ordinal_t lo_t
void initPrec_m(const Preconditioner &prec, const std::string &reuse)
Tpetra::Map< local_ordinal_t, global_ordinal_t, node_t > dmap_t
void setVerbose(bool verbose)
std::unique_ptr< AmrField_t > AmrField_u
void restrict_m(const lo_t &level)
double getZRangeMin(unsigned short level=0)
std::unordered_map< go_t, scalar_t > umap_t
void averageDown_m(const lo_t &level)
void initGuess_m(bool reset)
constexpr double e
The value of .
AmrPreconditioner< matrix_t, AmrMultiGridLevel_t > preconditioner_t
amr::AmrIntVect_t AmrIntVect_t
void relax_m(const lo_t &level)
AmrMultiGridLevel< matrix_t, vector_t > AmrMultiGridLevel_t
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)
int nlevel_m
number of levelss
Tpetra::MultiVector< scalar_t, local_ordinal_t, global_ordinal_t, node_t > multivector_t
double getYRangeMin(unsigned short level=0)
void solve(AmrScalarFieldContainer_t &rho, AmrScalarFieldContainer_t &phi, AmrVectorFieldContainer_t &efield, unsigned short baseLevel, unsigned short finestLevel, bool prevAsGuess=true)
amrex::FArrayBox farraybox_t
double getXRangeMin(unsigned short level=0)
int nBcPoints_m
maximum number of stencils points for BC
void amrex2trilinos_m(const lo_t &level, const lo_t &comp, const AmrField_t &mf, Teuchos::RCP< vector_t > &mv)
std::size_t getNumIters()
void buildPotentialVector_m(const lo_t &level, const AmrField_t &phi)
boundary_t bc_m[AMREX_SPACEDIM]
boundary conditions
double getXRangeMax(unsigned short level=0)
Interpolater convertToEnumInterpolater_m(const std::string &interp)
scalar_t eps_m
rhs scale for convergence
AmrMultiGridLevel_t::AmrGeometry_t AmrGeometry_t
AmrMultiGridLevel_t::AmrField_t AmrField_t
std::string snorm_m
norm for convergence criteria
std::ios_base::openmode flag_m
std::ios::out or std::ios::app
void prolongate_m(const lo_t &level)
AmrMultiGridLevel_t::boundary_t boundary_t
void open_m(const lo_t &level, const bool &matrices)
MueLuBottomSolver< AmrMultiGridLevel_t > MueLuSolver_t