11 #ifndef _BASELEVELHEATSOLVER_H__ 12 #define _BASELEVELHEATSOLVER_H__ 24 #include "NamespaceHeader.H" 41 template <
class LevelDataType,
43 class FluxRegisterType>
64 for (
int ilev = 0; ilev <
m_ops.
size(); ilev++)
67 if (
m_ops[ilev]==NULL)
69 MayDay::Error(
"dynamic cast failed---is that operator really a TGAHelmOp?");
111 virtual void updateSoln(LevelDataType& a_phiNew,
112 LevelDataType& a_phiOld,
113 LevelDataType& a_src,
115 FluxRegisterType* a_fineFluxRegPtr,
116 FluxRegisterType* a_crseFluxRegPtr,
117 const LevelDataType* a_crsePhiOldPtr,
118 const LevelDataType* a_crsePhiNewPtr,
124 bool a_zeroPhi =
true,
125 bool a_rhsAlreadyKappaWeighted=
false,
126 int a_fluxStartComponent = 0) = 0;
131 LevelDataType& a_phiOld,
132 LevelDataType& a_src,
133 FluxRegisterType* a_fineFluxRegPtr,
134 FluxRegisterType* a_crseFluxRegPtr,
135 const LevelDataType* a_crsePhiOldPtr,
136 const LevelDataType* a_crsePhiNewPtr,
142 bool a_zeroPhi =
true,
143 bool a_rhsAlreadyKappaWeighted =
false,
144 int a_fluxStartComponent = 0)
146 MayDay::Error(
"need to overwrite this function with one that calls with your flux or call more general one");
187 LevelDataType& a_phiOld,
188 LevelDataType& a_src,
190 FluxRegisterType* a_fineFluxRegPtr,
191 FluxRegisterType* a_crseFluxRegPtr,
192 const LevelDataType* a_crsePhiOldPtr,
193 const LevelDataType* a_crsePhiNewPtr,
199 bool a_zeroPhi =
true,
200 bool a_rhsAlreadyKappaWeighted =
false 206 LevelDataType phiNew;
208 m_ops[a_level]->create(phiNew, a_phiOld);
209 m_ops[a_level]->setToZero(phiNew);
216 a_fineFluxRegPtr, a_crseFluxRegPtr,
217 a_crsePhiOldPtr, a_crsePhiNewPtr,
218 a_oldTime, a_crseOldTime,
219 a_crseNewTime, a_dt, a_level, a_zeroPhi, a_rhsAlreadyKappaWeighted);
222 m_ops[a_level]->incr(phiNew, a_phiOld, -1.0);
223 m_ops[a_level]->scale(phiNew, 1.0/a_dt);
226 m_ops[a_level]->diagonalScale(phiNew,
false);
229 m_ops[a_level]->incr(phiNew, a_src, -1.0);
241 const LevelDataType& a_phi,
242 const LevelDataType* a_phiC,
248 m_ops[a_level]->setAlphaAndBeta(a_alpha, a_beta);
251 m_ops[a_level]->create(zero, a_ans);
252 m_ops[a_level]->setToZero(zero);
258 if ( (a_phiC == NULL) || (a_level==0))
260 m_ops[a_level]->applyOp(a_ans, a_phi,
false);
264 m_ops[a_level]->AMROperatorNF(a_ans, a_phi, *a_phiC,
false);
269 m_ops[a_level]->applyOpNoBoundary(a_ans, a_phi);
295 const LevelDataType& a_phi,
296 const LevelDataType* a_phiC,
300 bool a_homogeneousBC)
303 Real factor = a_mu*a_dt;
304 m_ops[a_level]->setAlphaAndBeta(1.0, factor);
307 m_ops[a_level]->create(zero, a_ans);
308 m_ops[a_level]->setToZero(zero);
312 if ( (a_phiC == NULL) || (a_level==0))
314 m_ops[a_level]->applyOp(a_ans, a_phi, a_homogeneousBC);
318 m_ops[a_level]->AMROperatorNF(a_ans, a_phi, *a_phiC, a_homogeneousBC);
340 LevelDataType& a_phi,
347 Real factor = a_sign*a_dt*a_mu;
348 m_ops[a_level]->setAlphaAndBeta(1.0, factor);
351 m_ops[a_level]->fillGrad(a_phi);
354 FluxDataType& thisFlux = a_diffusiveFlux[dit];
355 FluxDataType tempFlux;
356 tempFlux.
define(thisFlux);
358 tempFlux.setVal(0.0);
361 thisFlux.setVal(0.0);
364 m_ops[a_level]->getFlux(tempFlux, a_phi,
m_grids[a_level][dit], dit(), 1.0);
365 thisFlux += tempFlux;
388 LevelDataType& a_phiC,
389 LevelDataType& a_rhs,
393 bool a_zeroPhi =
true)
397 m_ops[a_level]->setToZero(a_phi);
401 phi[a_level] = &a_phi;
402 rhs[a_level] = &a_rhs;
405 phi[a_level-1] = &a_phiC;
408 Real factor = -a_dt*a_mu;
413 if (solverExitStatus==2 || solverExitStatus==4 || solverExitStatus==6)
419 pout() <<
"BaseLevelTGA:: WARNING: solver exitStatus == " 420 << solverExitStatus << std::endl;
434 for (
int iop = 0; iop < ops.
size(); iop++)
440 for (
int iop = 0; iop <
m_ops.
size(); iop++)
442 m_ops[iop]->setAlphaAndBeta(a_alpha, a_beta);
485 const LevelDataType& a_oldData,
486 const LevelDataType& a_newData,
494 Real diff = (a_newTime - a_oldTime);
495 this->
m_ops[a_level]->setToZero(a_data);
499 this->
m_ops[a_level]->incr(a_data, a_oldData, 1.0);
503 Real factor = (a_time-a_oldTime)/(a_newTime - a_oldTime);
504 this->
m_ops[a_level]->incr(a_data, a_oldData, 1.0-factor);
505 this->
m_ops[a_level]->incr(a_data, a_newData, factor);
531 #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:517
A reference-counting handle class.
Definition: RefCountedPtr.H:66
#define CH_assert(cond)
Definition: CHArray.H:37
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
virtual ~BaseLevelHeatSolver()
Destructor, called after destructors of BaseLevelHeatSolver subclasses.
Definition: BaseLevelHeatSolver.H:75
Definition: BaseLevelHeatSolver.H:44
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:833
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:240
virtual LevelTGAHelmOp< LevelDataType, FluxDataType > * newOp(const ProblemDomain &a_indexSpace, RefCountedPtr< AMRLevelOpFactory< LevelDataType > > &a_opFact)
Definition: BaseLevelHeatSolver.H:453
virtual bool ok() const
return true if this iterator is still in its Layout
Definition: LayoutIterator.H:110
Definition: DataIterator.H:140
RefCountedPtr< AMRMultiGrid< LevelDataType > > m_solver
The multigrid solver used to solve the Helmholtz equation.
Definition: BaseLevelHeatSolver.H:525
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:294
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:463
void resize(unsigned int isize)
Definition: Vector.H:323
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:186
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:130
Vector< MGLevelOp< T > *> getAllOperators()
Definition: AMRMultiGrid.H:552
Vector< DisjointBoxLayout > m_grids
The disjoint box layouts at every AMR grid level.
Definition: BaseLevelHeatSolver.H:511
Definition: BoxLayoutData.H:136
Vector< T > & assign(const T &inval)
assign a scalar to every element of the vector
Definition: Vector.H:138
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:70
size_t size() const
Definition: Vector.H:177
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:50
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:430
int m_exitStatus
Definition: AMRMultiGrid.H:379
Vector< int > m_refRat
The refinement ratios between AMR grid levels.
Definition: BaseLevelHeatSolver.H:514
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:484
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:387
Definition: AMRMultiGrid.H:231
Vector< AMRLevelOp< T > *> & getAMROperators()
Definition: AMRMultiGrid.H:431
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:339
Vector< LevelTGAHelmOp< LevelDataType, FluxDataType > *> m_ops
Definition: BaseLevelHeatSolver.H:522