#include <MultilevelLinearOp.H>
Public Member Functions | |
MultilevelLinearOp () | |
default constructor (sets defaults for preconditioner) | |
void | define (const Vector< DisjointBoxLayout > &a_vectGrids, const Vector< int > &a_refRatios, const Vector< ProblemDomain > &a_domains, const Vector< RealVect > &a_vectDx, RefCountedPtr< AMRLevelOpFactory< LevelData< T > > > &a_opFactory, int a_lBase) |
define function -- opFactory should be able to define all required levels | |
virtual | ~MultilevelLinearOp () |
virtual void | residual (Vector< LevelData< T > * > &a_lhs, const Vector< LevelData< T > * > &a_phi, const Vector< LevelData< T > * > &a_rhs, bool a_homogeneous=false) |
compute residual using AMRLevelOps AMRResidual functionality | |
virtual void | preCond (Vector< LevelData< T > * > &a_cor, const Vector< LevelData< T > * > &a_residual) |
Apply preconditioner. | |
virtual void | applyOp (Vector< LevelData< T > * > &a_lhs, const Vector< LevelData< T > * > &a_phi, bool a_homogeneous=false) |
virtual void | create (Vector< LevelData< T > * > &a_lhs, const Vector< LevelData< T > * > &a_rhs) |
virtual void | clear (Vector< LevelData< T > * > &a_lhs) |
virtual void | assign (Vector< LevelData< T > * > &a_lhs, const Vector< LevelData< T > * > &a_rhs) |
virtual Real | dotProduct (const Vector< LevelData< T > * > &a_1, const Vector< LevelData< T > * > &a_2) |
virtual void | incr (Vector< LevelData< T > * > &a_lhs, const Vector< LevelData< T > * > &a_x, Real a_scale) |
virtual void | axby (Vector< LevelData< T > * > &a_lhs, const Vector< LevelData< T > * > &a_x, const Vector< LevelData< T > * > &a_y, Real a_a, Real a_b) |
virtual void | scale (Vector< LevelData< T > * > &a_lhs, const Real &a_scale) |
virtual Real | norm (const Vector< LevelData< T > * > &a_rhs, int a_ord) |
virtual void | setToZero (Vector< LevelData< T > * > &a_lhs) |
virtual void | write (const Vector< LevelData< T > * > *a_data, const char *a_filename) |
Public Attributes | |
bool | m_use_multigrid_preconditioner |
if true, preCond(...) function uses multigrid v-cycle(s) | |
int | m_num_mg_iterations |
number of mg v-cycles for each preCond call (if using mg preconditioner) | |
int | m_num_mg_smooth |
number of smoothings in the multigrid preconditioner | |
int | m_preCondSolverDepth |
max depth for multigrid preconditioner (if using mg preconditioner) | |
Vector< DisjointBoxLayout > | m_vectGrids |
Vector< int > | m_refRatios |
Vector< ProblemDomain > | m_domains |
Vector< RealVect > | m_vectDx |
Vector< RefCountedPtr < AMRLevelOp< LevelData< T > > > > | m_vectOperators |
vector of level operators | |
int | m_lBase |
AMRMultiGrid< LevelData< T > > | m_preCondSolver |
Solver which is used by the preCond function. | |
LinearSolver< LevelData< T > > * | m_precondBottomSolverPtr |
bottom solver for m_preCondSolver | |
bool | m_isPrecondSolverInitialized |
has the preconditioner solver been initialized? |
MultilevelLinearOp< T >::MultilevelLinearOp | ( | ) | [inline] |
default constructor (sets defaults for preconditioner)
References MultilevelLinearOp< T >::m_num_mg_iterations, MultilevelLinearOp< T >::m_num_mg_smooth, MultilevelLinearOp< T >::m_precondBottomSolverPtr, MultilevelLinearOp< T >::m_preCondSolverDepth, and MultilevelLinearOp< T >::m_use_multigrid_preconditioner.
MultilevelLinearOp< T >::~MultilevelLinearOp | ( | ) | [inline, virtual] |
References CH_TIME, and MultilevelLinearOp< T >::m_precondBottomSolverPtr.
void MultilevelLinearOp< T >::define | ( | const Vector< DisjointBoxLayout > & | a_vectGrids, | |
const Vector< int > & | a_refRatios, | |||
const Vector< ProblemDomain > & | a_domains, | |||
const Vector< RealVect > & | a_vectDx, | |||
RefCountedPtr< AMRLevelOpFactory< LevelData< T > > > & | a_opFactory, | |||
int | a_lBase | |||
) | [inline] |
define function -- opFactory should be able to define all required levels
define function
References CH_TIME, AMRMultiGrid< T >::define(), MultilevelLinearOp< T >::m_domains, MultilevelLinearOp< T >::m_isPrecondSolverInitialized, MultilevelLinearOp< T >::m_lBase, AMRMultiGrid< T >::m_maxDepth, MultilevelLinearOp< T >::m_num_mg_smooth, MultilevelLinearOp< T >::m_precondBottomSolverPtr, MultilevelLinearOp< T >::m_preCondSolver, MultilevelLinearOp< T >::m_preCondSolverDepth, MultilevelLinearOp< T >::m_refRatios, MultilevelLinearOp< T >::m_use_multigrid_preconditioner, MultilevelLinearOp< T >::m_vectDx, MultilevelLinearOp< T >::m_vectGrids, MultilevelLinearOp< T >::m_vectOperators, AMRMultiGrid< T >::m_verbosity, BiCGStabSolver< T >::m_verbosity, Max(), Vector< T >::resize(), AMRMultiGrid< T >::setSolverParameters(), and Vector< T >::size().
void MultilevelLinearOp< T >::residual | ( | Vector< LevelData< T > * > & | a_lhs, | |
const Vector< LevelData< T > * > & | a_phi, | |||
const Vector< LevelData< T > * > & | a_rhs, | |||
bool | a_homogeneous = false | |||
) | [inline, virtual] |
compute residual using AMRLevelOps AMRResidual functionality
a_lhs = L(a_phi) - a_rhs. If a_homogeneous is true, evaluate the operator using homogeneous boundary conditions.
Say you are solving L(phi) = rhs. Make a_lhs = L(a_phi) - a_rhs. If a_homogeneous is true, evaluate the operator using homogeneous boundary conditions.
Implements LinearOp< Vector< LevelData< T > * > >.
References CH_TIME, MultilevelLinearOp< T >::m_lBase, MultilevelLinearOp< T >::m_vectOperators, and Vector< T >::size().
Referenced by MultilevelLinearOp< T >::preCond().
void MultilevelLinearOp< T >::preCond | ( | Vector< LevelData< T > * > & | a_cor, | |
const Vector< LevelData< T > * > & | a_residual | |||
) | [inline, virtual] |
Apply preconditioner.
Given the current state of the residual the correction, apply your preconditioner to a_cor.
Given the current state of the residual the correction, apply your preconditioner to a_cor.
Implements LinearOp< Vector< LevelData< T > * > >.
References AMRMultiGrid< T >::AMRVCycle(), CH_TIME, MultilevelLinearOp< T >::clear(), MultilevelLinearOp< T >::create(), MultilevelLinearOp< T >::incr(), AMRMultiGrid< T >::init(), MultilevelLinearOp< T >::m_isPrecondSolverInitialized, MultilevelLinearOp< T >::m_lBase, MultilevelLinearOp< T >::m_num_mg_iterations, MultilevelLinearOp< T >::m_preCondSolver, MultilevelLinearOp< T >::m_use_multigrid_preconditioner, MultilevelLinearOp< T >::m_vectOperators, MultilevelLinearOp< T >::residual(), AMRMultiGrid< T >::setBottomSolver(), MultilevelLinearOp< T >::setToZero(), and Vector< T >::size().
void MultilevelLinearOp< T >::applyOp | ( | Vector< LevelData< T > * > & | a_lhs, | |
const Vector< LevelData< T > * > & | a_phi, | |||
bool | a_homogeneous = false | |||
) | [inline, virtual] |
In the context of solving L(phi) = rhs, set a_lhs = L(a_phi). If a_homogeneous is true, evaluate the operator using homogeneous boundary conditions.
In the context of solving L(phi) = rhs, set a_lhs = L(a_phi). If a_homogeneous is true, evaluate the operator using homogeneous boundary conditions.
Implements LinearOp< Vector< LevelData< T > * > >.
References CH_TIME, MultilevelLinearOp< T >::m_lBase, and MultilevelLinearOp< T >::m_vectOperators.
void MultilevelLinearOp< T >::create | ( | Vector< LevelData< T > * > & | a_lhs, | |
const Vector< LevelData< T > * > & | a_rhs | |||
) | [inline, virtual] |
Create data holder a_lhs that mirrors a_rhs. You do not need to copy the data of a_rhs, just make a holder the same size.
Create data holder a_lhs that mirrors a_rhs. You do not need to copy the data of a_rhs, just make a holder the same size.
Implements LinearOp< Vector< LevelData< T > * > >.
References CH_TIME, MultilevelLinearOp< T >::m_lBase, MultilevelLinearOp< T >::m_vectOperators, and Max().
Referenced by MultilevelLinearOp< T >::dotProduct(), and MultilevelLinearOp< T >::preCond().
void MultilevelLinearOp< T >::clear | ( | Vector< LevelData< T > * > & | a_lhs | ) | [inline, virtual] |
Clean up data holder before it goes out of scope. This is necessary because create calls new.
Clean up data holder before it goes out of scope. This is necessary because create calls new.
Reimplemented from LinearOp< Vector< LevelData< T > * > >.
References CH_TIME.
Referenced by MultilevelLinearOp< T >::dotProduct(), and MultilevelLinearOp< T >::preCond().
void MultilevelLinearOp< T >::assign | ( | Vector< LevelData< T > * > & | a_lhs, | |
const Vector< LevelData< T > * > & | a_rhs | |||
) | [inline, virtual] |
Set a_lhs equal to a_rhs.
Set a_lhs equal to a_rhs.
Implements LinearOp< Vector< LevelData< T > * > >.
References Vector< T >::assign(), CH_TIME, MultilevelLinearOp< T >::m_lBase, and MultilevelLinearOp< T >::m_vectOperators.
Referenced by MultilevelLinearOp< T >::dotProduct().
Real MultilevelLinearOp< T >::dotProduct | ( | const Vector< LevelData< T > * > & | a_1, | |
const Vector< LevelData< T > * > & | a_2 | |||
) | [inline, virtual] |
Compute and return the dot product of a_1 and a_2. In most contexts, this means return the sum over all data points of a_1*a_2.
Compute and return the dot product of a_1 and a_2. In most contexts, this means return the sum over all data points of a_1*a_2.
Implements LinearOp< Vector< LevelData< T > * > >.
References MultilevelLinearOp< T >::assign(), LayoutIterator::begin(), CH_TIME, MultilevelLinearOp< T >::clear(), Box::coarsen(), MultilevelLinearOp< T >::create(), BoxLayout::dataIterator(), Box::isEmpty(), BoxLayout::layoutIterator(), MultilevelLinearOp< T >::m_lBase, MultilevelLinearOp< T >::m_refRatios, MultilevelLinearOp< T >::m_vectDx, MultilevelLinearOp< T >::m_vectOperators, BoxLayoutData< T >::nComp(), LayoutIterator::ok(), MultilevelLinearOp< T >::scale(), MultilevelLinearOp< T >::setToZero(), and Vector< T >::size().
void MultilevelLinearOp< T >::incr | ( | Vector< LevelData< T > * > & | a_lhs, | |
const Vector< LevelData< T > * > & | a_x, | |||
Real | a_scale | |||
) | [inline, virtual] |
Increment by scaled amount (a_lhs += a_scale*a_x).
Increment by scaled amount (a_lhs += a_scale*a_x).
Implements LinearOp< Vector< LevelData< T > * > >.
References CH_TIME, MultilevelLinearOp< T >::m_lBase, and MultilevelLinearOp< T >::m_vectOperators.
Referenced by MultilevelLinearOp< T >::preCond().
void MultilevelLinearOp< T >::axby | ( | Vector< LevelData< T > * > & | a_lhs, | |
const Vector< LevelData< T > * > & | a_x, | |||
const Vector< LevelData< T > * > & | a_y, | |||
Real | a_a, | |||
Real | a_b | |||
) | [inline, virtual] |
Set input to a scaled sum (a_lhs = a_a*a_x + a_b*a_y).
Set input to a scaled sum (a_lhs = a_a*a_x + a_b*a_y).
Implements LinearOp< Vector< LevelData< T > * > >.
References CH_TIME, MultilevelLinearOp< T >::m_lBase, and MultilevelLinearOp< T >::m_vectOperators.
void MultilevelLinearOp< T >::scale | ( | Vector< LevelData< T > * > & | a_lhs, | |
const Real & | a_scale | |||
) | [inline, virtual] |
Multiply the input by a given scale (a_lhs *= a_scale).
Multiply the input by a given scale (a_lhs *= a_scale).
Implements LinearOp< Vector< LevelData< T > * > >.
References CH_TIME, MultilevelLinearOp< T >::m_lBase, and MultilevelLinearOp< T >::m_vectOperators.
Referenced by MultilevelLinearOp< T >::dotProduct().
Real MultilevelLinearOp< T >::norm | ( | const Vector< LevelData< T > * > & | a_rhs, | |
int | a_ord | |||
) | [inline, virtual] |
Return the norm of a_rhs. a_ord == 0 max norm, a_ord == 1 sum(abs(a_rhs)), else, L(a_ord) norm.
Return the norm of a_rhs. a_ord == 0 max norm, a_ord == 1 sum(abs(a_rhs)), else, L(a_ord) norm.
Implements LinearOp< Vector< LevelData< T > * > >.
References CH_TIME, MayDay::Error(), MultilevelLinearOp< T >::m_lBase, MultilevelLinearOp< T >::m_refRatios, and MultilevelLinearOp< T >::m_vectOperators.
void MultilevelLinearOp< T >::setToZero | ( | Vector< LevelData< T > * > & | a_lhs | ) | [inline, virtual] |
Set a_lhs to zero.
Set a_lhs to zero.
Implements LinearOp< Vector< LevelData< T > * > >.
References CH_TIME, MultilevelLinearOp< T >::m_lBase, MultilevelLinearOp< T >::m_vectOperators, and Max().
Referenced by MultilevelLinearOp< T >::dotProduct(), and MultilevelLinearOp< T >::preCond().
void MultilevelLinearOp< T >::write | ( | const Vector< LevelData< T > * > * | a, | |
const char * | filename | |||
) | [inline, virtual] |
Debugging aid for solvers. Print out a "T" to a file named "filename" default implementation is to print out a message saying "LinearOp::write not implemented"
Reimplemented from LinearOp< Vector< LevelData< T > * > >.
References MultilevelLinearOp< T >::m_refRatios, MayDay::Warning(), and writeVectorLevelName().
bool MultilevelLinearOp< T >::m_use_multigrid_preconditioner |
if true, preCond(...) function uses multigrid v-cycle(s)
Referenced by MultilevelLinearOp< T >::define(), MultilevelLinearOp< T >::MultilevelLinearOp(), and MultilevelLinearOp< T >::preCond().
int MultilevelLinearOp< T >::m_num_mg_iterations |
number of mg v-cycles for each preCond call (if using mg preconditioner)
Referenced by MultilevelLinearOp< T >::MultilevelLinearOp(), and MultilevelLinearOp< T >::preCond().
int MultilevelLinearOp< T >::m_num_mg_smooth |
number of smoothings in the multigrid preconditioner
Referenced by MultilevelLinearOp< T >::define(), and MultilevelLinearOp< T >::MultilevelLinearOp().
int MultilevelLinearOp< T >::m_preCondSolverDepth |
max depth for multigrid preconditioner (if using mg preconditioner)
Referenced by MultilevelLinearOp< T >::define(), and MultilevelLinearOp< T >::MultilevelLinearOp().
Vector<DisjointBoxLayout> MultilevelLinearOp< T >::m_vectGrids |
Referenced by MultilevelLinearOp< T >::define().
Vector<int> MultilevelLinearOp< T >::m_refRatios |
Vector<ProblemDomain> MultilevelLinearOp< T >::m_domains |
Referenced by MultilevelLinearOp< T >::define().
Vector<RealVect> MultilevelLinearOp< T >::m_vectDx |
Referenced by MultilevelLinearOp< T >::define(), and MultilevelLinearOp< T >::dotProduct().
Vector<RefCountedPtr<AMRLevelOp<LevelData<T> > > > MultilevelLinearOp< T >::m_vectOperators |
vector of level operators
Referenced by MultilevelLinearOp< T >::applyOp(), MultilevelLinearOp< T >::assign(), MultilevelLinearOp< T >::axby(), MultilevelLinearOp< T >::create(), MultilevelLinearOp< T >::define(), MultilevelLinearOp< T >::dotProduct(), MultilevelLinearOp< T >::incr(), MultilevelLinearOp< T >::norm(), MultilevelLinearOp< T >::preCond(), MultilevelLinearOp< T >::residual(), MultilevelLinearOp< T >::scale(), and MultilevelLinearOp< T >::setToZero().
int MultilevelLinearOp< T >::m_lBase |
Referenced by MultilevelLinearOp< T >::applyOp(), MultilevelLinearOp< T >::assign(), MultilevelLinearOp< T >::axby(), MultilevelLinearOp< T >::create(), MultilevelLinearOp< T >::define(), MultilevelLinearOp< T >::dotProduct(), MultilevelLinearOp< T >::incr(), MultilevelLinearOp< T >::norm(), MultilevelLinearOp< T >::preCond(), MultilevelLinearOp< T >::residual(), MultilevelLinearOp< T >::scale(), and MultilevelLinearOp< T >::setToZero().
AMRMultiGrid<LevelData<T> > MultilevelLinearOp< T >::m_preCondSolver |
Solver which is used by the preCond function.
if m_use_multigrid_preconditioner is true, this solver is used to apply a AMR multigrid v-cycle as the preconditioner
Referenced by MultilevelLinearOp< T >::define(), and MultilevelLinearOp< T >::preCond().
LinearSolver<LevelData<T> >* MultilevelLinearOp< T >::m_precondBottomSolverPtr |
bottom solver for m_preCondSolver
Referenced by MultilevelLinearOp< T >::define(), MultilevelLinearOp< T >::MultilevelLinearOp(), and MultilevelLinearOp< T >::~MultilevelLinearOp().
bool MultilevelLinearOp< T >::m_isPrecondSolverInitialized |
has the preconditioner solver been initialized?
Referenced by MultilevelLinearOp< T >::define(), and MultilevelLinearOp< T >::preCond().