12 #ifndef _FASMULTIGRID_H_    13 #define _FASMULTIGRID_H_    19 #include "NamespaceHeader.H"    53   virtual void solve(T& a_phi, 
const T& a_rhs, 
Real a_tolerance, 
int a_maxIterations, 
int verbosity= 0);
    60   virtual void oneCycle(T& a_e, 
const T& a_res);
    61   void oneCycle(T& a_e, 
const T& a_res, T* a_phiCoarse);
    64   virtual void cycle(
int a_depth, T& a_correction, 
const T& a_residual);
   109   CH_TIME(
"FASMultiGrid::solve");
   110   this->
init(a_phi, a_rhs);
   112   T correction, residual;
   113   this->
m_op[0]->create(correction, a_phi);
   114   this->
m_op[0]->create(residual, a_rhs);
   115   this->
m_op[0]->setToZero(a_phi);
   116   this->
m_op[0]->residual(residual, a_phi, a_rhs, 
false);
   118   Real errorno = this->
m_op[0]->norm(residual, 0);
   121     pout() << 
"FASmultigrid::solve initial residual = " << errorno << std::endl;
   123   Real compval = a_tolerance*errorno;
   124   Real epsilon = 1.0e-16;
   125   compval = 
Max(compval, epsilon);
   126   Real error = errorno;
   128   while ((error > compval) && (error > a_tolerance*errorno) && (iter < a_maxIterations))
   130     this->
m_op[0]->setToZero(correction);
   131     this->
m_op[0]->residual(residual, a_phi, a_rhs, 
false);
   132     error = this->
m_op[0]->norm(residual, 0);
   135       pout() << 
"FASMultigrid::solve iter = " << iter <<  
",  residual = " << error << std::endl;
   138     this->
cycle(0, correction, residual);
   139     this->
m_op[0]->incr(a_phi, correction, 1.0);
   145     pout() << 
"FASMultigrid::solve final residual = " << error << std::endl;
   166   CH_TIME(
"FASMultigrid::oneCycle");
   172   for (
int depth = 1; depth < this->
m_depth; depth++)
   180       const T& phiCoarseGridFiner = *
m_phiCoarse[depth-1];
   185       this->
m_op[depth]->create(scratchCrse,  phiCoarseGridFiner);
   186       this->
m_op[depth]->setToZero(scratchCrse);
   188       this->
m_op[depth]->createCoarser(*(
m_phiCoarse[depth]), phiCoarseGridFiner, 
true);
   189       this->
m_op[depth]->restrictR(*(
m_phiCoarse[depth]), phiCoarseGridFiner);
   204   this->
cycle(0, a_phi, a_rhs);
   223   CH_TIME(
"FASMultigrid::cycle");
   228     CH_TIME(
"FASMultigrid::cycle:bottom-solve");
   247       MayDay::Error(
"FASMultigrid::cycle - non-V cycle options not implemented");
   252       T phi_coarse, op_coarse;
   255       this->
m_op[depth+1]->setToZero(phi_coarse);
   259       this->
m_op[depth+1]->setToZero(op_coarse);
   273       this->
m_op[depth]->create(scratch,  a_phi);
   274       this->
m_op[depth]->setToZero(scratch);
   276       this->
m_op[depth]->createCoarser(phi_coarse, a_phi, 
true); 
   278       this->
m_op[depth  ]->restrictR(phi_coarse, a_phi);
   283       this->
m_op[depth+1]->applyOpMg(op_coarse, phi_coarse, 
m_phiCoarse[depth+1], 
false); 
   289       this->
m_op[depth+1]->incr(*(this->
m_residual[depth+1]), op_coarse, 1.0);
   291       for (
int img = 0; img < cycles; img++)
   297       this->
m_op[depth  ]->prolongIncrement(a_phi, *(this->
m_correction[depth+1]));
   314 #include "NamespaceFooter.H" std::ostream & pout()
Use this in place of std::cout for program output. 
 
const ProblemDomain & physDomain() const
 
int m_cycle
Definition: MultiGrid.H:390
 
#define CH_assert(cond)
Definition: CHArray.H:37
 
A class to facilitate interaction with physical boundary conditions. 
Definition: ProblemDomain.H:141
 
Vector< T *> m_residual
Definition: MultiGrid.H:407
 
virtual void solve(T &a_phi, const T &a_rhs, Real a_tolerance, int a_maxIterations, int verbosity=0)
Definition: FASMultiGrid.H:107
 
one dimensional dynamic array 
Definition: Vector.H:53
 
void init(const T &a_correction, const T &a_residual)
Definition: MultiGrid.H:534
 
virtual void define(MGLevelOpFactory< T > &a_factory, LinearSolver< T > *a_bottomSolver, const ProblemDomain &a_domain, int a_maxDepth=-1, MGLevelOp< T > *a_finestLevelOp=NULL)
Function to define a MultiGrid object. 
Definition: MultiGrid.H:461
 
Vector< MGLevelOp< T > * > m_op
Definition: MultiGrid.H:406
 
bool m_homogeneous
Definition: MultiGrid.H:391
 
int m_post
Definition: MultiGrid.H:390
 
FASMultiGrid()
Definition: FASMultiGrid.H:77
 
void resize(unsigned int isize)
Definition: Vector.H:346
 
virtual void oneCycle(T &a_e, const T &a_res)
Execute ONE v-cycle of multigrid. 
Definition: FASMultiGrid.H:157
 
const IntVect & bigEnd() const
Definition: Box.H:1768
 
int m_depth
Definition: MultiGrid.H:390
 
void clear()
Definition: Vector.H:180
 
#define CH_TIME(name)
Definition: CH_Timer.H:82
 
Definition: MultiGrid.H:294
 
const IntVect & smallEnd() const
{ Accessors} 
Definition: Box.H:1754
 
double Real
Definition: REAL.H:33
 
Definition: MultiGrid.H:30
 
virtual ~FASMultiGrid()
Definition: FASMultiGrid.H:85
 
Definition: FASMultiGrid.H:22
 
A BoxLayout that has a concept of disjointedness. 
Definition: DisjointBoxLayout.H:30
 
size_t size() const
Definition: Vector.H:192
 
int m_bottom
Definition: MultiGrid.H:390
 
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code. 
 
Definition: MultiGrid.H:331
 
virtual void cycle(int a_depth, T &a_correction, const T &a_residual)
Definition: FASMultiGrid.H:221
 
Vector< T *> m_correction
Definition: MultiGrid.H:408
 
A Rectangular Domain on an Integer Lattice. 
Definition: Box.H:465
 
Definition: LinearSolver.H:156
 
T Max(const T &a_a, const T &a_b)
Definition: Misc.H:39
 
const Box & domainBox() const
Returns the logical computational domain. 
Definition: ProblemDomain.H:887
 
Vector< T *> m_phiCoarse
Definition: FASMultiGrid.H:68
 
int m_pre
Definition: MultiGrid.H:390
 
virtual void define(MGLevelOpFactory< T > &a_factory, LinearSolver< T > *a_bottomSolver, const ProblemDomain &a_domain, int a_maxDepth=-1, MGLevelOp< T > *a_finestLevelOp=NULL)
Function to define a FASMultiGrid object. 
Definition: FASMultiGrid.H:91