11 #ifndef _BASELEVELTGA_H__ 12 #define _BASELEVELTGA_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),
71 Real tgaEpsilon = 1.e-12;
73 tgaEpsilon = sqrt(tgaEpsilon);
75 Real a = 2.0 - sqrt(2.0) - tgaEpsilon;
76 m_mu1 = (a - sqrt( a*a - 4.0*a + 2.0))/2.0 ;
77 m_mu2 = (a + sqrt( a*a - 4.0*a + 2.0))/2.0 ;
81 Real discr = sqrt(a*a - 4.0*a + 2.0);
82 m_r1 = (2.0*a - 1.0)/(a + discr);
123 LevelDataType& a_phiOld,
124 LevelDataType& a_src,
126 FluxRegisterType* a_fineFluxRegPtr,
127 FluxRegisterType* a_crseFluxRegPtr,
128 const LevelDataType* a_crsePhiOldPtr,
129 const LevelDataType* a_crsePhiNewPtr,
135 bool a_zeroPhi =
true,
136 bool a_rhsAlreadyKappaWeighted =
false,
137 int a_fluxStartComponent = 0)
140 if (!this->
m_ops[a_level]->isTimeDependent())
143 a_fineFluxRegPtr, a_crseFluxRegPtr,
144 a_crsePhiOldPtr, a_crsePhiNewPtr,
145 a_oldTime, a_crseOldTime, a_crseNewTime,
146 a_dt, a_level, a_zeroPhi,
147 a_fluxStartComponent);
155 a_fineFluxRegPtr, a_crseFluxRegPtr,
156 a_crsePhiOldPtr, a_crsePhiNewPtr,
157 a_oldTime, a_crseOldTime, a_crseNewTime,
158 a_dt, a_level, a_zeroPhi,
159 a_fluxStartComponent);
202 LevelDataType& a_phiOld,
203 LevelDataType& a_src,
205 FluxRegisterType* a_fineFluxRegPtr,
206 FluxRegisterType* a_crseFluxRegPtr,
207 const LevelDataType* a_crsePhiOldPtr,
208 const LevelDataType* a_crsePhiNewPtr,
214 bool a_zeroPhi =
true,
215 bool a_rhsAlreadyKappaWeighted =
false)
217 CH_TIME(
"BaseLevelTGA::computeDiffusion");
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);
233 this->
m_ops[a_level]->assignLocal(phiNew, a_phiOld);
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]->assignLocal(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);
294 this->
m_ops[a_level]->assignLocal(phiNew, a_phiOld);
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()];
337 LevelDataType& a_phiOld,
338 LevelDataType& a_src,
340 FluxRegisterType* a_fineFluxRegPtr,
341 FluxRegisterType* a_crseFluxRegPtr,
342 const LevelDataType* a_crsePhiOldPtr,
343 const LevelDataType* a_crsePhiNewPtr,
349 bool a_zeroPhi =
true,
350 int a_fluxStartComponent = 0)
352 CH_TIME(
"BaseLevelTGA::updateWithTimeIndependentOp");
355 int ncomp = a_phiNew.nComp();
357 Interval intervFlux(a_fluxStartComponent, a_fluxStartComponent + ncomp-1);
361 CH_assert((a_level == 0) || (a_crsePhiOldPtr != NULL));
362 CH_assert((a_level == 0) || (a_crsePhiNewPtr != NULL));
363 CH_assert(a_crseNewTime >= a_crseOldTime);
366 LevelDataType rhst, srct, phis;
367 this->
m_ops[a_level]->create(rhst, a_src);
368 this->
m_ops[a_level]->create(srct, a_phiNew);
369 this->
m_ops[a_level]->create(phis, a_phiNew);
371 this->
m_ops[a_level]->setToZero(srct);
372 this->
m_ops[a_level]->setToZero(rhst);
374 this->
m_ops[a_level]->incr(srct, a_src, a_dt);
379 this->
m_ops[a_level]->setToZero(phis);
380 this->
m_ops[a_level]->incr(phis, a_phiNew, 1.0);
384 this->
m_ops[a_level]->divideByIdentityCoef(srct);
386 LevelDataType coarseData;
388 if ((a_crsePhiOldPtr != NULL) && (a_level > 0))
390 this->
m_ops[a_level-1]->create(coarseData, *a_crsePhiOldPtr);
396 this->
applyHelm(rhst, srct, NULL, a_level, m_mu4, a_dt,
true);
397 this->
incrementFlux(a_flux, srct, a_level, m_mu4, a_dt, -1.0,
true);
402 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
403 a_oldTime, a_crseOldTime, a_crseNewTime, a_level-1);
408 this->
applyHelm(a_phiNew, a_phiOld, &coarseData, a_level, m_mu3, a_dt,
false);
409 this->
incrementFlux(a_flux, a_phiOld, a_level, m_mu3, a_dt, -1.,
false);
412 this->
m_ops[a_level]->incr(rhst, a_phiNew, 1.0);
418 Real intermediateTime = a_oldTime + (1.0-
m_r1)*a_dt;
420 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
421 intermediateTime, a_crseOldTime, a_crseNewTime, a_level-1);
427 this->
m_ops[a_level]->setToZero(a_phiNew);
428 this->
m_ops[a_level]->incr(a_phiNew, phis, 1.0);
433 this->
solveHelm(a_phiNew, coarseData, rhst, a_level, m_mu2, a_dt, a_zeroPhi);
434 this->
incrementFlux(a_flux, a_phiNew, a_level, m_mu2, a_dt, -1.0,
false);
437 this->
m_ops[a_level]->assignLocal(rhst, a_phiNew);
442 Real newTime = a_oldTime + a_dt;
443 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
444 newTime, a_crseOldTime, a_crseNewTime, a_level-1);
449 this->
m_ops[a_level]->diagonalScale(rhst,
true);
454 this->
m_ops[a_level]->setToZero(a_phiNew);
455 this->
m_ops[a_level]->incr(a_phiNew, phis, 1.0);
459 this->
solveHelm(a_phiNew, coarseData, rhst, a_level, m_mu1, a_dt, a_zeroPhi);
460 this->
incrementFlux(a_flux, a_phiNew, a_level, m_mu1, a_dt, -1.0,
false);
465 if ((a_fineFluxRegPtr != NULL) && (a_level < this->
m_grids.
size()-1))
470 FluxDataType& thisFlux = a_flux[dit];
471 for (
int dir=0; dir<
SpaceDim; ++dir)
473 a_fineFluxRegPtr->incrementCoarse(thisFlux[dir],
482 if ((a_crseFluxRegPtr != NULL) && (a_level > 0))
488 FluxDataType& thisFlux = a_flux[dit];
489 for (
int dir=0; dir<
SpaceDim; ++dir)
491 a_crseFluxRegPtr->incrementFine(thisFlux[dir], fluxMult, dit(),
504 LevelDataType& a_phiOld,
505 LevelDataType& a_src,
507 FluxRegisterType* a_fineFluxRegPtr,
508 FluxRegisterType* a_crseFluxRegPtr,
509 const LevelDataType* a_crsePhiOldPtr,
510 const LevelDataType* a_crsePhiNewPtr,
516 bool a_zeroPhi =
true,
517 int a_fluxStartComponent = 0)
519 CH_TIME(
"BaseLevelTGA::updateWithTimeDependentOp");
520 int ncomp = a_phiNew.nComp();
522 Interval intervFlux(a_fluxStartComponent, a_fluxStartComponent + ncomp-1);
526 CH_assert((a_level == 0) || (a_crsePhiOldPtr != NULL));
527 CH_assert((a_level == 0) || (a_crsePhiNewPtr != NULL));
528 CH_assert(a_crseNewTime >= a_crseOldTime);
531 LevelDataType rhst, srct, phis;
532 this->
m_ops[a_level]->create(rhst, a_src);
533 this->
m_ops[a_level]->create(srct, a_phiNew);
534 this->
m_ops[a_level]->create(phis, a_phiNew);
536 this->
m_ops[a_level]->setToZero(srct);
537 this->
m_ops[a_level]->setToZero(rhst);
538 this->
m_ops[a_level]->incr(srct, a_src, 1.0);
543 this->
m_ops[a_level]->setToZero(phis);
544 this->
m_ops[a_level]->incr(phis, a_phiNew, 1.0);
566 this->
m_ops[a_level]->setTime(a_oldTime, 0.5, a_dt);
570 this->
m_ops[a_level]->divideByIdentityCoef(srct);
573 LevelDataType coarseData;
574 if ((a_crsePhiOldPtr != NULL) && (a_level > 0))
576 this->
m_ops[a_level-1]->create(coarseData, *a_crsePhiOldPtr);
585 this->
applyHelm(rhst, srct, NULL, a_level, m_mu4, a_dt,
true);
586 this->
incrementFlux(a_flux, srct, a_level, a_dt*m_mu4, a_dt, -1.0,
true);
598 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
599 a_oldTime, a_crseOldTime, a_crseNewTime, a_level-1);
603 this->
m_ops[a_level]->setTime(a_oldTime, 0.0, a_dt);
610 this->
applyHelm(a_phiNew, a_phiOld, &coarseData, a_level, m_mu3, a_dt,
false);
611 this->
incrementFlux(a_flux, a_phiOld, a_level, m_mu3, a_dt, -1.,
false);
615 this->
m_ops[a_level]->divideByIdentityCoef(a_phiNew);
619 this->
m_ops[a_level]->incr(rhst, a_phiNew, 1.0);
631 Real intermediateTime = a_oldTime + (1.0-
m_r1)*a_dt;
633 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
634 intermediateTime, a_crseOldTime, a_crseNewTime, a_level-1);
640 this->
m_ops[a_level]->setToZero(a_phiNew);
641 this->
m_ops[a_level]->incr(a_phiNew, phis, 1.0);
646 this->
m_ops[a_level]->setTime(a_oldTime, 1.0 - m_r1, a_dt);
650 this->
m_ops[a_level]->diagonalScale(rhst,
false);
654 this->
solveHelm(a_phiNew, coarseData, rhst, a_level, m_mu2, a_dt, a_zeroPhi);
655 this->
incrementFlux(a_flux, a_phiNew, a_level, m_mu2, a_dt, -1.0,
false);
658 this->
m_ops[a_level]->assignLocal(rhst, a_phiNew);
668 Real newTime = a_oldTime + a_dt;
669 this->
timeInterp(coarseData, *a_crsePhiOldPtr, *a_crsePhiNewPtr,
670 newTime, a_crseOldTime, a_crseNewTime, a_level-1);
674 this->
m_ops[a_level]->setTime(a_oldTime, 1.0, a_dt);
678 this->
m_ops[a_level]->diagonalScale(rhst);
683 this->
m_ops[a_level]->setToZero(a_phiNew);
684 this->
m_ops[a_level]->incr(a_phiNew, phis, 1.0);
689 this->
solveHelm(a_phiNew, coarseData, rhst, a_level, m_mu1, a_dt, a_zeroPhi);
690 this->
incrementFlux(a_flux, a_phiNew, a_level, m_mu1, a_dt, -1.0,
false);
695 if ((a_fineFluxRegPtr != NULL) && (a_level < this->
m_grids.
size()-1))
700 FluxDataType& thisFlux = a_flux[dit];
701 for (
int dir=0; dir<
SpaceDim; ++dir)
703 a_fineFluxRegPtr->incrementCoarse(thisFlux[dir],
712 if ((a_crseFluxRegPtr != NULL) && (a_level > 0))
718 FluxDataType& thisFlux = a_flux[dit];
719 for (
int dir=0; dir<
SpaceDim; ++dir)
721 a_crseFluxRegPtr->incrementFine(thisFlux[dir], fluxMult, dit(),
738 #include "NamespaceFooter.H" Real m_mu1
Definition: BaseLevelTGA.H:330
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
Definition: BaseLevelHeatSolver.H:43
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:336
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:201
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:503
virtual bool ok() const
return true if this iterator is still in its Layout
Definition: LayoutIterator.H:117
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: BaseLevelTGA.H:122
#define CH_TIME(name)
Definition: CH_Timer.H:82
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
Real m_mu2
Definition: BaseLevelTGA.H:330
double Real
Definition: REAL.H:33
Definition: BaseLevelTGA.H:44
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
size_t size() const
Definition: Vector.H:192
Real m_mu4
Definition: BaseLevelTGA.H:330
virtual ~BaseLevelTGA()
Destructor, called after destructors of BaseLevelTGA subclasses.
Definition: BaseLevelTGA.H:86
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:59
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
Real m_mu3
Definition: BaseLevelTGA.H:330
BaseLevelTGA & operator=(const BaseLevelTGA &)
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
Real m_r1
Definition: BaseLevelTGA.H:330