11 #ifndef _BASELEVELCRANKNICOLSON_H_ 12 #define _BASELEVELCRANKNICOLSON_H_ 25 #include "NamespaceHeader.H" 41 template <
class LevelDataType,
43 class FluxRegisterType>
64 :
BaseLevelHeatSolver<LevelDataType,FluxDataType,FluxRegisterType>(a_grids, a_refRat, a_level0Domain, a_opFact, a_solver)
106 LevelDataType& a_phiOld,
107 LevelDataType& a_src,
109 FluxRegisterType* a_fineFluxRegPtr,
110 FluxRegisterType* a_crseFluxRegPtr,
111 const LevelDataType* a_crsePhiOldPtr,
112 const LevelDataType* a_crsePhiNewPtr,
118 bool a_zeroPhi =
true,
119 bool a_rhsAlreadyKappaWeighted =
false,
120 int a_fluxStartComponent = 0)
123 int ncomp = a_phiNew.nComp();
125 Interval intervFlux(a_fluxStartComponent, a_fluxStartComponent + ncomp-1);
129 CH_assert((a_level == 0) || (a_crsePhiOldPtr != NULL));
130 CH_assert((a_level == 0) || (a_crsePhiNewPtr != NULL));
131 CH_assert(a_crseNewTime >= a_crseOldTime);
134 LevelDataType rhst, phit;
135 this->
m_ops[a_level]->create(rhst, a_src);
136 this->
m_ops[a_level]->create(phit, a_phiNew);
138 this->
m_ops[a_level]->setToZero(phit);
139 this->
m_ops[a_level]->setToZero(rhst);
142 this->
m_ops[a_level]->setToZero(a_phiNew);
145 LevelDataType coarseData;
146 if ((a_crsePhiOldPtr != NULL) && (a_level > 0))
148 this->
m_ops[a_level-1]->create(coarseData, *a_crsePhiOldPtr);
149 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
150 a_oldTime, a_crseOldTime, a_crseNewTime, a_level-1);
155 this->
applyHelm(phit, a_phiOld, &coarseData, a_level, 0.5, a_dt,
false);
158 this->
m_ops[a_level]->incr(rhst, a_src , a_dt);
161 this->
m_ops[a_level]->diagonalScale(phit,
true);
164 if (!a_rhsAlreadyKappaWeighted)
165 this->
m_ops[a_level]->kappaScale(rhst);
168 this->
m_ops[a_level]->incr(rhst, phit, 1.0);
170 this->
solveHelm(a_phiNew, coarseData, rhst, a_level, 0.5, a_dt, a_zeroPhi);
171 this->
incrementFlux(a_flux, a_phiNew, a_level, 0.5, a_dt, -1.0,
false);
176 if ((a_fineFluxRegPtr != NULL) && (a_level < this->
m_grids.
size()-1))
181 FluxDataType& thisFlux = a_flux[dit];
182 for (
int dir=0; dir<
SpaceDim; ++dir)
184 a_fineFluxRegPtr->incrementCoarse(thisFlux[dir],
193 if ((a_crseFluxRegPtr != NULL) && (a_level > 0))
199 FluxDataType& thisFlux = a_flux[dit];
200 for (
int dir=0; dir<
SpaceDim; ++dir)
202 a_crseFluxRegPtr->incrementFine(thisFlux[dir], fluxMult, dit(),
218 #include "NamespaceFooter.H" A reference-counting handle class.
Definition: RefCountedPtr.H:173
virtual ~BaseLevelCrankNicolson()
Destructor, called after destructors of BaseLevelCrankNicolson subclasses.
Definition: BaseLevelCrankNicolson.H:69
#define CH_assert(cond)
Definition: CHArray.H:37
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
Definition: BaseLevelHeatSolver.H:43
BaseLevelCrankNicolson(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: BaseLevelCrankNicolson.H:59
Definition: DataIterator.H:190
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
const int SpaceDim
Definition: SPACE.H:38
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)
Definition: BaseLevelCrankNicolson.H:105
Structure for passing component ranges in code.
Definition: Interval.H:23
Vector< DisjointBoxLayout > m_grids
The disjoint box layouts at every AMR grid level.
Definition: BaseLevelHeatSolver.H:504
new code
Definition: BoxLayoutData.H:170
BaseLevelCrankNicolson & operator=(const BaseLevelCrankNicolson &)
double Real
Definition: REAL.H:33
size_t size() const
Definition: Vector.H:192
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
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
Definition: BaseLevelCrankNicolson.H:44