1 #ifndef AMR_MULTI_GRID_H
2 #define AMR_MULTI_GRID_H
8 #include <AMReX_MultiFab.H>
9 #include <AMReX_Vector.H>
20 #define AMR_MG_TIMER true
21 #define AMR_MG_WRITE false
48 Teuchos::RCP<matrix_t>,
90 #ifdef HAVE_AMESOS2_KLU2
93 #ifdef HAVE_AMESOS2_SUPERLU
96 #ifdef HAVE_AMESOS2_UMFPACK
99 #ifdef HAVE_AMESOS2_PARDISO_MKL
102 #ifdef HAVE_AMESOS2_MUMPS
105 #ifdef HAVE_AMESOS2_LAPACK
144 const std::string& bsolver,
145 const std::string& prec,
146 const bool& rebalance,
147 const std::string& reuse,
148 const std::string& bcx,
149 const std::string& bcy,
150 const std::string& bcz,
151 const std::string& smoother,
152 const std::size_t& nSweeps,
153 const std::string& interp,
154 const std::string& norm);
169 unsigned short baseLevel,
170 unsigned short finestLevel,
171 bool prevAsGuess =
true);
232 const amrex::Vector<AmrGeometry_t>& geom,
257 std::vector<scalar_t>& resNorms);
267 Teuchos::RCP<vector_t>& r,
268 const Teuchos::RCP<vector_t>& b,
269 const Teuchos::RCP<vector_t>& x);
286 Teuchos::RCP<vector_t>& result,
287 const Teuchos::RCP<vector_t>& rhs,
288 const Teuchos::RCP<vector_t>& crs_rhs,
289 const Teuchos::RCP<vector_t>& b);
295 void writeResidualNorm_m();
311 std::vector<scalar_t>& resNorms);
322 void setup_m(
const amrex::Vector<AmrField_u>& rho,
323 const amrex::Vector<AmrField_u>& phi,
324 const bool& matrices =
true);
330 const amrex::Vector<AmrField_u>& phi,
331 const bool& matrices =
true);
337 const amrex::Vector<AmrField_u>& phi,
338 const bool& matrices =
true);
345 void open_m(
const lo_t& level,
const bool& matrices);
352 void close_m(
const lo_t& level,
const bool& matrices);
402 D_DECL(
const go_t& ii,
500 Teuchos::RCP<vector_t>& mv);
512 const Teuchos::RCP<vector_t>& mv);
531 Teuchos::RCP<vector_t>&
e,
532 Teuchos::RCP<vector_t>& r);
571 const bool& rebalance,
572 const std::string& reuse);
581 const bool& rebalance,
582 const std::string& reuse);
644 std::unique_ptr<AmrInterpolater<AmrMultiGridLevel_t> >
interp_mp;
656 std::vector<std::unique_ptr<AmrMultiGridLevel_t > >
mglevel_m;
std::ostream & operator<<(std::ostream &os, const Attribute &attr)
std::vector< scalar_t > coefficients_t
Type for matrix entries.
std::vector< std::unique_ptr< AmrMultiGridLevel_t > > mglevel_m
container for levels
Interface to Amesos2 solvers of the Trilinos package.
std::unique_ptr< AmrInterpolater< AmrMultiGridLevel_t > > interface_mp
interpolater for coarse-fine interface
AmrMultiGridLevel_t::boundary_t boundary_t
Bottom solver preconditioners.
constexpr double e
The value of .
void close_m(const lo_t &level, const bool &matrices)
std::unordered_map< go_t, scalar_t > umap_t
void buildNoFinePoissonMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const scalar_t *invdx2)
MueLuPreconditioner< AmrMultiGridLevel_t > MueLuPreconditioner_t
Norm convertToEnumNorm_m(const std::string &norm)
AmrPreconditioner< matrix_t, AmrMultiGridLevel_t > preconditioner_t
amr::AmrField_t AmrField_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)
void residual_m(const lo_t &level, Teuchos::RCP< vector_t > &r, const Teuchos::RCP< vector_t > &b, const Teuchos::RCP< vector_t > &x)
void buildDensityVector_m(const lo_t &level, const AmrField_t &rho)
amrex::FArrayBox farraybox_t
Teuchos::RCP< comm_t > comm_mp
communicator
void smooth_m(const lo_t &level, Teuchos::RCP< vector_t > &e, Teuchos::RCP< vector_t > &r)
double getXRangeMin(unsigned short level=0)
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)
int nBcPoints_m
maximum number of stencils points for BC
scalar_t getLevelResidualNorm(lo_t level)
bool verbose_m
If true, a SDDS file is written.
Smoother
All supported Ifpack2 smoothers.
void buildPotentialVector_m(const lo_t &level, const AmrField_t &phi)
void initCrseFineInterp_m(const Interpolater &interface)
void setVerbose(bool verbose)
void initGuess_m(bool reset)
Amesos2BottomSolver< AmrMultiGridLevel_t > Amesos2Solver_t
std::ios_base::openmode flag_m
std::ios::out or std::ios::app
void open_m(const lo_t &level, const bool &matrices)
MueLuBottomSolver< AmrMultiGridLevel_t > MueLuSolver_t
BaseSolver convertToEnumBaseSolver_m(const std::string &bsolver)
void initInterpolater_m(const Interpolater &interp)
std::size_t nIter_m
number of iterations till convergence
int nlevel_m
number of levelss
std::size_t nSweeps_m
number of smoothing iterations
AmrMultiGridLevel_t::AmrIntVect_t AmrIntVect_t
void solve(AmrScalarFieldContainer_t &rho, AmrScalarFieldContainer_t &phi, AmrVectorFieldContainer_t &efield, unsigned short baseLevel, unsigned short finestLevel, bool prevAsGuess=true)
double getYRangeMin(unsigned short level=0)
void setNumberOfSweeps(const std::size_t &nSweeps)
Abstract base class for all base level solvers.
BottomSolver< Teuchos::RCP< matrix_t >, Teuchos::RCP< mv_t >, AmrMultiGridLevel_t > bsolver_t
int lbase_m
base level (currently only 0 supported)
void writeSDDSData_m(const scalar_t &error)
double getXRangeMax(unsigned short level=0)
Interpolater convertToEnumInterpolater_m(const std::string &interp)
AmrMultiGridLevel_t::AmrGeometry_t AmrGeometry_t
std::string snorm_m
norm for convergence criteria
void buildSingleLevel_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
AmrMultiGridLevel< matrix_t, vector_t > AmrMultiGridLevel_t
void buildCompositePoissonMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const basefab_t &rfab, const basefab_t &cfab, const scalar_t *invdx2)
double getZRangeMax(unsigned short level=0)
std::shared_ptr< bsolver_t > solver_mp
bottom solver
amr::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 initPrec_m(const Preconditioner &prec, const bool &rebalance, const std::string &reuse)
Teuchos::MpiComm< int > comm_t
double getYRangeMax(unsigned short level=0)
std::shared_ptr< AmrBoundary< AmrMultiGridLevel< MatrixType, VectorType > > > boundary_t
std::size_t getNumIters()
void map2vector_m(umap_t &map, indices_t &indices, coefficients_t &values)
amr::local_ordinal_t lo_t
BaseSolver
Supported bottom solvers.
std::vector< std::shared_ptr< AmrSmoother > > smoother_m
error smoother
AmrMultiGridLevel_t::AmrField_t AmrField_t
Norm norm_m
norm for convergence criteria (l1, l2, linf)
boundary_t bc_m[AMREX_SPACEDIM]
boundary conditions
Tpetra::Map< local_ordinal_t, global_ordinal_t, node_t > dmap_t
std::unique_ptr< AmrField_t > AmrField_u
void restrict_m(const lo_t &level)
double getZRangeMin(unsigned short level=0)
void averageDown_m(const lo_t &level)
void initResidual_m(std::vector< scalar_t > &rhsNorms, std::vector< scalar_t > &resNorms)
void prolongate_m(const lo_t &level)
Smoother convertToEnumSmoother_m(const std::string &smoother)
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)
AmrMultiGridLevel_t::umap_t umap_t
void initPhysicalBoundary_m(const Boundary *bc)
Inform & print(Inform &os) const
Interface to Belos solvers of the Trilinos package.
void initBaseSolver_m(const BaseSolver &solver, const bool &rebalance, const std::string &reuse)
std::string fname_m
SDDS filename.
Norm
Supported convergence criteria.
Ifpack2Preconditioner< AmrMultiGridLevel_t > Ifpack2Preconditioner_t
Boundary convertToEnumBoundary_m(const std::string &bc)
Tpetra::CrsMatrix< scalar_t, local_ordinal_t, global_ordinal_t, node_t > matrix_t
Preconditioner convertToEnumPreconditioner_m(const std::string &prec)
AmrMultiGridLevel_t::AmrField_u AmrField_u
Tpetra::MultiVector< scalar_t, local_ordinal_t, global_ordinal_t, node_t > multivector_t
void buildFineBoundaryMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const basefab_t &rfab, const basefab_t &cfab)
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
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)
amrex::BoxArray boxarray_t
void writeSDDSHeader_m(std::ofstream &outfile)
std::shared_ptr< AmrField_t > AmrField_s
Teuchos::RCP< amr::node_t > node_mp
kokkos node
Boundary
Supported physical boundaries.
void buildGradientMatrix_m(const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const scalar_t *invdx)
scalar_t evalNorm_m(const Teuchos::RCP< const vector_t > &x)
void buildMultiLevel_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
amr::global_ordinal_t go_t
void trilinos2amrex_m(const lo_t &level, const lo_t &comp, AmrField_t &mf, const Teuchos::RCP< vector_t > &mv)
std::shared_ptr< preconditioner_t > prec_mp
preconditioner for bottom solver
BelosBottomSolver< AmrMultiGridLevel_t > BelosSolver_t
Timing::TimerRef TimerRef
AmrMultiGridLevel_t::indices_t indices_t
void initLevels_m(const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrGeometry_t > &geom, bool regrid)
amr::AmrScalarFieldContainer_t AmrScalarFieldContainer_t
void setMaxNumberOfIterations(const std::size_t &maxiter)
AmrMultiGridLevel_t::AmrField_s AmrField_s
Tpetra::Vector< scalar_t, local_ordinal_t, global_ordinal_t, node_t > vector_t
std::size_t bIter_m
number of iterations of bottom solver
const scalar_t eps_m
rhs scale for convergence
void relax_m(const lo_t &level)
amr::Preconditioner Preconditioner
Interpolater
Supported interpolaters for prolongation operation.
void computeEfield_m(AmrVectorFieldContainer_t &efield)
bool isConverged_m(std::vector< scalar_t > &rhsNorms, std::vector< scalar_t > &resNorms)
std::vector< go_t > indices_t
Type for matrix indices.
amrex::BaseFab< int > basefab_t
amr::AmrGeometry_t AmrGeometry_t
amr::AmrVectorFieldContainer_t AmrVectorFieldContainer_t
AmrSmoother::Smoother Smoother
amr::AmrField_t AmrField_t
std::unique_ptr< AmrInterpolater< AmrMultiGridLevel_t > > interp_mp
interpolater without coarse-fine interface
void amrex2trilinos_m(const lo_t &level, const lo_t &comp, const AmrField_t &mf, Teuchos::RCP< vector_t > &mv)