OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
AmrMultiGrid Class Reference

#include <AmrMultiGrid.h>

Inheritance diagram for AmrMultiGrid:
Inheritance graph
[legend]
Collaboration diagram for AmrMultiGrid:
Collaboration graph
[legend]

Public Types

enum  Interpolater { TRILINEAR = 0 , LAGRANGE , PIECEWISE_CONST }
 Supported interpolaters for prolongation operation. More...
 
enum  BaseSolver {
  BICGSTAB , MINRES , PCPG , CG ,
  GMRES , STOCHASTIC_CG , RECYCLING_CG , RECYCLING_GMRES ,
  SA
}
 Supported bottom solvers. More...
 
enum  Boundary { DIRICHLET = 0 , OPEN , PERIODIC }
 Supported physical boundaries. More...
 
enum  Norm { L1 , L2 , LINF }
 Supported convergence criteria. More...
 
typedef amr::matrix_t matrix_t
 
typedef amr::vector_t vector_t
 
typedef amr::multivector_t mv_t
 
typedef amr::dmap_t dmap_t
 
typedef amr::comm_t comm_t
 
typedef amr::local_ordinal_t lo_t
 
typedef amr::global_ordinal_t go_t
 
typedef amr::scalar_t scalar_t
 
typedef AmrMultiGridLevel< matrix_t, vector_tAmrMultiGridLevel_t
 
typedef AmrMultiGridLevel_t::AmrField_t AmrField_t
 
typedef AmrMultiGridLevel_t::AmrGeometry_t AmrGeometry_t
 
typedef AmrMultiGridLevel_t::AmrField_u AmrField_u
 
typedef AmrMultiGridLevel_t::AmrField_s AmrField_s
 
typedef AmrMultiGridLevel_t::AmrIntVect_t AmrIntVect_t
 
typedef AmrMultiGridLevel_t::indices_t indices_t
 
typedef AmrMultiGridLevel_t::coefficients_t coefficients_t
 
typedef AmrMultiGridLevel_t::umap_t umap_t
 
typedef AmrMultiGridLevel_t::boundary_t boundary_t
 
typedef BottomSolver< Teuchos::RCP< matrix_t >, Teuchos::RCP< mv_t >, AmrMultiGridLevel_tbsolver_t
 
typedef BelosBottomSolver< AmrMultiGridLevel_tBelosSolver_t
 
typedef Amesos2BottomSolver< AmrMultiGridLevel_tAmesos2Solver_t
 
typedef MueLuBottomSolver< AmrMultiGridLevel_tMueLuSolver_t
 
typedef AmrPreconditioner< matrix_t, AmrMultiGridLevel_tpreconditioner_t
 
typedef Ifpack2Preconditioner< AmrMultiGridLevel_tIfpack2Preconditioner_t
 
typedef MueLuPreconditioner< AmrMultiGridLevel_tMueLuPreconditioner_t
 
typedef amrex::BoxArray boxarray_t
 
typedef amrex::Box box_t
 
typedef amrex::BaseFab< int > basefab_t
 
typedef amrex::FArrayBox farraybox_t
 
typedef AmrSmoother::Smoother Smoother
 
typedef amr::Preconditioner Preconditioner
 

Public Member Functions

 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 solve (AmrScalarFieldContainer_t &rho, AmrScalarFieldContainer_t &phi, AmrVectorFieldContainer_t &efield, unsigned short baseLevel, unsigned short finestLevel, bool prevAsGuess=true)
 
void setNumberOfSweeps (const std::size_t &nSweeps)
 
void setMaxNumberOfIterations (const std::size_t &maxiter)
 
std::size_t getNumIters ()
 
scalar_t getLevelResidualNorm (lo_t level)
 
void setVerbose (bool verbose)
 
void setTolerance (const scalar_t &eps)
 
double getXRangeMin (unsigned short level=0)
 
double getXRangeMax (unsigned short level=0)
 
double getYRangeMin (unsigned short level=0)
 
double getYRangeMax (unsigned short level=0)
 
double getZRangeMin (unsigned short level=0)
 
double getZRangeMax (unsigned short level=0)
 
Informprint (Inform &os) const
 
- Public Member Functions inherited from AmrPoissonSolver< AmrBoxLib >
 AmrPoissonSolver (AmrBoxLib *itsAmrObject_p)
 
virtual ~AmrPoissonSolver ()
 
void computePotential (Field_t &, Vector_t)
 
void computePotential (Field_t &, Vector_t, double)
 
void test (PartBunchBase< double, 3 > *)
 
void hasToRegrid ()
 
- Public Member Functions inherited from PoissonSolver
virtual ~PoissonSolver ()
 
virtual void resizeMesh (Vector_t &, Vector_t &, const Vector_t &, const Vector_t &, double)
 

Private Member Functions

void initPhysicalBoundary_m (const Boundary *bc)
 
void initLevels_m (const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrGeometry_t > &geom, bool regrid)
 
void clearMasks_m ()
 
void initGuess_m (bool reset)
 
scalar_t iterate_m ()
 
bool isConverged_m (std::vector< scalar_t > &rhsNorms, std::vector< scalar_t > &resNorms)
 
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 relax_m (const lo_t &level)
 
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 evalNorm_m (const Teuchos::RCP< const vector_t > &x)
 
void initResidual_m (std::vector< scalar_t > &rhsNorms, std::vector< scalar_t > &resNorms)
 
void computeEfield_m (AmrVectorFieldContainer_t &efield)
 
void setup_m (const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
 
void buildSingleLevel_m (const amrex::Vector< AmrField_u > &rho, const amrex::Vector< AmrField_u > &phi, const bool &matrices=true)
 
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 close_m (const lo_t &level, const bool &matrices)
 
void buildNoFinePoissonMatrix_m (const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const scalar_t *invdx2)
 
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)
 
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)
 
void buildInterpolationMatrix_m (const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &cfab)
 
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)
 
void buildFineBoundaryMatrix_m (const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const basefab_t &rfab)
 
void buildDensityVector_m (const lo_t &level, const AmrField_t &rho)
 
void buildPotentialVector_m (const lo_t &level, const AmrField_t &phi)
 
void buildGradientMatrix_m (const lo_t &level, const go_t &gidx, const AmrIntVect_t &iv, const basefab_t &mfab, const scalar_t *invdx)
 
void amrex2trilinos_m (const lo_t &level, const lo_t &comp, const AmrField_t &mf, Teuchos::RCP< vector_t > &mv)
 
void trilinos2amrex_m (const lo_t &level, const lo_t &comp, AmrField_t &mf, const Teuchos::RCP< vector_t > &mv)
 
void map2vector_m (umap_t &map, indices_t &indices, coefficients_t &values)
 
void smooth_m (const lo_t &level, Teuchos::RCP< vector_t > &e, Teuchos::RCP< vector_t > &r)
 
void restrict_m (const lo_t &level)
 
void prolongate_m (const lo_t &level)
 
void averageDown_m (const lo_t &level)
 
void initInterpolater_m (const Interpolater &interp)
 
void initCrseFineInterp_m (const Interpolater &interface)
 
void initBaseSolver_m (const BaseSolver &solver, const bool &rebalance, const std::string &reuse)
 
void initPrec_m (const Preconditioner &prec, const std::string &reuse)
 
Boundary convertToEnumBoundary_m (const std::string &bc)
 
Interpolater convertToEnumInterpolater_m (const std::string &interp)
 
BaseSolver convertToEnumBaseSolver_m (const std::string &bsolver)
 
Preconditioner convertToEnumPreconditioner_m (const std::string &prec)
 
Smoother convertToEnumSmoother_m (const std::string &smoother)
 
Norm convertToEnumNorm_m (const std::string &norm)
 
void writeSDDSHeader_m (std::ofstream &outfile)
 
void writeSDDSData_m (const scalar_t &error)
 

Private Attributes

Teuchos::RCP< comm_tcomm_mp
 communicator More...
 
std::unique_ptr< AmrInterpolater< AmrMultiGridLevel_t > > interp_mp
 interpolater without coarse-fine interface More...
 
std::unique_ptr< AmrInterpolater< AmrMultiGridLevel_t > > interface_mp
 interpolater for coarse-fine interface More...
 
std::size_t nIter_m
 number of iterations till convergence More...
 
std::size_t bIter_m
 number of iterations of bottom solver More...
 
std::size_t maxiter_m
 maximum number of iterations allowed More...
 
std::size_t nSweeps_m
 number of smoothing iterations More...
 
Smoother smootherType_m
 type of smoother More...
 
std::vector< std::unique_ptr< AmrMultiGridLevel_t > > mglevel_m
 container for levels More...
 
std::shared_ptr< bsolver_tsolver_mp
 bottom solver More...
 
std::vector< std::shared_ptr< AmrSmoother > > smoother_m
 error smoother More...
 
std::shared_ptr< preconditioner_tprec_mp
 preconditioner for bottom solver More...
 
int lbase_m
 base level (currently only 0 supported) More...
 
int lfine_m
 fineste level More...
 
int nlevel_m
 number of levelss More...
 
boundary_t bc_m [AMREX_SPACEDIM]
 boundary conditions More...
 
int nBcPoints_m
 maximum number of stencils points for BC More...
 
Norm norm_m
 norm for convergence criteria (l1, l2, linf) More...
 
std::string snorm_m
 norm for convergence criteria More...
 
scalar_t eps_m
 rhs scale for convergence More...
 
bool verbose_m
 If true, a SDDS file is written. More...
 
std::string fname_m
 SDDS filename. More...
 
std::ios_base::openmode flag_m
 std::ios::out or std::ios::app More...
 

Additional Inherited Members

- Protected Types inherited from PoissonSolver
typedef Field< int, 3, Mesh_t, Center_tIField_t
 
typedef Field< std::complex< double >, 3, Mesh_t, Center_tCxField_t
 
- Protected Attributes inherited from AmrPoissonSolver< AmrBoxLib >
AmrBoxLibitsAmrObject_mp
 
bool regrid_m
 is set to true by itsAmrObject_mp and reset to false by solver More...
 

Detailed Description

Definition at line 44 of file AmrMultiGrid.h.

Member Typedef Documentation

◆ Amesos2Solver_t

Definition at line 75 of file AmrMultiGrid.h.

◆ AmrField_s

Definition at line 61 of file AmrMultiGrid.h.

◆ AmrField_t

Definition at line 58 of file AmrMultiGrid.h.

◆ AmrField_u

Definition at line 60 of file AmrMultiGrid.h.

◆ AmrGeometry_t

Definition at line 59 of file AmrMultiGrid.h.

◆ AmrIntVect_t

Definition at line 62 of file AmrMultiGrid.h.

◆ AmrMultiGridLevel_t

Definition at line 56 of file AmrMultiGrid.h.

◆ basefab_t

typedef amrex::BaseFab<int> AmrMultiGrid::basefab_t

Definition at line 85 of file AmrMultiGrid.h.

◆ BelosSolver_t

Definition at line 74 of file AmrMultiGrid.h.

◆ boundary_t

Definition at line 66 of file AmrMultiGrid.h.

◆ box_t

typedef amrex::Box AmrMultiGrid::box_t

Definition at line 84 of file AmrMultiGrid.h.

◆ boxarray_t

typedef amrex::BoxArray AmrMultiGrid::boxarray_t

Definition at line 83 of file AmrMultiGrid.h.

◆ bsolver_t

typedef BottomSolver< Teuchos::RCP<matrix_t>, Teuchos::RCP<mv_t>, AmrMultiGridLevel_t > AmrMultiGrid::bsolver_t

Definition at line 72 of file AmrMultiGrid.h.

◆ coefficients_t

Definition at line 64 of file AmrMultiGrid.h.

◆ comm_t

Definition at line 51 of file AmrMultiGrid.h.

◆ dmap_t

Definition at line 50 of file AmrMultiGrid.h.

◆ farraybox_t

typedef amrex::FArrayBox AmrMultiGrid::farraybox_t

Definition at line 86 of file AmrMultiGrid.h.

◆ go_t

Definition at line 53 of file AmrMultiGrid.h.

◆ Ifpack2Preconditioner_t

Definition at line 80 of file AmrMultiGrid.h.

◆ indices_t

Definition at line 63 of file AmrMultiGrid.h.

◆ lo_t

Definition at line 52 of file AmrMultiGrid.h.

◆ matrix_t

Definition at line 47 of file AmrMultiGrid.h.

◆ MueLuPreconditioner_t

Definition at line 81 of file AmrMultiGrid.h.

◆ MueLuSolver_t

Definition at line 76 of file AmrMultiGrid.h.

◆ mv_t

Definition at line 49 of file AmrMultiGrid.h.

◆ Preconditioner

Definition at line 90 of file AmrMultiGrid.h.

◆ preconditioner_t

Definition at line 78 of file AmrMultiGrid.h.

◆ scalar_t

Definition at line 54 of file AmrMultiGrid.h.

◆ Smoother

Definition at line 88 of file AmrMultiGrid.h.

◆ umap_t

Definition at line 65 of file AmrMultiGrid.h.

◆ vector_t

Definition at line 48 of file AmrMultiGrid.h.

Member Enumeration Documentation

◆ BaseSolver

Supported bottom solvers.

Enumerator
BICGSTAB 
MINRES 
PCPG 
CG 
GMRES 
STOCHASTIC_CG 
RECYCLING_CG 
RECYCLING_GMRES 
SA 

Definition at line 100 of file AmrMultiGrid.h.

◆ Boundary

Supported physical boundaries.

Enumerator
DIRICHLET 
OPEN 
PERIODIC 

Definition at line 135 of file AmrMultiGrid.h.

◆ Interpolater

Supported interpolaters for prolongation operation.

Enumerator
TRILINEAR 
LAGRANGE 
PIECEWISE_CONST 

Definition at line 93 of file AmrMultiGrid.h.

◆ Norm

Supported convergence criteria.

Enumerator
L1 
L2 
LINF 

Definition at line 142 of file AmrMultiGrid.h.

Constructor & Destructor Documentation

◆ AmrMultiGrid()

AmrMultiGrid::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 
)

Instantiation used in Structure/FieldSolver.cpp

Parameters
itsAmrObject_phas information about refinemen ratios, etc.
bsolverbottom solver
precpreconditioner for bottom solver
rebalanceof preconditioner (SA only)
bcxboundary condition in x
bcyboundary condition in y
bczboundary condition in z
smootherfor level solution
nSweepswhen smoothing
interpinterpolater between levels
normfor convergence criteria

Definition at line 42 of file AmrMultiGrid.cpp.

References convertToEnumBaseSolver_m(), convertToEnumBoundary_m(), convertToEnumInterpolater_m(), convertToEnumNorm_m(), convertToEnumPreconditioner_m(), convertToEnumSmoother_m(), endl(), flag_m, fname_m, INFOMSG, initBaseSolver_m(), initCrseFineInterp_m(), initInterpolater_m(), initPhysicalBoundary_m(), initPrec_m(), norm_m, and smootherType_m.

Here is the call graph for this function:

Member Function Documentation

◆ amrex2trilinos_m()

void AmrMultiGrid::amrex2trilinos_m ( const lo_t level,
const lo_t comp,
const AmrField_t mf,
Teuchos::RCP< vector_t > &  mv 
)
private

Data transfer from AMReX to Trilinos.

Parameters
mfis the multifab of a level
compcomponent to copy
mvis the vector to be filled
levelwhere to perform

Definition at line 1656 of file AmrMultiGrid.cpp.

References mglevel_m.

Referenced by buildDensityVector_m(), and buildPotentialVector_m().

◆ averageDown_m()

void AmrMultiGrid::averageDown_m ( const lo_t level)
private

Average data from fine level to coarse

Parameters
levelfinest level is omitted

Definition at line 1844 of file AmrMultiGrid.cpp.

References lfine_m, mglevel_m, IpplTimings::startTimer(), and IpplTimings::stopTimer().

Referenced by solve().

Here is the call graph for this function:

◆ buildCompositePoissonMatrix_m()

void AmrMultiGrid::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 
)
private

Build the Poisson matrix for a level that got refined (it does not take the covered cells (covered by fine cells) into account). The finest level does not build such a matrix. It takes care of physical boundaries (i.e. mesh boundary). Internal boundaries (i.e. boundaries due to crse-fine interfaces) are treated by the boundary matrix.

Parameters
ivis the current cell
mfabis the mask (internal cell, boundary cell, ...) of that level
rfabis the mask between levels
levelfor which we build the special Poisson matrix

Definition at line 1111 of file AmrMultiGrid.cpp.

References interface_mp, lbase_m, and mglevel_m.

Referenced by buildMultiLevel_m().

◆ buildCrseBoundaryMatrix_m()

void AmrMultiGrid::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 
)
private

The boundary values at the crse-fine-interface need to be taken into account properly. This matrix is used to update the fine boundary values from the coarse values, i.e.

\[ x^{(l)} = B_{crse}\cdot x^{(l-1)} \]

Dirichlet boundary condition

Parameters
ivis the current cell
mfabis the mask (internal cell, boundary cell, ...) of that level
cellsall fine cells that are at the crse-fine interface
levelthe base level is omitted

Definition at line 1358 of file AmrMultiGrid.cpp.

References interface_mp, lbase_m, and mglevel_m.

Referenced by buildMultiLevel_m().

◆ buildDensityVector_m()

void AmrMultiGrid::buildDensityVector_m ( const lo_t level,
const AmrField_t rho 
)
inlineprivate

Copy data from AMReX to Trilinos

Parameters
rhois the charge density
levelfor which to copy

Definition at line 1564 of file AmrMultiGrid.cpp.

References amrex2trilinos_m(), and mglevel_m.

Referenced by buildMultiLevel_m(), and buildSingleLevel_m().

Here is the call graph for this function:

◆ buildFineBoundaryMatrix_m()

void AmrMultiGrid::buildFineBoundaryMatrix_m ( const lo_t level,
const go_t gidx,
const AmrIntVect_t iv,
const basefab_t mfab,
const basefab_t rfab 
)
private

The boundary values at the crse-fine-interface need to be taken into account properly. This matrix is used to update the coarse boundary values from fine values, i.e.

\[ x^{(l)} = B_{fine}\cdot x^{(l+1)} \]

Dirichlet boundary condition. Flux matching.

Parameters
levelthe finest level is omitted
gidxthe global index
ivis the current cell
mfabis the mask (internal cell, boundary cell, ...) of that level
rfabis the mask between levels

Definition at line 1423 of file AmrMultiGrid.cpp.

References begin(), end(), interface_mp, lfine_m, and mglevel_m.

Referenced by buildMultiLevel_m().

Here is the call graph for this function:

◆ buildGradientMatrix_m()

void AmrMultiGrid::buildGradientMatrix_m ( const lo_t level,
const go_t gidx,
const AmrIntVect_t iv,
const basefab_t mfab,
const scalar_t invdx 
)
private

Gradient matrix is used to compute the electric field

Parameters
ivis the current cell
mfabis the mask (internal cell, boundary cell, ...) of that level
levelfor which to compute

Definition at line 1578 of file AmrMultiGrid.cpp.

References lbase_m, map2vector_m(), and mglevel_m.

Referenced by buildMultiLevel_m(), and buildSingleLevel_m().

Here is the call graph for this function:

◆ buildInterpolationMatrix_m()

void AmrMultiGrid::buildInterpolationMatrix_m ( const lo_t level,
const go_t gidx,
const AmrIntVect_t iv,
const basefab_t cfab 
)
private

Interpolate data from coarse cells to appropriate refined cells. The interpolation scheme is allowed only to have local cells in the stencil, i.e. 2D --> 4, 3D --> 8.

\[ x^{(l)} = I\cdot x^{(l-1)} \]

Parameters
ivis the current cell
levelfor which to build the interpolation matrix. The finest level does not build such a matrix.

Definition at line 1321 of file AmrMultiGrid.cpp.

References interp_mp, lbase_m, and mglevel_m.

Referenced by buildMultiLevel_m().

◆ buildMultiLevel_m()

void AmrMultiGrid::buildMultiLevel_m ( const amrex::Vector< AmrField_u > &  rho,
const amrex::Vector< AmrField_u > &  phi,
const bool &  matrices = true 
)
private

◆ buildNoFinePoissonMatrix_m()

void AmrMultiGrid::buildNoFinePoissonMatrix_m ( const lo_t level,
const go_t gidx,
const AmrIntVect_t iv,
const basefab_t mfab,
const scalar_t invdx2 
)
private

Build the Poisson matrix for a level assuming no finer level (i.e. the whole fine mesh is taken into account). It takes care of physical boundaries (i.e. mesh boundary). Internal boundaries (i.e. boundaries due to crse-fine interfaces) are treated by the boundary matrix.

Parameters
ivis the current cell
mfabis the mask (internal cell, boundary cell, ...) of that level
levelfor which we build the Poisson matrix

Definition at line 1030 of file AmrMultiGrid.cpp.

References interface_mp, lbase_m, and mglevel_m.

Referenced by buildMultiLevel_m(), and buildSingleLevel_m().

◆ buildPotentialVector_m()

void AmrMultiGrid::buildPotentialVector_m ( const lo_t level,
const AmrField_t phi 
)
inlineprivate

Copy data from AMReX to Trilinos

Parameters
phiis the potential
levelfor which to copy

Definition at line 1571 of file AmrMultiGrid.cpp.

References amrex2trilinos_m(), and mglevel_m.

Here is the call graph for this function:

◆ buildRestrictionMatrix_m()

void AmrMultiGrid::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 
)
private

Build a matrix that averages down the data of the fine cells down to the corresponding coarse cells. The base level does not build such a matrix.

\[ x^{(l)} = R\cdot x^{(l+1)} \]

Parameters
ivis the current cell
rfabis the mask between levels
levelfor which to build restriction matrix

Definition at line 1269 of file AmrMultiGrid.cpp.

References lfine_m, mglevel_m, and serialize().

Referenced by buildMultiLevel_m().

Here is the call graph for this function:

◆ buildSingleLevel_m()

void AmrMultiGrid::buildSingleLevel_m ( const amrex::Vector< AmrField_u > &  rho,
const amrex::Vector< AmrField_u > &  phi,
const bool &  matrices = true 
)
private

Build all matrices and vectors needed for single-level computation

Definition at line 717 of file AmrMultiGrid.cpp.

References buildDensityVector_m(), buildGradientMatrix_m(), buildNoFinePoissonMatrix_m(), close_m(), lbase_m, mglevel_m, open_m(), and solver_mp.

Referenced by setup_m().

Here is the call graph for this function:

◆ clearMasks_m()

void AmrMultiGrid::clearMasks_m ( )
private

Clear masks (required to build matrices) no longer needed.

Definition at line 317 of file AmrMultiGrid.cpp.

References mglevel_m, and nlevel_m.

Referenced by setup_m().

◆ close_m()

void AmrMultiGrid::close_m ( const lo_t level,
const bool &  matrices 
)
private

Call fill complete

Parameters
levelfor which we filled matrix
matricesif we set matrices as well.

Definition at line 992 of file AmrMultiGrid.cpp.

References lbase_m, lfine_m, mglevel_m, and solver_mp.

Referenced by buildMultiLevel_m(), and buildSingleLevel_m().

◆ computeEfield_m()

void AmrMultiGrid::computeEfield_m ( AmrVectorFieldContainer_t efield)
private
Parameters
efieldto compute

Definition at line 664 of file AmrMultiGrid.cpp.

References lbase_m, mglevel_m, nlevel_m, IpplTimings::startTimer(), IpplTimings::stopTimer(), and trilinos2amrex_m().

Referenced by solve().

Here is the call graph for this function:

◆ convertToEnumBaseSolver_m()

AmrMultiGrid::BaseSolver AmrMultiGrid::convertToEnumBaseSolver_m ( const std::string &  bsolver)
private

Converts string to enum BaseSolver

Parameters
bsolverbottom solver

Definition at line 2041 of file AmrMultiGrid.cpp.

References amr::SA.

Referenced by AmrMultiGrid().

◆ convertToEnumBoundary_m()

AmrMultiGrid::Boundary AmrMultiGrid::convertToEnumBoundary_m ( const std::string &  bc)
private

Convertstring to enum Boundary

Parameters
bcboundary condition

Definition at line 2008 of file AmrMultiGrid.cpp.

Referenced by AmrMultiGrid().

◆ convertToEnumInterpolater_m()

AmrMultiGrid::Interpolater AmrMultiGrid::convertToEnumInterpolater_m ( const std::string &  interp)
private

Converts string to enum Interpolater

Parameters
interpinterpolater

Definition at line 2024 of file AmrMultiGrid.cpp.

Referenced by AmrMultiGrid().

◆ convertToEnumNorm_m()

AmrMultiGrid::Norm AmrMultiGrid::convertToEnumNorm_m ( const std::string &  norm)
private

Converts string to enum Norm

Parameters
normeither L1, L2, LInf

Definition at line 2107 of file AmrMultiGrid.cpp.

References Hypervolume::n.

Referenced by AmrMultiGrid().

◆ convertToEnumPreconditioner_m()

AmrMultiGrid::Preconditioner AmrMultiGrid::convertToEnumPreconditioner_m ( const std::string &  prec)
private

Converts string to enum Preconditioner

Parameters
precpreconditioner

Definition at line 2082 of file AmrMultiGrid.cpp.

References Ifpack2Preconditioner< Level >::fillMap(), MueLuPreconditioner< Level >::fillMap(), and EmissionModelT::NONE.

Referenced by AmrMultiGrid().

Here is the call graph for this function:

◆ convertToEnumSmoother_m()

AmrMultiGrid::Smoother AmrMultiGrid::convertToEnumSmoother_m ( const std::string &  smoother)
private

Converts string to enum Smoother

Parameters
smootherof level solution

Definition at line 2101 of file AmrMultiGrid.cpp.

References AmrSmoother::convertToEnumSmoother().

Referenced by AmrMultiGrid().

Here is the call graph for this function:

◆ evalNorm_m()

AmrMultiGrid::scalar_t AmrMultiGrid::evalNorm_m ( const Teuchos::RCP< const vector_t > &  x)
private

Vector norm computation.

Parameters
xis the vector for which we compute the norm
Returns
the evaluated norm of a level

Definition at line 595 of file AmrMultiGrid.cpp.

References norm_m.

Referenced by getLevelResidualNorm(), and initResidual_m().

◆ getLevelResidualNorm()

AmrMultiGrid::scalar_t AmrMultiGrid::getLevelResidualNorm ( lo_t  level)

Obtain the residual norm of a level

Parameters
levelfor which error is requested
Returns
the norm of the residual

Definition at line 184 of file AmrMultiGrid.cpp.

References evalNorm_m(), and mglevel_m.

Referenced by iterate_m().

Here is the call graph for this function:

◆ getNumIters()

std::size_t AmrMultiGrid::getNumIters ( )

Obtain some convergence info

Returns
the number of iterations till convergence

Definition at line 179 of file AmrMultiGrid.cpp.

References nIter_m.

◆ getXRangeMax()

double AmrMultiGrid::getXRangeMax ( unsigned short  level = 0)
virtual

Implements PoissonSolver.

Definition at line 2241 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

◆ getXRangeMin()

double AmrMultiGrid::getXRangeMin ( unsigned short  level = 0)
virtual

Implements PoissonSolver.

Definition at line 2236 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

◆ getYRangeMax()

double AmrMultiGrid::getYRangeMax ( unsigned short  level = 0)
virtual

Implements PoissonSolver.

Definition at line 2251 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

◆ getYRangeMin()

double AmrMultiGrid::getYRangeMin ( unsigned short  level = 0)
virtual

Implements PoissonSolver.

Definition at line 2246 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

◆ getZRangeMax()

double AmrMultiGrid::getZRangeMax ( unsigned short  level = 0)
virtual

Implements PoissonSolver.

Definition at line 2261 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

◆ getZRangeMin()

double AmrMultiGrid::getZRangeMin ( unsigned short  level = 0)
virtual

Implements PoissonSolver.

Definition at line 2256 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

◆ initBaseSolver_m()

void AmrMultiGrid::initBaseSolver_m ( const BaseSolver solver,
const bool &  rebalance,
const std::string &  reuse 
)
private

Instantiate a bottom solver

Parameters
solvertype
rebalancesolver (SA only)
reusetypes of SA hierarchy

Definition at line 1904 of file AmrMultiGrid.cpp.

References MueLuBottomSolver< Level >::convertToMueLuReuseOption(), prec_mp, amr::SA, and solver_mp.

Referenced by AmrMultiGrid().

Here is the call graph for this function:

◆ initCrseFineInterp_m()

void AmrMultiGrid::initCrseFineInterp_m ( const Interpolater interface)
private

Instantiate interface interpolater

Parameters
interfacehandler

Definition at line 1885 of file AmrMultiGrid.cpp.

References interface_mp.

Referenced by AmrMultiGrid().

◆ initGuess_m()

void AmrMultiGrid::initGuess_m ( bool  reset)
private

Reset potential to zero (currently)

Parameters
resetsolution to initial guess (zero)

Definition at line 326 of file AmrMultiGrid.cpp.

References mglevel_m, and nlevel_m.

Referenced by solve().

◆ initInterpolater_m()

void AmrMultiGrid::initInterpolater_m ( const Interpolater interp)
private

Instantiate interpolater

Parameters
interpinterpolater type

Definition at line 1867 of file AmrMultiGrid.cpp.

References interp_mp.

Referenced by AmrMultiGrid().

◆ initLevels_m()

void AmrMultiGrid::initLevels_m ( const amrex::Vector< AmrField_u > &  rho,
const amrex::Vector< AmrGeometry_t > &  geom,
bool  regrid 
)
private

Instantiate all levels and set boundary conditions

Parameters
rhois the charge density
geomis the geometry
regridwas performed

Definition at line 227 of file AmrMultiGrid.cpp.

References bc_m, comm_mp, AmrBoxLib::getMeshScaling(), AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp, lbase_m, mglevel_m, and nlevel_m.

Referenced by solve().

Here is the call graph for this function:

◆ initPhysicalBoundary_m()

void AmrMultiGrid::initPhysicalBoundary_m ( const Boundary bc)
private

Instantiate boundary object

Parameters
bcboundary conditions @precondition length must be equal to AMREX_SPACEDIM

Definition at line 199 of file AmrMultiGrid.cpp.

References bc_m, and nBcPoints_m.

Referenced by AmrMultiGrid().

◆ initPrec_m()

void AmrMultiGrid::initPrec_m ( const Preconditioner prec,
const std::string &  reuse 
)
private

Instantiate a preconditioner for the bottom solver

Parameters
precondtype
reusetypes of SA hierarchy

Definition at line 1978 of file AmrMultiGrid.cpp.

References amr::BLOCK_GS, amr::BLOCK_JACOBI, amr::CHEBYSHEV, MueLuPreconditioner< Level >::convertToMueLuReuseOption(), amr::GS, amr::ILUT, amr::JACOBI, EmissionModelT::NONE, prec_mp, amr::RILUK, and amr::SA.

Referenced by AmrMultiGrid().

Here is the call graph for this function:

◆ initResidual_m()

void AmrMultiGrid::initResidual_m ( std::vector< scalar_t > &  rhsNorms,
std::vector< scalar_t > &  resNorms 
)
private

Initial convergence criteria values.

Parameters
rhsNormsper level of right-hand side (is filled)
resNormsper level of residual (is filled)

Definition at line 623 of file AmrMultiGrid.cpp.

References comm_mp, endl(), evalNorm_m(), mglevel_m, nlevel_m, and residual_m().

Referenced by iterate_m().

Here is the call graph for this function:

◆ isConverged_m()

bool AmrMultiGrid::isConverged_m ( std::vector< scalar_t > &  rhsNorms,
std::vector< scalar_t > &  resNorms 
)
private

Compute norms / level and check convergence

Returns
true if converged

Definition at line 391 of file AmrMultiGrid.cpp.

Referenced by iterate_m().

◆ iterate_m()

AmrMultiGrid::scalar_t AmrMultiGrid::iterate_m ( )
private

Actual solve.

Returns
the the max. residual

Definition at line 336 of file AmrMultiGrid.cpp.

References bIter_m, for_each(), getLevelResidualNorm(), initResidual_m(), isConverged_m(), lfine_m, maxiter_m, mglevel_m, nIter_m, nlevel_m, relax_m(), residual_m(), and solver_mp.

Referenced by solve().

Here is the call graph for this function:

◆ map2vector_m()

void AmrMultiGrid::map2vector_m ( umap_t map,
indices_t indices,
coefficients_t values 
)
inlineprivate

Some indices might occur several times due to boundary conditions, etc. We avoid this by filling a map and then copying the data to a vector for filling the matrices. The map gets cleared inside the function.

Parameters
indicesin matrix
valuesare the coefficients

Definition at line 1725 of file AmrMultiGrid.cpp.

References for_each().

Referenced by buildGradientMatrix_m().

Here is the call graph for this function:

◆ open_m()

void AmrMultiGrid::open_m ( const lo_t level,
const bool &  matrices 
)
private

Set matrix and vector pointer

Parameters
levelfor which we fill matrix + vector
matricesif we need to set matrices as well or only vectors.

Definition at line 876 of file AmrMultiGrid.cpp.

References interface_mp, interp_mp, lbase_m, lfine_m, mglevel_m, nBcPoints_m, and solver_mp.

Referenced by buildMultiLevel_m(), and buildSingleLevel_m().

◆ print()

Inform & AmrMultiGrid::print ( Inform os) const

Print information abour tolerances.

Parameters
osoutput stream where to write to

Definition at line 2266 of file AmrMultiGrid.cpp.

References endl().

Here is the call graph for this function:

◆ prolongate_m()

void AmrMultiGrid::prolongate_m ( const lo_t level)
private

Update error of fine level based on error of coarse level

Parameters
levelto update

Definition at line 1827 of file AmrMultiGrid.cpp.

References mglevel_m, IpplTimings::startTimer(), and IpplTimings::stopTimer().

Referenced by relax_m().

Here is the call graph for this function:

◆ relax_m()

void AmrMultiGrid::relax_m ( const lo_t level)
private

Recursive call.

Parameters
levelto relax

Definition at line 463 of file AmrMultiGrid.cpp.

References lbase_m, lfine_m, mglevel_m, prolongate_m(), residual_no_fine_m(), restrict_m(), smooth_m(), solver_mp, IpplTimings::startTimer(), and IpplTimings::stopTimer().

Referenced by iterate_m().

Here is the call graph for this function:

◆ residual_m()

void AmrMultiGrid::residual_m ( const lo_t level,
Teuchos::RCP< vector_t > &  r,
const Teuchos::RCP< vector_t > &  b,
const Teuchos::RCP< vector_t > &  x 
)
private

Compute composite residual of a level

Parameters
ris the residual to compute
bis the right-hand side
xis the left-hand side
levelto solve for

Definition at line 400 of file AmrMultiGrid.cpp.

References lfine_m, and mglevel_m.

Referenced by initResidual_m(), and iterate_m().

◆ residual_no_fine_m()

void AmrMultiGrid::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 
)
private

Compute the residual of a level without considering refined level.

Parameters
resultis computed
rhsis the right-hand side
crs_rhsis the coarse right-hand side for internal boundary
bis the left-hand side
levelto solver for

Definition at line 550 of file AmrMultiGrid.cpp.

References mglevel_m.

Referenced by relax_m(), and restrict_m().

◆ restrict_m()

void AmrMultiGrid::restrict_m ( const lo_t level)
private

Restrict coarse level residual based on fine level residual

Parameters
levelto restrict

Definition at line 1770 of file AmrMultiGrid.cpp.

References mglevel_m, residual_no_fine_m(), IpplTimings::startTimer(), and IpplTimings::stopTimer().

Referenced by relax_m().

Here is the call graph for this function:

◆ setMaxNumberOfIterations()

void AmrMultiGrid::setMaxNumberOfIterations ( const std::size_t &  maxiter)

Specify the maximum number of iterations

Parameters
maxiter\( [0, \infty[ \)

Definition at line 170 of file AmrMultiGrid.cpp.

References maxiter_m.

◆ setNumberOfSweeps()

void AmrMultiGrid::setNumberOfSweeps ( const std::size_t &  nSweeps)

Specify the number of smoothing steps

Parameters
nSweepsfor each smoothing step

Definition at line 165 of file AmrMultiGrid.cpp.

References nSweeps_m.

◆ setTolerance()

void AmrMultiGrid::setTolerance ( const scalar_t eps)

Change accuracy of solver

Definition at line 194 of file AmrMultiGrid.cpp.

References eps_m.

◆ setup_m()

void AmrMultiGrid::setup_m ( const amrex::Vector< AmrField_u > &  rho,
const amrex::Vector< AmrField_u > &  phi,
const bool &  matrices = true 
)
private

Build all matrices and vectors, i.e. AMReX to Trilinos

Parameters
matricesif we need to build matrices as well or only vectors.

Definition at line 688 of file AmrMultiGrid.cpp.

References buildMultiLevel_m(), buildSingleLevel_m(), clearMasks_m(), lbase_m, lfine_m, mglevel_m, solver_mp, and IpplTimings::startTimer().

Referenced by solve().

Here is the call graph for this function:

◆ setVerbose()

void AmrMultiGrid::setVerbose ( bool  verbose)

Enable solver info dumping into SDDS file

Definition at line 189 of file AmrMultiGrid.cpp.

References verbose_m.

◆ smooth_m()

void AmrMultiGrid::smooth_m ( const lo_t level,
Teuchos::RCP< vector_t > &  e,
Teuchos::RCP< vector_t > &  r 
)
private

Perform one smoothing step

Parameters
eerror to update (left-hand side)
rresidual (right-hand side)
levelon which to relax

Definition at line 1753 of file AmrMultiGrid.cpp.

References Physics::e, smoother_m, IpplTimings::startTimer(), and IpplTimings::stopTimer().

Referenced by relax_m().

Here is the call graph for this function:

◆ solve()

void AmrMultiGrid::solve ( AmrScalarFieldContainer_t rho,
AmrScalarFieldContainer_t phi,
AmrVectorFieldContainer_t efield,
unsigned short  baseLevel,
unsigned short  finestLevel,
bool  prevAsGuess = true 
)
virtual

Used in OPAL

Parameters
rhoright-hand side charge density on grid [C / m]
phielectrostatic potential (unknown) [V]
efieldelectric field [V / m]
baseLevelfor solve
finestLevelfor solve
prevAsGuessuse of previous solution as initial guess

Reimplemented from PoissonSolver.

Definition at line 110 of file AmrMultiGrid.cpp.

References averageDown_m(), computeEfield_m(), initGuess_m(), initLevels_m(), iterate_m(), AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp, lbase_m, lfine_m, mglevel_m, nlevel_m, AmrPoissonSolver< AmrBoxLib >::regrid_m, setup_m(), trilinos2amrex_m(), verbose_m, and writeSDDSData_m().

Here is the call graph for this function:

◆ trilinos2amrex_m()

void AmrMultiGrid::trilinos2amrex_m ( const lo_t level,
const lo_t comp,
AmrField_t mf,
const Teuchos::RCP< vector_t > &  mv 
)
private

Data transfer from Trilinos to AMReX.

Parameters
levelto copy
compcomponent to copy
mfis the multifab to be filled
mvis the corresponding Trilinos vector

Definition at line 1690 of file AmrMultiGrid.cpp.

References mglevel_m.

Referenced by computeEfield_m(), and solve().

◆ writeSDDSData_m()

void AmrMultiGrid::writeSDDSData_m ( const scalar_t error)
private

SDDS data write (done by root core)

Parameters
errorto write

Definition at line 2192 of file AmrMultiGrid.cpp.

References bIter_m, comm_mp, flag_m, fname_m, AmrBoxLib::getT(), AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp, nIter_m, AmrPoissonSolver< AmrBoxLib >::regrid_m, IpplTimings::startTimer(), IpplTimings::stopTimer(), and writeSDDSHeader_m().

Referenced by solve().

Here is the call graph for this function:

◆ writeSDDSHeader_m()

void AmrMultiGrid::writeSDDSHeader_m ( std::ofstream &  outfile)
private

SDDS header is written by root core

Parameters
outfileoutput stream

Definition at line 2123 of file AmrMultiGrid.cpp.

References comm_mp, OPALTimer::Timer::date(), endl(), Util::getGitRevision(), OpalData::getInputFn(), OpalData::getInstance(), OpalData::isInOPALCyclMode(), OpalData::isInOPALTMode(), OPAL_PROJECT_NAME, OPAL_PROJECT_VERSION, snorm_m, and OPALTimer::Timer::time().

Referenced by writeSDDSData_m().

Here is the call graph for this function:

Member Data Documentation

◆ bc_m

boundary_t AmrMultiGrid::bc_m[AMREX_SPACEDIM]
private

boundary conditions

Definition at line 693 of file AmrMultiGrid.h.

Referenced by initLevels_m(), and initPhysicalBoundary_m().

◆ bIter_m

std::size_t AmrMultiGrid::bIter_m
private

number of iterations of bottom solver

Definition at line 672 of file AmrMultiGrid.h.

Referenced by iterate_m(), and writeSDDSData_m().

◆ comm_mp

Teuchos::RCP<comm_t> AmrMultiGrid::comm_mp
private

communicator

Definition at line 663 of file AmrMultiGrid.h.

Referenced by initLevels_m(), initResidual_m(), writeSDDSData_m(), and writeSDDSHeader_m().

◆ eps_m

scalar_t AmrMultiGrid::eps_m
private

rhs scale for convergence

Definition at line 699 of file AmrMultiGrid.h.

Referenced by setTolerance().

◆ flag_m

std::ios_base::openmode AmrMultiGrid::flag_m
private

std::ios::out or std::ios::app

Definition at line 703 of file AmrMultiGrid.h.

Referenced by AmrMultiGrid(), and writeSDDSData_m().

◆ fname_m

std::string AmrMultiGrid::fname_m
private

SDDS filename.

Definition at line 702 of file AmrMultiGrid.h.

Referenced by AmrMultiGrid(), and writeSDDSData_m().

◆ interface_mp

std::unique_ptr<AmrInterpolater<AmrMultiGridLevel_t> > AmrMultiGrid::interface_mp
private

◆ interp_mp

std::unique_ptr<AmrInterpolater<AmrMultiGridLevel_t> > AmrMultiGrid::interp_mp
private

interpolater without coarse-fine interface

Definition at line 666 of file AmrMultiGrid.h.

Referenced by buildInterpolationMatrix_m(), initInterpolater_m(), and open_m().

◆ lbase_m

int AmrMultiGrid::lbase_m
private

◆ lfine_m

int AmrMultiGrid::lfine_m
private

◆ maxiter_m

std::size_t AmrMultiGrid::maxiter_m
private

maximum number of iterations allowed

Definition at line 673 of file AmrMultiGrid.h.

Referenced by iterate_m(), and setMaxNumberOfIterations().

◆ mglevel_m

std::vector<std::unique_ptr<AmrMultiGridLevel_t > > AmrMultiGrid::mglevel_m
private

◆ nBcPoints_m

int AmrMultiGrid::nBcPoints_m
private

maximum number of stencils points for BC

Definition at line 694 of file AmrMultiGrid.h.

Referenced by initPhysicalBoundary_m(), and open_m().

◆ nIter_m

std::size_t AmrMultiGrid::nIter_m
private

number of iterations till convergence

Definition at line 671 of file AmrMultiGrid.h.

Referenced by getNumIters(), iterate_m(), and writeSDDSData_m().

◆ nlevel_m

int AmrMultiGrid::nlevel_m
private

◆ norm_m

Norm AmrMultiGrid::norm_m
private

norm for convergence criteria (l1, l2, linf)

Definition at line 696 of file AmrMultiGrid.h.

Referenced by AmrMultiGrid(), and evalNorm_m().

◆ nSweeps_m

std::size_t AmrMultiGrid::nSweeps_m
private

number of smoothing iterations

Definition at line 674 of file AmrMultiGrid.h.

Referenced by buildMultiLevel_m(), and setNumberOfSweeps().

◆ prec_mp

std::shared_ptr<preconditioner_t> AmrMultiGrid::prec_mp
private

preconditioner for bottom solver

Definition at line 687 of file AmrMultiGrid.h.

Referenced by initBaseSolver_m(), and initPrec_m().

◆ smoother_m

std::vector<std::shared_ptr<AmrSmoother> > AmrMultiGrid::smoother_m
private

error smoother

Definition at line 684 of file AmrMultiGrid.h.

Referenced by buildMultiLevel_m(), and smooth_m().

◆ smootherType_m

Smoother AmrMultiGrid::smootherType_m
private

type of smoother

Definition at line 675 of file AmrMultiGrid.h.

Referenced by AmrMultiGrid(), and buildMultiLevel_m().

◆ snorm_m

std::string AmrMultiGrid::snorm_m
private

norm for convergence criteria

Definition at line 697 of file AmrMultiGrid.h.

Referenced by writeSDDSHeader_m().

◆ solver_mp

std::shared_ptr<bsolver_t> AmrMultiGrid::solver_mp
private

◆ verbose_m

bool AmrMultiGrid::verbose_m
private

If true, a SDDS file is written.

Definition at line 701 of file AmrMultiGrid.h.

Referenced by setVerbose(), and solve().


The documentation for this class was generated from the following files: