Skip to content

Commit

Permalink
Bugfix for adaptive timestepping (#1666)
Browse files Browse the repository at this point in the history
Co-authored-by: Brandon Blakeley <[email protected]>
Co-authored-by: Ann Almgren <[email protected]>
  • Loading branch information
3 people authored Jul 9, 2024
1 parent ded446b commit fdf6c42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ private:
void setSpongeRefFromSounding (bool restarting);

// a wrapper for estTimeStep()
void ComputeDt ();
void ComputeDt (int step = -1);

// get plotfile name
[[nodiscard]] std::string PlotFileName (int lev) const;
Expand Down
8 changes: 4 additions & 4 deletions Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ ERF::Evolve ()
{
Print() << "\nCoarse STEP " << step+1 << " starts ..." << std::endl;

ComputeDt();
ComputeDt(step);

// Make sure we have read enough of the boundary plane data to make it through this timestep
if (input_bndry_planes)
Expand Down Expand Up @@ -1972,7 +1972,7 @@ ERF::Evolve_MB (int MBstep, int max_block_step)

Print() << "\nCoarse STEP " << step+1 << " starts ..." << std::endl;

ComputeDt();
ComputeDt(step);

// Make sure we have read enough of the boundary plane data to make it through this timestep
if (input_bndry_planes)
Expand Down Expand Up @@ -2051,8 +2051,8 @@ ERF::writeNow(const Real cur_time, const Real dt_lev, const int nstep, const int

const Real eps = std::numeric_limits<Real>::epsilon() * Real(10.0) * std::abs(cur_time);

int num_per_old = static_cast<int>(std::round((cur_time-eps-dt_lev) / plot_per));
int num_per_new = static_cast<int>(std::round((cur_time-eps ) / plot_per));
int num_per_old = static_cast<int>(std::floor((cur_time-eps-dt_lev) / plot_per));
int num_per_new = static_cast<int>(std::floor((cur_time-eps ) / plot_per));

// Before using these, however, we must test for the case where we're
// within machine epsilon of the next interval. In that case, increment
Expand Down
6 changes: 5 additions & 1 deletion Source/TimeIntegration/ERF_ComputeTimestep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace amrex;
*
*/
void
ERF::ComputeDt ()
ERF::ComputeDt (int step)
{
Vector<Real> dt_tmp(finest_level+1);

Expand All @@ -25,6 +25,10 @@ ERF::ComputeDt ()
dt_tmp[lev] = amrex::min(dt_tmp[lev], change_max*dt[lev]);
n_factor *= nsubsteps[lev];
dt_0 = amrex::min(dt_0, n_factor*dt_tmp[lev]);
if (step == 0){
dt_0 *= init_shrink;
Print() << "Timestep 0: shrink initial dt by " << init_shrink << std::endl;
}
}

// Limit dt's by the value of stop_time.
Expand Down

0 comments on commit fdf6c42

Please sign in to comment.