Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ private:
void setSpongeRefFromSounding (bool restarting);

// a wrapper for estTimeStep()
void ComputeDt (int step = -1);
void ComputeDt (int step = -1, double cur_time_d = 0.0);

// get plotfile name
[[nodiscard]] std::string PlotFileName (int lev) const;
Expand Down
10 changes: 6 additions & 4 deletions Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ ERF::Evolve ()
//
// cur_time = t_new is elapsed time, not total time
// stop_time is total time
//
Real cur_time = t_new[0];
// Tracked in double to avoid float32 drift over many timesteps in single-precision builds.
double cur_time = static_cast<double>(t_new[0]);

// Take one coarse timestep by calling timeStep -- which recursively calls timeStep
// for finer levels (with or without subcycling)
Expand All @@ -622,7 +622,7 @@ ERF::Evolve ()
}
Print() << "\nCoarse STEP " << step+1 << " starts ..." << std::endl;

ComputeDt(step);
ComputeDt(step, cur_time);

// 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 @@ -657,7 +657,9 @@ ERF::Evolve ()
int iteration = 1;
timeStep(0, cur_time, iteration);

cur_time += dt[0];
cur_time += static_cast<double>(dt[0]);
// Sync t_new[0] from accurate double to prevent float32 accumulation drift in SP builds.
t_new[0] = static_cast<Real>(cur_time);

Print() << "Coarse STEP " << step+1 << " ends." << " TIME = " << cur_time
<< " DT = " << dt[0] << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions 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 (int step)
ERF::ComputeDt (int step, double cur_time_d)
{
Vector<Real> dt_tmp(finest_level+1);

Expand Down Expand Up @@ -40,8 +40,8 @@ ERF::ComputeDt (int step)
// so we must add start_time to t_new
//
const Real eps = Real(1.e-3)*dt_0;
if (t_new[0] + dt_0 > (stop_time - start_time) - eps) {
dt_0 = (stop_time - start_time) - t_new[0];
if (cur_time_d + static_cast<double>(dt_0) > static_cast<double>(stop_time - start_time) - static_cast<double>(eps)) {
dt_0 = static_cast<Real>(static_cast<double>(stop_time - start_time) - cur_time_d);
}

dt[0] = dt_0;
Expand Down
Loading