OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
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_t
AmrMultiGridLevel_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_t
bsolver_t
 
typedef BelosBottomSolver
< AmrMultiGridLevel_t
BelosSolver_t
 
typedef Amesos2BottomSolver
< AmrMultiGridLevel_t
Amesos2Solver_t
 
typedef MueLuBottomSolver
< AmrMultiGridLevel_t
MueLuSolver_t
 
typedef AmrPreconditioner
< matrix_t,
AmrMultiGridLevel_t
preconditioner_t
 
typedef Ifpack2Preconditioner
< AmrMultiGridLevel_t
Ifpack2Preconditioner_t
 
typedef MueLuPreconditioner
< AmrMultiGridLevel_t
MueLuPreconditioner_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)
 
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 &rho, Vector_t hr)
 
void computePotential (Field_t &rho, Vector_t hr, double zshift)
 
void test (PartBunchBase< double, 3 > *bunch)
 
void hasToRegrid ()
 
- Public Member Functions inherited from PoissonSolver
virtual ~PoissonSolver ()
 

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 basefab_t &cfab, 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, const basefab_t &cfab)
 
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 bool &rebalance, 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...
 
Teuchos::RCP< amr::node_tnode_mp
 kokkos node 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...
 
const 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 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 23 of file AmrMultiGrid.h.

Member Typedef Documentation

Definition at line 54 of file AmrMultiGrid.h.

Definition at line 40 of file AmrMultiGrid.h.

Definition at line 37 of file AmrMultiGrid.h.

Definition at line 39 of file AmrMultiGrid.h.

Definition at line 38 of file AmrMultiGrid.h.

Definition at line 41 of file AmrMultiGrid.h.

Definition at line 35 of file AmrMultiGrid.h.

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

Definition at line 64 of file AmrMultiGrid.h.

Definition at line 53 of file AmrMultiGrid.h.

Definition at line 45 of file AmrMultiGrid.h.

typedef amrex::Box AmrMultiGrid::box_t

Definition at line 63 of file AmrMultiGrid.h.

typedef amrex::BoxArray AmrMultiGrid::boxarray_t

Definition at line 62 of file AmrMultiGrid.h.

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

Definition at line 51 of file AmrMultiGrid.h.

Definition at line 43 of file AmrMultiGrid.h.

Definition at line 30 of file AmrMultiGrid.h.

Definition at line 29 of file AmrMultiGrid.h.

typedef amrex::FArrayBox AmrMultiGrid::farraybox_t

Definition at line 65 of file AmrMultiGrid.h.

Definition at line 32 of file AmrMultiGrid.h.

Definition at line 59 of file AmrMultiGrid.h.

Definition at line 42 of file AmrMultiGrid.h.

Definition at line 31 of file AmrMultiGrid.h.

Definition at line 26 of file AmrMultiGrid.h.

Definition at line 60 of file AmrMultiGrid.h.

Definition at line 55 of file AmrMultiGrid.h.

Definition at line 28 of file AmrMultiGrid.h.

Definition at line 69 of file AmrMultiGrid.h.

Definition at line 57 of file AmrMultiGrid.h.

Definition at line 33 of file AmrMultiGrid.h.

Definition at line 67 of file AmrMultiGrid.h.

Definition at line 44 of file AmrMultiGrid.h.

Definition at line 27 of file AmrMultiGrid.h.

Member Enumeration Documentation

Supported bottom solvers.

Enumerator
BICGSTAB 
MINRES 
PCPG 
CG 
GMRES 
STOCHASTIC_CG 
RECYCLING_CG 
RECYCLING_GMRES 
SA 

Definition at line 79 of file AmrMultiGrid.h.

Supported physical boundaries.

Enumerator
DIRICHLET 
OPEN 
PERIODIC 

Definition at line 114 of file AmrMultiGrid.h.

Supported interpolaters for prolongation operation.

Enumerator
TRILINEAR 
LAGRANGE 
PIECEWISE_CONST 

Definition at line 72 of file AmrMultiGrid.h.

Supported convergence criteria.

Enumerator
L1 
L2 
LINF 

Definition at line 121 of file AmrMultiGrid.h.

Constructor & Destructor Documentation

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 21 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(), node_mp, norm_m, and smootherType_m.

Here is the call graph for this function:

Member Function Documentation

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 1639 of file AmrMultiGrid.cpp.

References mglevel_m.

Referenced by buildDensityVector_m(), and buildPotentialVector_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 1827 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:

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 basefab_t cfab,
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 1091 of file AmrMultiGrid.cpp.

References interface_mp, lbase_m, map2vector_m(), and mglevel_m.

Referenced by buildMultiLevel_m().

Here is the call graph for this function:

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 1339 of file AmrMultiGrid.cpp.

References interface_mp, lbase_m, map2vector_m(), and mglevel_m.

Referenced by buildMultiLevel_m().

Here is the call graph for this function:

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 1547 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:

void AmrMultiGrid::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 
)
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
ivis the current cell
cellsall coarse cells that are at the crse-fine interface but are not refined
crse_fine_bacoarse cells that got refined
levelthe finest level is omitted

Definition at line 1404 of file AmrMultiGrid.cpp.

References interface_mp, lfine_m, map2vector_m(), mglevel_m, AmrMultiGridLevel< MatrixType, VectorType >::PHYSBNDRY, and sign().

Referenced by buildMultiLevel_m().

Here is the call graph for this function:

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 1561 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:

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 1302 of file AmrMultiGrid.cpp.

References interp_mp, lbase_m, map2vector_m(), and mglevel_m.

Referenced by buildMultiLevel_m().

Here is the call graph for this function:

void AmrMultiGrid::buildMultiLevel_m ( const amrex::Vector< AmrField_u > &  rho,
const amrex::Vector< AmrField_u > &  phi,
const bool &  matrices = true 
)
private
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 1010 of file AmrMultiGrid.cpp.

References interface_mp, lbase_m, map2vector_m(), and mglevel_m.

Referenced by buildMultiLevel_m(), and buildSingleLevel_m().

Here is the call graph for this function:

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 1554 of file AmrMultiGrid.cpp.

References amrex2trilinos_m(), and mglevel_m.

Here is the call graph for this function:

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 1250 of file AmrMultiGrid.cpp.

References lfine_m, mglevel_m, and serialize().

Referenced by buildMultiLevel_m().

Here is the call graph for this function:

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 697 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:

void AmrMultiGrid::clearMasks_m ( )
private

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

Definition at line 297 of file AmrMultiGrid.cpp.

References mglevel_m, and nlevel_m.

Referenced by setup_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 972 of file AmrMultiGrid.cpp.

References lbase_m, lfine_m, mglevel_m, and solver_mp.

Referenced by buildMultiLevel_m(), and buildSingleLevel_m().

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

Definition at line 644 of file AmrMultiGrid.cpp.

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

Referenced by solve().

Here is the call graph for this function:

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

Converts string to enum BaseSolver

Parameters
bsolverbottom solver

Definition at line 2025 of file AmrMultiGrid.cpp.

References amr::SA, and Util::toUpper().

Referenced by AmrMultiGrid().

Here is the call graph for this function:

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

Convertstring to enum Boundary

Parameters
bcboundary condition

Definition at line 1992 of file AmrMultiGrid.cpp.

References Util::toUpper().

Referenced by AmrMultiGrid().

Here is the call graph for this function:

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

Converts string to enum Interpolater

Parameters
interpinterpolater

Definition at line 2008 of file AmrMultiGrid.cpp.

References Util::toUpper().

Referenced by AmrMultiGrid().

Here is the call graph for this function:

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

Converts string to enum Norm

Parameters
normeither L1, L2, LInf

Definition at line 2091 of file AmrMultiGrid.cpp.

References Hypervolume::n, snorm_m, and Util::toUpper().

Referenced by AmrMultiGrid().

Here is the call graph for this function:

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

Converts string to enum Preconditioner

Parameters
precpreconditioner

Definition at line 2066 of file AmrMultiGrid.cpp.

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

Referenced by AmrMultiGrid().

Here is the call graph for this function:

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

Converts string to enum Smoother

Parameters
smootherof level solution

Definition at line 2085 of file AmrMultiGrid.cpp.

References AmrSmoother::convertToEnumSmoother().

Referenced by AmrMultiGrid().

Here is the call graph for this function:

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 575 of file AmrMultiGrid.cpp.

References norm_m.

Referenced by getLevelResidualNorm(), and initResidual_m().

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 168 of file AmrMultiGrid.cpp.

References evalNorm_m(), and mglevel_m.

Referenced by iterate_m().

Here is the call graph for this function:

std::size_t AmrMultiGrid::getNumIters ( )

Obtain some convergence info

Returns
the number of iterations till convergence

Definition at line 163 of file AmrMultiGrid.cpp.

References nIter_m.

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

Implements PoissonSolver.

Definition at line 2227 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

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

Implements PoissonSolver.

Definition at line 2222 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

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

Implements PoissonSolver.

Definition at line 2237 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

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

Implements PoissonSolver.

Definition at line 2232 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

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

Implements PoissonSolver.

Definition at line 2247 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

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

Implements PoissonSolver.

Definition at line 2242 of file AmrMultiGrid.cpp.

References AmrPoissonSolver< AmrBoxLib >::itsAmrObject_mp.

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 1887 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:

void AmrMultiGrid::initCrseFineInterp_m ( const Interpolater interface)
private

Instantiate interface interpolater

Parameters
interfacehandler

Definition at line 1868 of file AmrMultiGrid.cpp.

References interface_mp.

Referenced by AmrMultiGrid().

void AmrMultiGrid::initGuess_m ( bool  reset)
private

Reset potential to zero (currently)

Parameters
resetsolution to initial guess (zero)

Definition at line 306 of file AmrMultiGrid.cpp.

References mglevel_m, and nlevel_m.

Referenced by solve().

void AmrMultiGrid::initInterpolater_m ( const Interpolater interp)
private

Instantiate interpolater

Parameters
interpinterpolater type

Definition at line 1850 of file AmrMultiGrid.cpp.

References interp_mp.

Referenced by AmrMultiGrid().

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 206 of file AmrMultiGrid.cpp.

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

Referenced by solve().

Here is the call graph for this function:

void AmrMultiGrid::initPhysicalBoundary_m ( const Boundary bc)
private

Instantiate boundary object

Parameters
bcboundary conditions length must be equal to AMREX_SPACEDIM

Definition at line 178 of file AmrMultiGrid.cpp.

References bc_m, and nBcPoints_m.

Referenced by AmrMultiGrid().

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

Instantiate a preconditioner for the bottom solver

Parameters
precondtype
rebalancepreconditioner (SA only)
reusetypes of SA hierarchy

Definition at line 1961 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:

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 603 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:

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 371 of file AmrMultiGrid.cpp.

Referenced by iterate_m().

AmrMultiGrid::scalar_t AmrMultiGrid::iterate_m ( )
private

Actual solve.

Returns
the the max. residual

Definition at line 316 of file AmrMultiGrid.cpp.

References bIter_m, eps_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:

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 1708 of file AmrMultiGrid.cpp.

References for_each().

Referenced by buildCompositePoissonMatrix_m(), buildCrseBoundaryMatrix_m(), buildFineBoundaryMatrix_m(), buildGradientMatrix_m(), buildInterpolationMatrix_m(), and buildNoFinePoissonMatrix_m().

Here is the call graph for this function:

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 856 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().

Inform & AmrMultiGrid::print ( Inform os) const

Print information abour tolerances.

Parameters
osoutput stream where to write to

Definition at line 2252 of file AmrMultiGrid.cpp.

References endl().

Referenced by operator<<().

Here is the call graph for this function:

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 1810 of file AmrMultiGrid.cpp.

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

Referenced by relax_m().

Here is the call graph for this function:

void AmrMultiGrid::relax_m ( const lo_t level)
private

Recursive call.

Parameters
levelto relax

Definition at line 443 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:

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 380 of file AmrMultiGrid.cpp.

References lfine_m, and mglevel_m.

Referenced by initResidual_m(), and iterate_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 530 of file AmrMultiGrid.cpp.

References mglevel_m.

Referenced by relax_m(), and 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 1753 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:

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

Specify the maximum number of iterations

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

Definition at line 154 of file AmrMultiGrid.cpp.

References maxiter_m.

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

Specify the number of smoothing steps

Parameters
nSweepsfor each smoothing step

Definition at line 145 of file AmrMultiGrid.cpp.

References nSweeps_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 668 of file AmrMultiGrid.cpp.

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

Referenced by solve().

Here is the call graph for this function:

void AmrMultiGrid::setVerbose ( bool  verbose)

Enable solver info dumping into SDDS file

Definition at line 173 of file AmrMultiGrid.cpp.

References verbose_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 1736 of file AmrMultiGrid.cpp.

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

Referenced by relax_m().

Here is the call graph for this function:

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 90 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:

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 1673 of file AmrMultiGrid.cpp.

References mglevel_m.

Referenced by computeEfield_m(), and solve().

void AmrMultiGrid::writeSDDSData_m ( const scalar_t error)
private

SDDS data write (done by root core)

Parameters
errorto write

Definition at line 2178 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:

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

SDDS header is written by root core

Parameters
outfileoutput stream

Definition at line 2109 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

boundary_t AmrMultiGrid::bc_m[AMREX_SPACEDIM]
private

boundary conditions

Definition at line 671 of file AmrMultiGrid.h.

Referenced by initLevels_m(), and initPhysicalBoundary_m().

std::size_t AmrMultiGrid::bIter_m
private

number of iterations of bottom solver

Definition at line 650 of file AmrMultiGrid.h.

Referenced by iterate_m(), and writeSDDSData_m().

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

communicator

Definition at line 640 of file AmrMultiGrid.h.

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

const scalar_t AmrMultiGrid::eps_m
private

rhs scale for convergence

Definition at line 677 of file AmrMultiGrid.h.

Referenced by iterate_m().

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

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

Definition at line 681 of file AmrMultiGrid.h.

Referenced by AmrMultiGrid(), and writeSDDSData_m().

std::string AmrMultiGrid::fname_m
private

SDDS filename.

Definition at line 680 of file AmrMultiGrid.h.

Referenced by AmrMultiGrid(), and writeSDDSData_m().

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

interpolater without coarse-fine interface

Definition at line 644 of file AmrMultiGrid.h.

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

int AmrMultiGrid::lbase_m
private
int AmrMultiGrid::lfine_m
private
std::size_t AmrMultiGrid::maxiter_m
private

maximum number of iterations allowed

Definition at line 651 of file AmrMultiGrid.h.

Referenced by iterate_m(), and setMaxNumberOfIterations().

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

maximum number of stencils points for BC

Definition at line 672 of file AmrMultiGrid.h.

Referenced by initPhysicalBoundary_m(), and open_m().

std::size_t AmrMultiGrid::nIter_m
private

number of iterations till convergence

Definition at line 649 of file AmrMultiGrid.h.

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

int AmrMultiGrid::nlevel_m
private

number of levelss

Definition at line 669 of file AmrMultiGrid.h.

Referenced by buildMultiLevel_m(), clearMasks_m(), initGuess_m(), initLevels_m(), initResidual_m(), iterate_m(), and solve().

Teuchos::RCP<amr::node_t> AmrMultiGrid::node_mp
private

kokkos node

Definition at line 641 of file AmrMultiGrid.h.

Referenced by AmrMultiGrid(), and initLevels_m().

Norm AmrMultiGrid::norm_m
private

norm for convergence criteria (l1, l2, linf)

Definition at line 674 of file AmrMultiGrid.h.

Referenced by AmrMultiGrid(), and evalNorm_m().

std::size_t AmrMultiGrid::nSweeps_m
private

number of smoothing iterations

Definition at line 652 of file AmrMultiGrid.h.

Referenced by buildMultiLevel_m(), and setNumberOfSweeps().

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

preconditioner for bottom solver

Definition at line 665 of file AmrMultiGrid.h.

Referenced by initBaseSolver_m(), and initPrec_m().

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

error smoother

Definition at line 662 of file AmrMultiGrid.h.

Referenced by buildMultiLevel_m(), and smooth_m().

Smoother AmrMultiGrid::smootherType_m
private

type of smoother

Definition at line 653 of file AmrMultiGrid.h.

Referenced by AmrMultiGrid(), and buildMultiLevel_m().

std::string AmrMultiGrid::snorm_m
private

norm for convergence criteria

Definition at line 675 of file AmrMultiGrid.h.

Referenced by convertToEnumNorm_m(), and writeSDDSHeader_m().

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

If true, a SDDS file is written.

Definition at line 679 of file AmrMultiGrid.h.

Referenced by setVerbose(), and solve().


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