Block-Structured AMR Software Framework
amrex::MLMG Class Reference

#include <AMReX_MLMG.H>

Public Types

enum class  CFStrategy : int { none , ghostnodes }
 
using BCMode = MLLinOp::BCMode
 
using Location = MLLinOp::Location
 
using BottomSolver = amrex::BottomSolver
 

Public Member Functions

 MLMG (MLLinOp &a_lp)
 
 ~MLMG ()
 
Real solve (const Vector< MultiFab * > &a_sol, const Vector< MultiFab const * > &a_rhs, Real a_tol_rel, Real a_tol_abs, const char *checkpoint_file=nullptr)
 
Real solve (Vector< Any > &a_sol, const Vector< Any > &a_rhs, Real a_tol_rel, Real a_tol_abs, const char *checkpoint_file=nullptr)
 
void getGradSolution (const Vector< Array< MultiFab *, AMREX_SPACEDIM > > &a_grad_sol, Location a_loc=Location::FaceCenter)
 
void getFluxes (const Vector< Array< MultiFab *, AMREX_SPACEDIM > > &a_flux, Location a_loc=Location::FaceCenter)
 For (alpha * a - beta * (del dot b grad)) phi = rhs, flux means -b grad phi More...
 
void getFluxes (const Vector< Array< MultiFab *, AMREX_SPACEDIM > > &a_flux, const Vector< MultiFab * > &a_sol, Location a_loc=Location::FaceCenter)
 
void getFluxes (const Vector< MultiFab * > &a_flux, Location a_loc=Location::CellCenter)
 
void getFluxes (const Vector< MultiFab * > &a_flux, const Vector< MultiFab * > &a_sol, Location a_loc=Location::CellCenter)
 
void compResidual (const Vector< MultiFab * > &a_res, const Vector< MultiFab * > &a_sol, const Vector< MultiFab const * > &a_rhs)
 
void apply (const Vector< MultiFab * > &out, const Vector< MultiFab * > &in)
 out = L(in). Note that, if no actual solve is needed, one could turn off multigrid coarsening by constructing a MLLinOp object with an appropriate LPInfo object (e.g., with LPInfo().setMaxCoarseningLevel(0)). More...
 
void setVerbose (int v) noexcept
 
void setMaxIter (int n) noexcept
 
void setMaxFmgIter (int n) noexcept
 
void setFixedIter (int nit) noexcept
 
void setPreSmooth (int n) noexcept
 
void setPostSmooth (int n) noexcept
 
void setFinalSmooth (int n) noexcept
 
void setBottomSmooth (int n) noexcept
 
void setBottomSolver (BottomSolver s) noexcept
 
void setCFStrategy (CFStrategy a_cf_strategy) noexcept
 
void setBottomVerbose (int v) noexcept
 
void setBottomMaxIter (int n) noexcept
 
void setBottomTolerance (Real t) noexcept
 
void setBottomToleranceAbs (Real t) noexcept
 
Real getBottomToleranceAbs () noexcept
 
void setAlwaysUseBNorm (int flag) noexcept
 
void setFinalFillBC (int flag) noexcept
 
int numAMRLevels () const noexcept
 
void setNSolve (int flag) noexcept
 
void setNSolveGridSize (int s) noexcept
 
void prepareForSolve (Vector< Any > &a_sol, const Vector< Any > &a_rhs)
 
void prepareForNSolve ()
 
void oneIter (int iter)
 
void miniCycle (int alev)
 
void mgVcycle (int amrlev, int mglev)
 
void mgFcycle ()
 
void bottomSolve ()
 
void NSolve (MLMG &a_solver, MultiFab &a_sol, MultiFab &a_rhs)
 
void actualBottomSolve ()
 
void computeMLResidual (int amrlevmax)
 
void computeResidual (int alev)
 
void computeResWithCrseSolFineCor (int crse_amr_lev, int fine_amr_lev)
 
void computeResWithCrseCorFineCor (int fine_amr_lev)
 
void interpCorrection (int alev)
 
void interpCorrection (int alev, int mglev)
 
void addInterpCorrection (int alev, int mglev)
 
void computeResOfCorrection (int amrlev, int mglev)
 
Real ResNormInf (int amrlev, bool local=false)
 
Real MLResNormInf (int alevmax, bool local=false)
 
Real MLRhsNormInf (bool local=false)
 
void buildFineMask ()
 
void makeSolvable ()
 
void makeSolvable (int amrlev, int mglev, Any &mf)
 
void bottomSolveWithPETSc (Any &x, const Any &b)
 
int bottomSolveWithCG (Any &x, const Any &b, MLCGSolver::Type type)
 
Real getInitRHS () const noexcept
 
Real getInitResidual () const noexcept
 
Real getFinalResidual () const noexcept
 
Vector< Real > const & getResidualHistory () const noexcept
 
int getNumIters () const noexcept
 
Vector< int > const & getNumCGIters () const noexcept
 

Private Types

enum  timer_types { solve_time =0 , iter_time , bottom_time , ntimers }
 

Private Member Functions

void checkPoint (const Vector< MultiFab * > &a_sol, const Vector< MultiFab const * > &a_rhs, Real a_tol_rel, Real a_tol_abs, const char *a_file_name) const
 

Private Attributes

int verbose = 1
 
int max_iters = 200
 
int do_fixed_number_of_iters = 0
 
int nu1 = 2
 pre More...
 
int nu2 = 2
 post More...
 
int nuf = 8
 when smoother is used as bottom solver More...
 
int nub = 0
 additional smoothing after bottom cg solver More...
 
int max_fmg_iters = 0
 
BottomSolver bottom_solver = BottomSolver::Default
 
CFStrategy cf_strategy = CFStrategy::none
 
int bottom_verbose = 0
 
int bottom_maxiter = 200
 
Real bottom_reltol = Real(1.e-4)
 
Real bottom_abstol = Real(-1.0)
 
int always_use_bnorm = 0
 
int final_fill_bc = 0
 
MLLinOplinop
 
int namrlevs
 
int finest_amr_lev
 
bool linop_prepared = false
 
Long solve_called = 0
 
int do_nsolve = false
 N Solve. More...
 
int nsolve_grid_size = 16
 
std::unique_ptr< MLLinOpns_linop
 
std::unique_ptr< MLMGns_mlmg
 
std::unique_ptr< MultiFabns_sol
 
std::unique_ptr< MultiFabns_rhs
 
Vector< Anysol
 Hypre. More...
 
Vector< Anyrhs
 
Vector< intsol_is_alias
 
Vector< Vector< Any > > res
 First Vector: Amr levels. 0 is the coarest level Second Vector: MG levels. 0 is the finest level. More...
 
Vector< Vector< Any > > cor
 = rhs - L(sol) More...
 
Vector< Vector< Any > > cor_hold
 
Vector< Vector< Any > > rescor
 
Vector< double > timer
 
Real m_rhsnorm0 = -1.0
 
Real m_init_resnorm0 = -1.0
 
Real m_final_resnorm0 = -1.0
 
Vector< intm_niters_cg
 
Vector< Real > m_iter_fine_resnorm0
 

Friends

class MLCGSolver
 

Member Typedef Documentation

◆ BCMode

◆ BottomSolver

◆ Location

Member Enumeration Documentation

◆ CFStrategy

Enumerator
none 
ghostnodes 

◆ timer_types

Enumerator
solve_time 
iter_time 
bottom_time 
ntimers 

Constructor & Destructor Documentation

◆ MLMG()

amrex::MLMG::MLMG ( MLLinOp a_lp)

◆ ~MLMG()

amrex::MLMG::~MLMG ( )

Member Function Documentation

◆ actualBottomSolve()

void amrex::MLMG::actualBottomSolve ( )

◆ addInterpCorrection()

void amrex::MLMG::addInterpCorrection ( int  alev,
int  mglev 
)

◆ apply()

void amrex::MLMG::apply ( const Vector< MultiFab * > &  out,
const Vector< MultiFab * > &  in 
)

out = L(in). Note that, if no actual solve is needed, one could turn off multigrid coarsening by constructing a MLLinOp object with an appropriate LPInfo object (e.g., with LPInfo().setMaxCoarseningLevel(0)).

Parameters
out
in

◆ bottomSolve()

void amrex::MLMG::bottomSolve ( )

◆ bottomSolveWithCG()

int amrex::MLMG::bottomSolveWithCG ( Any x,
const Any b,
MLCGSolver::Type  type 
)

◆ bottomSolveWithPETSc()

void amrex::MLMG::bottomSolveWithPETSc ( Any x,
const Any b 
)

◆ buildFineMask()

void amrex::MLMG::buildFineMask ( )

◆ checkPoint()

void amrex::MLMG::checkPoint ( const Vector< MultiFab * > &  a_sol,
const Vector< MultiFab const * > &  a_rhs,
Real  a_tol_rel,
Real  a_tol_abs,
const char *  a_file_name 
) const
private

◆ compResidual()

void amrex::MLMG::compResidual ( const Vector< MultiFab * > &  a_res,
const Vector< MultiFab * > &  a_sol,
const Vector< MultiFab const * > &  a_rhs 
)

◆ computeMLResidual()

void amrex::MLMG::computeMLResidual ( int  amrlevmax)

◆ computeResidual()

void amrex::MLMG::computeResidual ( int  alev)

◆ computeResOfCorrection()

void amrex::MLMG::computeResOfCorrection ( int  amrlev,
int  mglev 
)

◆ computeResWithCrseCorFineCor()

void amrex::MLMG::computeResWithCrseCorFineCor ( int  fine_amr_lev)

◆ computeResWithCrseSolFineCor()

void amrex::MLMG::computeResWithCrseSolFineCor ( int  crse_amr_lev,
int  fine_amr_lev 
)

◆ getBottomToleranceAbs()

Real amrex::MLMG::getBottomToleranceAbs ( )
inlinenoexcept

◆ getFinalResidual()

Real amrex::MLMG::getFinalResidual ( ) const
inlinenoexcept

◆ getFluxes() [1/4]

void amrex::MLMG::getFluxes ( const Vector< Array< MultiFab *, AMREX_SPACEDIM > > &  a_flux,
const Vector< MultiFab * > &  a_sol,
Location  a_loc = Location::FaceCenter 
)

◆ getFluxes() [2/4]

void amrex::MLMG::getFluxes ( const Vector< Array< MultiFab *, AMREX_SPACEDIM > > &  a_flux,
Location  a_loc = Location::FaceCenter 
)

For (alpha * a - beta * (del dot b grad)) phi = rhs, flux means -b grad phi

Parameters
a_flux
a_loc

◆ getFluxes() [3/4]

void amrex::MLMG::getFluxes ( const Vector< MultiFab * > &  a_flux,
const Vector< MultiFab * > &  a_sol,
Location  a_loc = Location::CellCenter 
)

◆ getFluxes() [4/4]

void amrex::MLMG::getFluxes ( const Vector< MultiFab * > &  a_flux,
Location  a_loc = Location::CellCenter 
)

◆ getGradSolution()

void amrex::MLMG::getGradSolution ( const Vector< Array< MultiFab *, AMREX_SPACEDIM > > &  a_grad_sol,
Location  a_loc = Location::FaceCenter 
)

◆ getInitResidual()

Real amrex::MLMG::getInitResidual ( ) const
inlinenoexcept

◆ getInitRHS()

Real amrex::MLMG::getInitRHS ( ) const
inlinenoexcept

◆ getNumCGIters()

Vector<int> const& amrex::MLMG::getNumCGIters ( ) const
inlinenoexcept

◆ getNumIters()

int amrex::MLMG::getNumIters ( ) const
inlinenoexcept

◆ getResidualHistory()

Vector<Real> const& amrex::MLMG::getResidualHistory ( ) const
inlinenoexcept

◆ interpCorrection() [1/2]

void amrex::MLMG::interpCorrection ( int  alev)

◆ interpCorrection() [2/2]

void amrex::MLMG::interpCorrection ( int  alev,
int  mglev 
)

◆ makeSolvable() [1/2]

void amrex::MLMG::makeSolvable ( )

◆ makeSolvable() [2/2]

void amrex::MLMG::makeSolvable ( int  amrlev,
int  mglev,
Any mf 
)

◆ mgFcycle()

void amrex::MLMG::mgFcycle ( )

◆ mgVcycle()

void amrex::MLMG::mgVcycle ( int  amrlev,
int  mglev 
)

◆ miniCycle()

void amrex::MLMG::miniCycle ( int  alev)

◆ MLResNormInf()

Real amrex::MLMG::MLResNormInf ( int  alevmax,
bool  local = false 
)

◆ MLRhsNormInf()

Real amrex::MLMG::MLRhsNormInf ( bool  local = false)

◆ NSolve()

void amrex::MLMG::NSolve ( MLMG a_solver,
MultiFab a_sol,
MultiFab a_rhs 
)

◆ numAMRLevels()

int amrex::MLMG::numAMRLevels ( ) const
inlinenoexcept

◆ oneIter()

void amrex::MLMG::oneIter ( int  iter)

◆ prepareForNSolve()

void amrex::MLMG::prepareForNSolve ( )

◆ prepareForSolve()

void amrex::MLMG::prepareForSolve ( Vector< Any > &  a_sol,
const Vector< Any > &  a_rhs 
)

◆ ResNormInf()

Real amrex::MLMG::ResNormInf ( int  amrlev,
bool  local = false 
)

◆ setAlwaysUseBNorm()

void amrex::MLMG::setAlwaysUseBNorm ( int  flag)
inlinenoexcept

◆ setBottomMaxIter()

void amrex::MLMG::setBottomMaxIter ( int  n)
inlinenoexcept

◆ setBottomSmooth()

void amrex::MLMG::setBottomSmooth ( int  n)
inlinenoexcept

◆ setBottomSolver()

void amrex::MLMG::setBottomSolver ( BottomSolver  s)
inlinenoexcept

◆ setBottomTolerance()

void amrex::MLMG::setBottomTolerance ( Real  t)
inlinenoexcept

◆ setBottomToleranceAbs()

void amrex::MLMG::setBottomToleranceAbs ( Real  t)
inlinenoexcept

◆ setBottomVerbose()

void amrex::MLMG::setBottomVerbose ( int  v)
inlinenoexcept

◆ setCFStrategy()

void amrex::MLMG::setCFStrategy ( CFStrategy  a_cf_strategy)
inlinenoexcept

◆ setFinalFillBC()

void amrex::MLMG::setFinalFillBC ( int  flag)
inlinenoexcept

◆ setFinalSmooth()

void amrex::MLMG::setFinalSmooth ( int  n)
inlinenoexcept

◆ setFixedIter()

void amrex::MLMG::setFixedIter ( int  nit)
inlinenoexcept

◆ setMaxFmgIter()

void amrex::MLMG::setMaxFmgIter ( int  n)
inlinenoexcept

◆ setMaxIter()

void amrex::MLMG::setMaxIter ( int  n)
inlinenoexcept

◆ setNSolve()

void amrex::MLMG::setNSolve ( int  flag)
inlinenoexcept

◆ setNSolveGridSize()

void amrex::MLMG::setNSolveGridSize ( int  s)
inlinenoexcept

◆ setPostSmooth()

void amrex::MLMG::setPostSmooth ( int  n)
inlinenoexcept

◆ setPreSmooth()

void amrex::MLMG::setPreSmooth ( int  n)
inlinenoexcept

◆ setVerbose()

void amrex::MLMG::setVerbose ( int  v)
inlinenoexcept

◆ solve() [1/2]

Real amrex::MLMG::solve ( const Vector< MultiFab * > &  a_sol,
const Vector< MultiFab const * > &  a_rhs,
Real  a_tol_rel,
Real  a_tol_abs,
const char *  checkpoint_file = nullptr 
)

◆ solve() [2/2]

Real amrex::MLMG::solve ( Vector< Any > &  a_sol,
const Vector< Any > &  a_rhs,
Real  a_tol_rel,
Real  a_tol_abs,
const char *  checkpoint_file = nullptr 
)

Friends And Related Function Documentation

◆ MLCGSolver

friend class MLCGSolver
friend

Member Data Documentation

◆ always_use_bnorm

int amrex::MLMG::always_use_bnorm = 0
private

◆ bottom_abstol

Real amrex::MLMG::bottom_abstol = Real(-1.0)
private

◆ bottom_maxiter

int amrex::MLMG::bottom_maxiter = 200
private

◆ bottom_reltol

Real amrex::MLMG::bottom_reltol = Real(1.e-4)
private

◆ bottom_solver

BottomSolver amrex::MLMG::bottom_solver = BottomSolver::Default
private

◆ bottom_verbose

int amrex::MLMG::bottom_verbose = 0
private

◆ cf_strategy

CFStrategy amrex::MLMG::cf_strategy = CFStrategy::none
private

◆ cor

Vector<Vector<Any> > amrex::MLMG::cor
private

= rhs - L(sol)

L(cor) = res

◆ cor_hold

Vector<Vector<Any> > amrex::MLMG::cor_hold
private

◆ do_fixed_number_of_iters

int amrex::MLMG::do_fixed_number_of_iters = 0
private

◆ do_nsolve

int amrex::MLMG::do_nsolve = false
private

N Solve.

◆ final_fill_bc

int amrex::MLMG::final_fill_bc = 0
private

◆ finest_amr_lev

int amrex::MLMG::finest_amr_lev
private

◆ linop

MLLinOp& amrex::MLMG::linop
private

◆ linop_prepared

bool amrex::MLMG::linop_prepared = false
private

◆ m_final_resnorm0

Real amrex::MLMG::m_final_resnorm0 = -1.0
private

◆ m_init_resnorm0

Real amrex::MLMG::m_init_resnorm0 = -1.0
private

◆ m_iter_fine_resnorm0

Vector<Real> amrex::MLMG::m_iter_fine_resnorm0
private

◆ m_niters_cg

Vector<int> amrex::MLMG::m_niters_cg
private

◆ m_rhsnorm0

Real amrex::MLMG::m_rhsnorm0 = -1.0
private

◆ max_fmg_iters

int amrex::MLMG::max_fmg_iters = 0
private

◆ max_iters

int amrex::MLMG::max_iters = 200
private

◆ namrlevs

int amrex::MLMG::namrlevs
private

◆ ns_linop

std::unique_ptr<MLLinOp> amrex::MLMG::ns_linop
private

◆ ns_mlmg

std::unique_ptr<MLMG> amrex::MLMG::ns_mlmg
private

◆ ns_rhs

std::unique_ptr<MultiFab> amrex::MLMG::ns_rhs
private

◆ ns_sol

std::unique_ptr<MultiFab> amrex::MLMG::ns_sol
private

◆ nsolve_grid_size

int amrex::MLMG::nsolve_grid_size = 16
private

◆ nu1

int amrex::MLMG::nu1 = 2
private

pre

◆ nu2

int amrex::MLMG::nu2 = 2
private

post

◆ nub

int amrex::MLMG::nub = 0
private

additional smoothing after bottom cg solver

◆ nuf

int amrex::MLMG::nuf = 8
private

when smoother is used as bottom solver

◆ res

Vector<Vector<Any> > amrex::MLMG::res
private

First Vector: Amr levels. 0 is the coarest level Second Vector: MG levels. 0 is the finest level.

◆ rescor

Vector<Vector<Any> > amrex::MLMG::rescor
private

= res - L(cor) Residual of the correction form

◆ rhs

Vector<Any> amrex::MLMG::rhs
private

Copy of original rhs L(sol) = rhs

◆ sol

Vector<Any> amrex::MLMG::sol
private

Hypre.

PETSc

To avoid confusion, terms like sol, cor, rhs, res, ... etc. are in the frame of the original equation, not the correction form Might be alias to argument a_sol

◆ sol_is_alias

Vector<int> amrex::MLMG::sol_is_alias
private

◆ solve_called

Long amrex::MLMG::solve_called = 0
private

◆ timer

Vector<double> amrex::MLMG::timer
private

◆ verbose

int amrex::MLMG::verbose = 1
private

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