11 #ifndef _BASELEVELHEATSOLVER_H__ 12 #define _BASELEVELHEATSOLVER_H__ 24 #include "NamespaceHeader.H" 40 template <
class LevelDataType,
42 class FluxRegisterType>
63 for (
int ilev = 0; ilev <
m_ops.
size(); ilev++)
66 if (
m_ops[ilev]==NULL)
68 MayDay::Error(
"dynamic cast failed---is that operator really a TGAHelmOp?");
110 virtual void updateSoln(LevelDataType& a_phiNew,
111 LevelDataType& a_phiOld,
112 LevelDataType& a_src,
114 FluxRegisterType* a_fineFluxRegPtr,
115 FluxRegisterType* a_crseFluxRegPtr,
116 const LevelDataType* a_crsePhiOldPtr,
117 const LevelDataType* a_crsePhiNewPtr,
123 bool a_zeroPhi =
true,
124 bool a_rhsAlreadyKappaWeighted=
false,
125 int a_fluxStartComponent = 0) = 0;
130 LevelDataType& a_phiOld,
131 LevelDataType& a_src,
132 FluxRegisterType* a_fineFluxRegPtr,
133 FluxRegisterType* a_crseFluxRegPtr,
134 const LevelDataType* a_crsePhiOldPtr,
135 const LevelDataType* a_crsePhiNewPtr,
141 bool a_zeroPhi =
true,
142 bool a_rhsAlreadyKappaWeighted =
false,
143 int a_fluxStartComponent = 0)
145 MayDay::Error(
"need to overwrite this function with one that calls with your flux or call more general one");
186 LevelDataType& a_phiOld,
187 LevelDataType& a_src,
189 FluxRegisterType* a_fineFluxRegPtr,
190 FluxRegisterType* a_crseFluxRegPtr,
191 const LevelDataType* a_crsePhiOldPtr,
192 const LevelDataType* a_crsePhiNewPtr,
198 bool a_zeroPhi =
true,
199 bool a_rhsAlreadyKappaWeighted =
false 205 LevelDataType phiNew;
207 m_ops[a_level]->create(phiNew, a_phiOld);
208 m_ops[a_level]->setToZero(phiNew);
215 a_fineFluxRegPtr, a_crseFluxRegPtr,
216 a_crsePhiOldPtr, a_crsePhiNewPtr,
217 a_oldTime, a_crseOldTime,
218 a_crseNewTime, a_dt, a_level, a_zeroPhi, a_rhsAlreadyKappaWeighted);
221 m_ops[a_level]->incr(phiNew, a_phiOld, -1.0);
222 m_ops[a_level]->scale(phiNew, 1.0/a_dt);
225 m_ops[a_level]->diagonalScale(phiNew,
false);
228 m_ops[a_level]->incr(phiNew, a_src, -1.0);
239 const LevelDataType& a_phi,
240 const LevelDataType* a_phiC,
246 m_ops[a_level]->setAlphaAndBeta(a_alpha, a_beta);
249 m_ops[a_level]->create(zero, a_ans);
250 m_ops[a_level]->setToZero(zero);
256 if ( (a_phiC == NULL) || (a_level==0))
258 m_ops[a_level]->applyOp(a_ans, a_phi,
false);
262 m_ops[a_level]->AMROperatorNF(a_ans, a_phi, *a_phiC,
false);
267 m_ops[a_level]->applyOpNoBoundary(a_ans, a_phi);
292 const LevelDataType& a_phi,
293 const LevelDataType* a_phiC,
297 bool a_homogeneousBC)
300 Real factor = a_mu*a_dt;
301 m_ops[a_level]->setAlphaAndBeta(1.0, factor);
304 m_ops[a_level]->create(zero, a_ans);
305 m_ops[a_level]->setToZero(zero);
309 if ( (a_phiC == NULL) || (a_level==0))
311 m_ops[a_level]->applyOp(a_ans, a_phi, a_homogeneousBC);
315 m_ops[a_level]->AMROperatorNF(a_ans, a_phi, *a_phiC, a_homogeneousBC);
336 LevelDataType& a_phi,
343 Real factor = a_sign*a_dt*a_mu;
344 m_ops[a_level]->setAlphaAndBeta(1.0, factor);
347 m_ops[a_level]->fillGrad(a_phi);
350 FluxDataType& thisFlux = a_diffusiveFlux[dit];
351 FluxDataType tempFlux;
352 tempFlux.
define(thisFlux);
354 tempFlux.setVal(0.0);
357 thisFlux.setVal(0.0);
360 m_ops[a_level]->getFlux(tempFlux, a_phi,
m_grids[a_level][dit], dit(), 1.0);
361 thisFlux += tempFlux;
384 LevelDataType& a_phiC,
385 LevelDataType& a_rhs,
389 bool a_zeroPhi =
true)
393 m_ops[a_level]->setToZero(a_phi);
397 phi[a_level] = &a_phi;
398 rhs[a_level] = &a_rhs;
401 phi[a_level-1] = &a_phiC;
404 Real factor = -a_dt*a_mu;
409 if (solverExitStatus==2 || solverExitStatus==4 || solverExitStatus==6)
415 pout() <<
"BaseLevelTGA:: WARNING: solver exitStatus == " 416 << solverExitStatus << std::endl;
429 for (
int iop = 0; iop < ops.
size(); iop++)
435 for (
int iop = 0; iop <
m_ops.
size(); iop++)
437 m_ops[iop]->setAlphaAndBeta(a_alpha, a_beta);
479 const LevelDataType& a_oldData,
480 const LevelDataType& a_newData,
488 Real diff = (a_newTime - a_oldTime);
489 this->
m_ops[a_level]->setToZero(a_data);
493 this->
m_ops[a_level]->incr(a_data, a_oldData, 1.0);
497 Real factor = (a_time-a_oldTime)/(a_newTime - a_oldTime);
498 this->
m_ops[a_level]->incr(a_data, a_oldData, 1.0-factor);
499 this->
m_ops[a_level]->incr(a_data, a_newData, factor);
521 #include "NamespaceFooter.H" std::ostream & pout()
Use this in place of std::cout for program output.
ProblemDomain m_level0Domain
The coarsest domain on which the Helmholtz equation is integrated.
Definition: BaseLevelHeatSolver.H:510
A reference-counting handle class.
Definition: RefCountedPtr.H:173
#define CH_assert(cond)
Definition: CHArray.H:37
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
virtual ~BaseLevelHeatSolver()
Destructor, called after destructors of BaseLevelHeatSolver subclasses.
Definition: BaseLevelHeatSolver.H:74
Definition: BaseLevelHeatSolver.H:43
virtual void solve(Vector< T *> &a_phi, const Vector< T *> &a_rhs, int l_max, int l_base, bool a_zeroPhi=true, bool forceHomogeneous=false)
Definition: AMRMultiGrid.H:895
virtual void applyOperator(LevelDataType &a_ans, const LevelDataType &a_phi, const LevelDataType *a_phiC, int a_level, Real a_alpha, Real a_beta, bool a_applyBC)
Definition: BaseLevelHeatSolver.H:238
virtual LevelTGAHelmOp< LevelDataType, FluxDataType > * newOp(const ProblemDomain &a_indexSpace, RefCountedPtr< AMRLevelOpFactory< LevelDataType > > &a_opFact)
Definition: BaseLevelHeatSolver.H:447
virtual bool ok() const
return true if this iterator is still in its Layout
Definition: LayoutIterator.H:117
Definition: DataIterator.H:190
RefCountedPtr< AMRMultiGrid< LevelDataType > > m_solver
The multigrid solver used to solve the Helmholtz equation.
Definition: BaseLevelHeatSolver.H:518
void applyHelm(LevelDataType &a_ans, const LevelDataType &a_phi, const LevelDataType *a_phiC, int a_level, Real a_mu, Real a_dt, bool a_homogeneousBC)
Definition: BaseLevelHeatSolver.H:291
virtual void setAlphaAndBeta(const Real &a_alpha, const Real &a_beta)=0
int size() const
Returns the number of grid levels on which this integrator operates.
Definition: BaseLevelHeatSolver.H:457
void resize(unsigned int isize)
Definition: Vector.H:346
virtual void computeDiffusion(LevelDataType &a_diffusiveTerm, LevelDataType &a_phiOld, LevelDataType &a_src, LevelData< FluxDataType > &a_flux, FluxRegisterType *a_fineFluxRegPtr, FluxRegisterType *a_crseFluxRegPtr, const LevelDataType *a_crsePhiOldPtr, const LevelDataType *a_crsePhiNewPtr, Real a_oldTime, Real a_crseOldTime, Real a_crseNewTime, Real a_dt, int a_level, bool a_zeroPhi=true, bool a_rhsAlreadyKappaWeighted=false)
Definition: BaseLevelHeatSolver.H:185
virtual void updateSoln(LevelDataType &a_phiNew, LevelDataType &a_phiOld, LevelDataType &a_src, FluxRegisterType *a_fineFluxRegPtr, FluxRegisterType *a_crseFluxRegPtr, const LevelDataType *a_crsePhiOldPtr, const LevelDataType *a_crsePhiNewPtr, Real a_oldTime, Real a_crseOldTime, Real a_crseNewTime, Real a_dt, int a_level, bool a_zeroPhi=true, bool a_rhsAlreadyKappaWeighted=false, int a_fluxStartComponent=0)
Definition: BaseLevelHeatSolver.H:129
Vector< MGLevelOp< T > *> getAllOperators()
Definition: AMRMultiGrid.H:556
Vector< DisjointBoxLayout > m_grids
The disjoint box layouts at every AMR grid level.
Definition: BaseLevelHeatSolver.H:504
new code
Definition: BoxLayoutData.H:170
Vector< T > & assign(const T &inval)
assign a scalar to every element of the vector
Definition: Vector.H:153
double Real
Definition: REAL.H:33
virtual void define(const DisjointBoxLayout &dp, int comps, const IntVect &ghost=IntVect::Zero, const DataFactory< T > &a_factory=DefaultDataFactory< T >())
Definition: LevelDataI.H:93
size_t size() const
Definition: Vector.H:192
BaseLevelHeatSolver(const Vector< DisjointBoxLayout > &a_grids, const Vector< int > &a_refRat, const ProblemDomain &a_level0Domain, RefCountedPtr< AMRLevelOpFactory< LevelDataType > > &a_opFact, const RefCountedPtr< AMRMultiGrid< LevelDataType > > &a_solver)
Definition: BaseLevelHeatSolver.H:49
virtual void updateSoln(LevelDataType &a_phiNew, LevelDataType &a_phiOld, LevelDataType &a_src, LevelData< FluxDataType > &a_flux, FluxRegisterType *a_fineFluxRegPtr, FluxRegisterType *a_crseFluxRegPtr, const LevelDataType *a_crsePhiOldPtr, const LevelDataType *a_crsePhiNewPtr, Real a_oldTime, Real a_crseOldTime, Real a_crseNewTime, Real a_dt, int a_level, bool a_zeroPhi=true, bool a_rhsAlreadyKappaWeighted=false, int a_fluxStartComponent=0)=0
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.
void resetSolverAlphaAndBeta(const Real &a_alpha, const Real &a_beta)
Definition: BaseLevelHeatSolver.H:425
int m_exitStatus
Definition: AMRMultiGrid.H:380
Vector< int > m_refRat
The refinement ratios between AMR grid levels.
Definition: BaseLevelHeatSolver.H:507
void timeInterp(LevelDataType &a_data, const LevelDataType &a_oldData, const LevelDataType &a_newData, Real a_time, Real a_oldTime, Real a_newTime, int a_level)
Definition: BaseLevelHeatSolver.H:478
void solveHelm(LevelDataType &a_phi, LevelDataType &a_phiC, LevelDataType &a_rhs, int a_level, Real a_mu, Real a_dt, bool a_zeroPhi=true)
Definition: BaseLevelHeatSolver.H:383
Definition: AMRMultiGrid.H:233
Vector< AMRLevelOp< T > *> & getAMROperators()
Definition: AMRMultiGrid.H:434
void incrementFlux(LevelData< FluxDataType > &a_diffusiveFlux, LevelDataType &a_phi, int a_level, Real a_mu, Real a_dt, Real a_sign, bool a_setToZero)
Definition: BaseLevelHeatSolver.H:335
Vector< LevelTGAHelmOp< LevelDataType, FluxDataType > *> m_ops
Definition: BaseLevelHeatSolver.H:515