13 #include "LevelPluto.H"
14 #include "BoxIterator.H"
21 #include "NamespaceHeader.H"
24 LevelPluto::LevelPluto()
34 LevelPluto::~LevelPluto()
36 if (m_patchPluto != NULL)
43 void LevelPluto::define(
const DisjointBoxLayout& a_thisDisjointBoxLayout,
44 const DisjointBoxLayout& a_coarserDisjointBoxLayout,
45 const ProblemDomain& a_domain,
46 const int& a_refineCoarse,
49 const PatchPluto* a_patchPlutoFactory,
50 const bool& a_hasCoarser,
51 const bool& a_hasFiner)
53 CH_TIME(
"LevelPluto::define");
56 CH_assert(a_refineCoarse > 0);
57 CH_assert(a_dx > 0.0);
60 m_grids = a_thisDisjointBoxLayout;
66 m_refineCoarse = a_refineCoarse;
67 m_hasCoarser = a_hasCoarser;
68 m_hasFiner = a_hasFiner;
71 if (m_patchPluto != NULL)
79 m_patchPluto = a_patchPlutoFactory->new_patchPluto();
80 m_patchPluto->define(m_domain,m_dx,m_level,m_numGhost);
86 m_numCons = m_patchPluto->numConserved();
87 m_numFluxes = m_patchPluto->numFluxes();
89 m_exchangeCopier.exchangeDefine(a_thisDisjointBoxLayout,
90 m_numGhost*IntVect::Unit);
93 Interval UInterval(0,m_numCons-1);
95 #if (TIME_STEPPING == RK2)
98 m_Flags.define(m_grids,1,m_numGhost*IntVect::Unit);
99 m_Utmp.define(m_grids,m_numCons,m_numGhost*IntVect::Unit);
104 CH_TIME(
"setup::Udefine");
105 m_U.define(m_grids,m_numCons,m_numGhost*IntVect::Unit);
111 m_patcher.define(a_thisDisjointBoxLayout,
112 a_coarserDisjointBoxLayout,
114 coarsen(a_domain,a_refineCoarse),
129 Real LevelPluto::step(LevelData<FArrayBox>& a_U,
130 LevelData<FArrayBox> a_flux[CH_SPACEDIM],
131 LevelFluxRegister& a_finerFluxRegister,
132 LevelFluxRegister& a_coarserFluxRegister,
133 LevelData<FArrayBox>& a_split_tags,
134 const LevelData<FArrayBox>& a_UCoarseOld,
135 const Real& a_TCoarseOld,
136 const LevelData<FArrayBox>& a_UCoarseNew,
137 const Real& a_TCoarseNew,
142 CH_TIMERS(
"LevelPluto::step");
144 CH_TIMER(
"LevelPluto::step::setup" ,timeSetup);
145 CH_TIMER(
"LevelPluto::step::update" ,timeUpdate);
146 CH_TIMER(
"LevelPluto::step::reflux" ,timeReflux);
147 CH_TIMER(
"LevelPluto::step::conclude",timeConclude);
150 CH_assert(m_isDefined);
157 a_finerFluxRegister.setToZero();
161 Interval UInterval(0,m_numCons-1);
164 CH_TIME(
"setup::localU");
165 for (DataIterator dit = m_U.dataIterator(); dit.ok(); ++dit)
167 m_U[dit].setVal(0.0);
168 m_U[dit].copy(a_U[dit]);
171 m_U.exchange(m_exchangeCopier);
178 Real
alpha = (a_time - a_TCoarseOld) / (a_TCoarseNew - a_TCoarseOld);
182 Real
eps = 0.04 * a_dt / m_refineCoarse;
184 if (Abs(alpha) <
eps) alpha = 0.0;
185 if (Abs(1.0-alpha) <
eps) alpha = 1.0;
190 MayDay::Error(
"LevelPluto::step: alpha < 0.0");
196 MayDay::Error(
"LevelPluto::step: alpha > 1.0");
201 m_patcher.fillInterp(m_U,
209 m_patchPluto->setCurrentTime(a_time);
212 Real maxWaveSpeed = 1.e-12;
213 Real minDtCool = 1.e38;
221 glm_ch = g_coeff_dl_min*m_dx/(a_dt + 1.e-16)*a_cfl;
230 for (DataIterator dit = m_grids.dataIterator(); dit.ok(); ++dit){
231 CH_START(timeUpdate);
234 Box curBox = m_grids.get(dit());
237 FArrayBox& curU = m_U[dit];
240 #if GEOMETRY != CARTESIAN
241 const FArrayBox& curdV = m_dV[dit()];
243 const FArrayBox curdV;
246 #ifdef SKIP_SPLIT_CELLS
248 FArrayBox& split_tags = a_split_tags[dit];
250 FArrayBox split_tags;
253 #if (TIME_STEPPING == RK2)
255 BaseFab<unsigned char>& flags = m_Flags[dit];
257 FArrayBox& curUtmp = m_Utmp[dit];
259 BaseFab<unsigned char> flags;
268 m_patchPluto->setCurrentBox(curBox);
272 grid = m_structs_grid[dit].getGrid();
293 #if RECONSTRUCTION == PARABOLIC
307 m_patchPluto->advanceStep (curU, curUtmp, curdV, split_tags, flags, flux,
311 maxWaveSpeed = Max(maxWaveSpeed, inv_dt);
313 minDtCool = Min(minDtCool, Dts.
dt_cool/a_cfl);
317 CH_START(timeReflux);
320 for (
int idir = 0; idir < SpaceDim; idir++) {
325 a_finerFluxRegister.incrementCoarse(flux[idir],a_dt,dit(),
326 UInterval, UInterval,idir);
333 a_coarserFluxRegister.incrementFine(flux[idir],a_dt,dit(),
334 UInterval, UInterval,idir);
341 CH_START(timeConclude);
344 CH_TIME(
"conclude::copyU");
347 for(DataIterator dit = m_U.dataIterator(); dit.ok(); ++dit){
348 a_U[dit].copy(m_U[dit]);
353 Real local_dtNew = 1. / maxWaveSpeed;
354 local_dtNew = Min(local_dtNew,minDtCool);
358 CH_TIME(
"conclude::getDt");
360 #if (TIME_STEPPING == RK2) && (COOLING == NO)
363 int result = MPI_Allreduce(&local_dtNew, &dtNew, 1, MPI_CH_REAL,
364 MPI_MIN, Chombo_MPI::comm);
365 if(result != MPI_SUCCESS){
366 MayDay::Error(
"sorry, but I had a communcation error on new dt");
368 #if (TIME_STEPPING == RK2) && (COOLING == NO)
378 CH_STOP(timeConclude);
384 void LevelPluto::setGridLevel()
387 CH_TIME(
"LevelPluto::setGrid");
389 m_structs_grid.define(m_grids);
391 #if GEOMETRY != CARTESIAN
392 m_dV.define(m_grids,CHOMBO_NDV,m_numGhost*IntVect::Unit);
395 Real dlMinLoc = 1.e30;
397 for (DataIterator dit = m_grids.dataIterator(); dit.ok(); ++dit)
400 Box curBox = m_grids.get(dit());
401 struct GRID* grid = m_structs_grid[dit].getGrid();
403 #if GEOMETRY != CARTESIAN
404 FArrayBox& curdV = m_dV[dit()];
409 m_patchPluto->setGrid(curBox, grid, curdV);
411 for (
int idir = 0; idir < SpaceDim; idir++) dlMinLoc = Min(dlMinLoc,grid[idir].
dl_min);
414 #if (GEOMETRY == CARTESIAN) || (GEOMETRY == CYLINDRICAL)
417 m_dl_min =
MIN(m_dl_min,m_dx*g_x2stretch); ,
418 m_dl_min =
MIN(m_dl_min,m_dx*g_x3stretch); )
423 int result = MPI_Allreduce(&dlMinLoc, &dlMin, 1, MPI_CH_REAL,
424 MPI_MIN, Chombo_MPI::comm);
425 if(result != MPI_SUCCESS){
426 MayDay::Error(
"sorry, but I had a communcation error on dlMin");
437 #if GEOMETRY != CARTESIAN
438 const LevelData<FArrayBox>& LevelPluto::getdV()
const
444 Real LevelPluto::getDlMin()
447 CH_TIME(
"LevelPluto::getDlMin");
449 return m_dl_min / m_dx;
455 #include "NamespaceFooter.H"
void PPM_CoefficientsSet(Grid *grid)
long int NX1
Number of interior zones in the X1 directions (boundaries excluded) for the local processor...
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
int g_intStage
Gives the current integration stage of the time stepping method (predictor = 0, 1st corrector = 1...
int g_maxRiemannIter
Maximum number of iterations for iterative Riemann Solver.
double g_dt
The current integration time step.
int lend
Local end index for the local array.
int lbeg
Local start index for the local array.
double * cmax
Maximum signal velocity for hyperbolic eqns.
double inv_dtp
Inverse of diffusion (parabolic) time step .
double inv_dta
Inverse of advection (hyperbolic) time step, .
double dt_cool
Cooling time step.
long int NX2
Number of interior zones in the X2 directions (boundaries excluded) for the local processor...
void PLM_CoefficientsSet(Grid *grid)
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
long int IEND
Upper grid index of the computational domain in the the X1 direction for the local processor...
double dl_min
minimum cell length (e.g.
double cfl
Courant number for advection.
#define ARRAY_1D(nx, type)
D_EXPAND(tot/[n]=(double) grid[IDIR].np_int_glob;, tot/[n]=(double) grid[JDIR].np_int_glob;, tot/[n]=(double) grid[KDIR].np_int_glob;)
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
double g_time
The current integration time.
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
int np_tot
Total number of points in the local domain (boundaries included).
long int KEND
Upper grid index of the computational domain in the the X3 direction for the local processor...
double glm_ch
The propagation speed of divergence error.
long int JBEG
Lower grid index of the computational domain in the the X2 direction for the local processor...
long int JEND
Upper grid index of the computational domain in the the X2 direction for the local processor...
long int NX1_TOT
Total number of zones in the X1 direction (boundaries included) for the local processor.
long int NX3
Number of interior zones in the X3 directions (boundaries excluded) for the local processor...
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
int np_int
Total number of points in the local domain (boundaries excluded).