11 #ifndef _BASELEVELTGA_H__ 12 #define _BASELEVELTGA_H__ 25 #include "NamespaceHeader.H" 42 template <
class LevelDataType,
44 class FluxRegisterType>
65 :
BaseLevelHeatSolver<LevelDataType,FluxDataType,FluxRegisterType>(a_grids, a_refRat, a_level0Domain, a_opFact, a_solver),
72 Real tgaEpsilon = 1.e-12;
74 tgaEpsilon = sqrt(tgaEpsilon);
76 Real a = 2.0 - sqrt(2.0) - tgaEpsilon;
77 m_mu1 = (a - sqrt( a*a - 4.0*a + 2.0))/2.0 ;
78 m_mu2 = (a + sqrt( a*a - 4.0*a + 2.0))/2.0 ;
82 Real discr = sqrt(a*a - 4.0*a + 2.0);
83 m_r1 = (2.0*a - 1.0)/(a + discr);
124 LevelDataType& a_phiOld,
125 LevelDataType& a_src,
127 FluxRegisterType* a_fineFluxRegPtr,
128 FluxRegisterType* a_crseFluxRegPtr,
129 const LevelDataType* a_crsePhiOldPtr,
130 const LevelDataType* a_crsePhiNewPtr,
136 bool a_zeroPhi =
true,
137 bool a_rhsAlreadyKappaWeighted =
false,
138 int a_fluxStartComponent = 0)
141 if (!this->
m_ops[a_level]->isTimeDependent())
144 a_fineFluxRegPtr, a_crseFluxRegPtr,
145 a_crsePhiOldPtr, a_crsePhiNewPtr,
146 a_oldTime, a_crseOldTime, a_crseNewTime,
147 a_dt, a_level, a_zeroPhi,
148 a_fluxStartComponent);
156 a_fineFluxRegPtr, a_crseFluxRegPtr,
157 a_crsePhiOldPtr, a_crsePhiNewPtr,
158 a_oldTime, a_crseOldTime, a_crseNewTime,
159 a_dt, a_level, a_zeroPhi,
160 a_fluxStartComponent);
203 LevelDataType& a_phiOld,
204 LevelDataType& a_src,
206 FluxRegisterType* a_fineFluxRegPtr,
207 FluxRegisterType* a_crseFluxRegPtr,
208 const LevelDataType* a_crsePhiOldPtr,
209 const LevelDataType* a_crsePhiNewPtr,
215 bool a_zeroPhi =
true,
216 bool a_rhsAlreadyKappaWeighted =
false)
222 if (!this->
m_ops[a_level]->isTimeDependent())
227 LevelDataType phiNew;
229 this->
m_ops[a_level]->create(phiNew, a_phiOld);
230 this->
m_ops[a_level]->setToZero(phiNew);
237 a_fineFluxRegPtr, a_crseFluxRegPtr,
238 a_crsePhiOldPtr, a_crsePhiNewPtr,
239 a_oldTime, a_crseOldTime,
240 a_crseNewTime, a_dt, a_level, a_zeroPhi, a_rhsAlreadyKappaWeighted);
243 this->
m_ops[a_level]->incr(phiNew, a_phiOld, -1.0);
244 this->
m_ops[a_level]->scale(phiNew, 1.0/a_dt);
247 this->
m_ops[a_level]->diagonalScale(phiNew,
false);
250 this->
m_ops[a_level]->incr(phiNew, a_src, -1.0);
253 this->
m_ops[a_level]->
assign(a_diffusiveTerm, phiNew);
264 LevelDataType phidadt, aOld, aNew, rhs;
265 this->
m_ops[a_level]->create(phidadt, a_phiOld);
266 this->
m_ops[a_level]->create(aOld, a_phiOld);
267 this->
m_ops[a_level]->create(aNew, a_phiOld);
268 this->
m_ops[a_level]->create(rhs, a_phiOld);
269 for (
DataIterator dit = a_phiOld.disjointBoxLayout().dataIterator(); dit.
ok(); ++dit)
272 this->
m_ops[a_level]->setTime(a_oldTime, 0.0, a_dt);
273 aOld[dit()].setVal(1.);
274 this->
m_ops[a_level]->diagonalScale(aOld);
275 this->
m_ops[a_level]->setTime(a_oldTime, 1.0, a_dt);
276 aNew[dit()].setVal(1.);
277 this->
m_ops[a_level]->diagonalScale(aNew);
280 phidadt[dit()].axby(aNew[dit()], aOld[dit()], 1.0/a_dt, -1.0/a_dt);
281 phidadt[dit()] *= a_phiOld[dit()];
285 rhs[dit()].axby(a_src[dit()], phidadt[dit()], 1.0, -1.0);
289 LevelDataType phiNew;
290 this->
m_ops[a_level]->create(phiNew, a_phiOld);
291 this->
m_ops[a_level]->setToZero(phiNew);
297 a_fineFluxRegPtr, a_crseFluxRegPtr,
298 a_crsePhiOldPtr, a_crsePhiNewPtr,
299 a_oldTime, a_crseOldTime,
300 a_crseNewTime, a_dt, a_level, a_zeroPhi);
306 for (
DataIterator dit = a_phiOld.disjointBoxLayout().dataIterator(); dit.
ok(); ++dit)
308 aNew[dit()] *= phiNew[dit()];
309 aOld[dit()] *= a_phiOld[dit()];
310 a_diffusiveTerm[dit()].axby(aNew[dit()], aOld[dit()], 1.0/a_dt, -1.0/a_dt);
311 a_diffusiveTerm[dit()] -= a_src[dit()];
341 LevelDataType& a_phiOld,
342 LevelDataType& a_src,
344 FluxRegisterType* a_fineFluxRegPtr,
345 FluxRegisterType* a_crseFluxRegPtr,
346 const LevelDataType* a_crsePhiOldPtr,
347 const LevelDataType* a_crsePhiNewPtr,
353 bool a_zeroPhi =
true,
354 int a_fluxStartComponent = 0)
358 int ncomp = a_phiNew.nComp();
360 Interval intervFlux(a_fluxStartComponent, a_fluxStartComponent + ncomp-1);
364 CH_assert((a_level == 0) || (a_crsePhiOldPtr != NULL));
365 CH_assert((a_level == 0) || (a_crsePhiNewPtr != NULL));
366 CH_assert(a_crseNewTime >= a_crseOldTime);
369 LevelDataType rhst, srct, phis;
370 this->
m_ops[a_level]->create(rhst, a_src);
371 this->
m_ops[a_level]->create(srct, a_phiNew);
372 this->
m_ops[a_level]->create(phis, a_phiNew);
374 this->
m_ops[a_level]->setToZero(srct);
375 this->
m_ops[a_level]->setToZero(rhst);
377 this->
m_ops[a_level]->incr(srct, a_src, a_dt);
382 this->
m_ops[a_level]->setToZero(phis);
383 this->
m_ops[a_level]->incr(phis, a_phiNew, 1.0);
387 this->
m_ops[a_level]->divideByIdentityCoef(srct);
389 LevelDataType coarseData;
391 if ((a_crsePhiOldPtr != NULL) && (a_level > 0))
393 this->
m_ops[a_level-1]->create(coarseData, *a_crsePhiOldPtr);
399 this->
applyHelm(rhst, srct, NULL, a_level, m_mu4, a_dt,
true);
400 this->
incrementFlux(a_flux, srct, a_level, m_mu4, a_dt, -1.0,
true);
405 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
406 a_oldTime, a_crseOldTime, a_crseNewTime, a_level-1);
411 this->
applyHelm(a_phiNew, a_phiOld, &coarseData, a_level, m_mu3, a_dt,
true);
412 this->
incrementFlux(a_flux, a_phiOld, a_level, m_mu3, a_dt, -1.,
false);
415 this->
m_ops[a_level]->incr(rhst, a_phiNew, 1.0);
421 Real intermediateTime = a_oldTime + (1.0-
m_r1)*a_dt;
423 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
424 intermediateTime, a_crseOldTime, a_crseNewTime, a_level-1);
430 this->
m_ops[a_level]->setToZero(a_phiNew);
431 this->
m_ops[a_level]->incr(a_phiNew, phis, 1.0);
436 this->
solveHelm(a_phiNew, coarseData, rhst, a_level, m_mu2, a_dt, a_zeroPhi);
437 this->
incrementFlux(a_flux, a_phiNew, a_level, m_mu2, a_dt, -1.0,
false);
446 Real newTime = a_oldTime + a_dt;
447 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
448 newTime, a_crseOldTime, a_crseNewTime, a_level-1);
453 this->
m_ops[a_level]->diagonalScale(rhst,
true);
458 this->
m_ops[a_level]->setToZero(a_phiNew);
459 this->
m_ops[a_level]->incr(a_phiNew, phis, 1.0);
463 this->
solveHelm(a_phiNew, coarseData, rhst, a_level, m_mu1, a_dt, a_zeroPhi);
464 this->
incrementFlux(a_flux, a_phiNew, a_level, m_mu1, a_dt, -1.0,
false);
469 if ((a_fineFluxRegPtr != NULL) && (a_level < this->
m_grids.
size()-1))
474 FluxDataType& thisFlux = a_flux[dit];
475 for (
int dir=0; dir<
SpaceDim; ++dir)
477 a_fineFluxRegPtr->incrementCoarse(thisFlux[dir],
486 if ((a_crseFluxRegPtr != NULL) && (a_level > 0))
492 FluxDataType& thisFlux = a_flux[dit];
493 for (
int dir=0; dir<
SpaceDim; ++dir)
495 a_crseFluxRegPtr->incrementFine(thisFlux[dir], fluxMult, dit(),
509 LevelDataType& a_phiOld,
510 LevelDataType& a_src,
512 FluxRegisterType* a_fineFluxRegPtr,
513 FluxRegisterType* a_crseFluxRegPtr,
514 const LevelDataType* a_crsePhiOldPtr,
515 const LevelDataType* a_crsePhiNewPtr,
521 bool a_zeroPhi =
true,
522 int a_fluxStartComponent = 0)
524 int ncomp = a_phiNew.nComp();
526 Interval intervFlux(a_fluxStartComponent, a_fluxStartComponent + ncomp-1);
530 CH_assert((a_level == 0) || (a_crsePhiOldPtr != NULL));
531 CH_assert((a_level == 0) || (a_crsePhiNewPtr != NULL));
532 CH_assert(a_crseNewTime >= a_crseOldTime);
535 LevelDataType rhst, srct, phis;
536 this->
m_ops[a_level]->create(rhst, a_src);
537 this->
m_ops[a_level]->create(srct, a_phiNew);
538 this->
m_ops[a_level]->create(phis, a_phiNew);
540 this->
m_ops[a_level]->setToZero(srct);
541 this->
m_ops[a_level]->setToZero(rhst);
542 this->
m_ops[a_level]->incr(srct, a_src, 1.0);
547 this->
m_ops[a_level]->setToZero(phis);
548 this->
m_ops[a_level]->incr(phis, a_phiNew, 1.0);
570 this->
m_ops[a_level]->setTime(a_oldTime, 0.5, a_dt);
574 this->
m_ops[a_level]->divideByIdentityCoef(srct);
577 LevelDataType coarseData;
578 if ((a_crsePhiOldPtr != NULL) && (a_level > 0))
580 this->
m_ops[a_level-1]->create(coarseData, *a_crsePhiOldPtr);
589 this->
applyHelm(rhst, srct, NULL, a_level, m_mu4, a_dt,
true);
590 this->
incrementFlux(a_flux, srct, a_level, a_dt*m_mu4, a_dt, -1.0,
true);
602 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
603 a_oldTime, a_crseOldTime, a_crseNewTime, a_level-1);
607 this->
m_ops[a_level]->setTime(a_oldTime, 0.0, a_dt);
614 this->
applyHelm(a_phiNew, a_phiOld, &coarseData, a_level, m_mu3, a_dt,
false);
615 this->
incrementFlux(a_flux, a_phiOld, a_level, m_mu3, a_dt, -1.,
false);
619 this->
m_ops[a_level]->divideByIdentityCoef(a_phiNew);
623 this->
m_ops[a_level]->incr(rhst, a_phiNew, 1.0);
635 Real intermediateTime = a_oldTime + (1.0-
m_r1)*a_dt;
637 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
638 intermediateTime, a_crseOldTime, a_crseNewTime, a_level-1);
644 this->
m_ops[a_level]->setToZero(a_phiNew);
645 this->
m_ops[a_level]->incr(a_phiNew, phis, 1.0);
650 this->
m_ops[a_level]->setTime(a_oldTime, 1.0 - m_r1, a_dt);
654 this->
m_ops[a_level]->diagonalScale(rhst,
false);
658 this->
solveHelm(a_phiNew, coarseData, rhst, a_level, m_mu2, a_dt, a_zeroPhi);
659 this->
incrementFlux(a_flux, a_phiNew, a_level, m_mu2, a_dt, -1.0,
false);
672 Real newTime = a_oldTime + a_dt;
673 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
674 newTime, a_crseOldTime, a_crseNewTime, a_level-1);
678 this->
m_ops[a_level]->setTime(a_oldTime, 1.0, a_dt);
682 this->
m_ops[a_level]->diagonalScale(rhst);
687 this->
m_ops[a_level]->setToZero(a_phiNew);
688 this->
m_ops[a_level]->incr(a_phiNew, phis, 1.0);
693 this->
solveHelm(a_phiNew, coarseData, rhst, a_level, m_mu1, a_dt, a_zeroPhi);
694 this->
incrementFlux(a_flux, a_phiNew, a_level, m_mu1, a_dt, -1.0,
false);
699 if ((a_fineFluxRegPtr != NULL) && (a_level < this->
m_grids.
size()-1))
704 FluxDataType& thisFlux = a_flux[dit];
705 for (
int dir=0; dir<
SpaceDim; ++dir)
707 a_fineFluxRegPtr->incrementCoarse(thisFlux[dir],
716 if ((a_crseFluxRegPtr != NULL) && (a_level > 0))
722 FluxDataType& thisFlux = a_flux[dit];
723 for (
int dir=0; dir<
SpaceDim; ++dir)
725 a_crseFluxRegPtr->incrementFine(thisFlux[dir], fluxMult, dit(),
744 #include "NamespaceFooter.H" Real m_mu1
Definition: BaseLevelTGA.H:334
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
Definition: BaseLevelHeatSolver.H:44
void updateSolnWithTimeIndependentOp(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, int a_fluxStartComponent=0)
Definition: BaseLevelTGA.H:340
virtual void setSourceGhostCells(LevelDataType &a_src, const DisjointBoxLayout &a_dbl, int a_level)=0
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: BaseLevelTGA.H:202
void updateSolnWithTimeDependentOp(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, int a_fluxStartComponent=0)
Definition: BaseLevelTGA.H:508
virtual bool ok() const
return true if this iterator is still in its Layout
Definition: LayoutIterator.H:110
Definition: DataIterator.H:140
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
const int SpaceDim
Definition: SPACE.H:39
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: BaseLevelTGA.H:123
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:511
Definition: BoxLayoutData.H:136
Vector< T > & assign(const T &inval)
assign a scalar to every element of the vector
Definition: Vector.H:138
Real m_mu2
Definition: BaseLevelTGA.H:334
double Real
Definition: REAL.H:33
Definition: BaseLevelTGA.H:45
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:31
size_t size() const
Definition: Vector.H:177
Real m_mu4
Definition: BaseLevelTGA.H:334
virtual ~BaseLevelTGA()
Destructor, called after destructors of BaseLevelTGA subclasses.
Definition: BaseLevelTGA.H:87
BaseLevelTGA(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: BaseLevelTGA.H:60
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
Real m_mu3
Definition: BaseLevelTGA.H:334
BaseLevelTGA & operator=(const BaseLevelTGA &)
Definition: AMRMultiGrid.H:231
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
Real m_r1
Definition: BaseLevelTGA.H:334