Skip to content

Commit 4ca9088

Browse files
committed
finish dt_ref_ratio stuff
1 parent a3b2be7 commit 4ca9088

File tree

3 files changed

+38
-36
lines changed

3 files changed

+38
-36
lines changed

Docs/sphinx_doc/Inputs.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@ List of Parameters
145145
| | subsequent | | |
146146
| | levels | | |
147147
+-----------------------------------+--------------------+-----------------+-------------+
148-
| **amr.dt_ref_ratio** | ratio of coarse | Integer >= 1 | same as |
149-
| | to fine grid | (one per level) | ref_ratio |
150-
| | time steps between | | |
151-
| | subsequent | | |
152-
| | levels | | |
153-
+-----------------------------------+--------------------+-----------------+-------------+
154148
| **amr.regrid_int** | how often to | Integer > 0 | -1 |
155149
| | regrid | (if negative, | |
156150
| | | no regridding) | |
@@ -513,6 +507,12 @@ List of Parameters
513507
| **erf.dt_max_initial** | maximum initial | Real > 0 | 1.0 |
514508
| | timestep | | |
515509
+----------------------------+----------------------+----------------+---------------------+
510+
| **erf.dt_ref_ratio** | ratio of coarse | Integer >= 1 | same as |
511+
| | to fine grid | (one per level)| maximum over |
512+
| | time steps between | | directions of |
513+
| | subsequent | | ref_ratio |
514+
| | levels | | |
515+
+----------------------------+----------------------+----------------+---------------------+
516516

517517
Notes
518518
-----------------

Source/ERF.cpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -286,33 +286,6 @@ ERF::ERF_shared ()
286286
// No valid BoxArray and DistributionMapping have been defined.
287287
// But the arrays for them have been resized.
288288

289-
istep.resize(nlevs_max, 0);
290-
nsubsteps.resize(nlevs_max, 1);
291-
// This is the default
292-
for (int lev = 1; lev <= max_level; ++lev) {
293-
nsubsteps[lev] = MaxRefRatio(lev-1);
294-
}
295-
296-
if (max_level > 0) {
297-
ParmParse pp("erf");
298-
int count = pp.countval("dt_ref_ratio");
299-
if (count > 0) {
300-
Vector<int> nsub;
301-
nsub.resize(nlevs_max, 0);
302-
if (count == 1) {
303-
pp.queryarr("dt_ref_ratio", nsub, 0, 1);
304-
for (int lev = 1; lev <= max_level; ++lev) {
305-
nsubsteps[lev] = nsub[0];
306-
}
307-
} else {
308-
pp.queryarr("dt_ref_ratio", nsub, 0, max_level);
309-
for (int lev = 1; lev <= max_level; ++lev) {
310-
nsubsteps[lev] = nsub[lev-1];
311-
}
312-
}
313-
}
314-
}
315-
316289
t_new.resize(nlevs_max, 0.0);
317290
t_old.resize(nlevs_max, -1.e100);
318291
dt.resize(nlevs_max, std::min(1.e100,dt_max_initial));
@@ -2120,10 +2093,39 @@ ERF::ReadParameters ()
21202093
pp.query("fixed_dt", fixed_dt[0]);
21212094
pp.query("fixed_fast_dt", fixed_fast_dt[0]);
21222095

2096+
int nlevs_max = max_level + 1;
2097+
istep.resize(nlevs_max, 0);
2098+
nsubsteps.resize(nlevs_max, 1);
2099+
// This is the default
2100+
for (int lev = 1; lev <= max_level; ++lev) {
2101+
nsubsteps[lev] = MaxRefRatio(lev-1);
2102+
}
2103+
2104+
if (max_level > 0) {
2105+
ParmParse pp("erf");
2106+
int count = pp.countval("dt_ref_ratio");
2107+
if (count > 0) {
2108+
Vector<int> nsub;
2109+
nsub.resize(nlevs_max, 0);
2110+
if (count == 1) {
2111+
pp.queryarr("dt_ref_ratio", nsub, 0, 1);
2112+
for (int lev = 1; lev <= max_level; ++lev) {
2113+
nsubsteps[lev] = nsub[0];
2114+
}
2115+
} else {
2116+
pp.queryarr("dt_ref_ratio", nsub, 0, max_level);
2117+
for (int lev = 1; lev <= max_level; ++lev) {
2118+
nsubsteps[lev] = nsub[lev-1];
2119+
}
2120+
}
2121+
}
2122+
}
2123+
2124+
// Make sure we do this after we have defined nsubsteps above
21232125
for (int lev = 1; lev <= max_level; lev++)
21242126
{
2125-
fixed_dt[lev] = fixed_dt[lev-1] / static_cast<Real>(MaxRefRatio(lev-1));
2126-
fixed_fast_dt[lev] = fixed_fast_dt[lev-1] / static_cast<Real>(MaxRefRatio(lev-1));
2127+
fixed_dt[lev] = fixed_dt[lev-1] / static_cast<Real>(nsubsteps[lev]);
2128+
fixed_fast_dt[lev] = fixed_fast_dt[lev-1] / static_cast<Real>(nsubsteps[lev]);
21272129
}
21282130

21292131
pp.query("fixed_mri_dt_ratio", fixed_mri_dt_ratio);

Source/TimeIntegration/ERF_TimeStep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ ERF::timeStep (int lev, Real time, int /*iteration*/)
147147

148148
// if there are newly created levels, set the time step
149149
for (int k = old_finest+1; k <= finest_level; ++k) {
150-
dt[k] = dt[k-1] / MaxRefRatio(k-1);
150+
dt[k] = dt[k-1] / static_cast<Real>(nsubsteps[k]);
151151
}
152152
} // if
153153
} // lev

0 commit comments

Comments
 (0)