[Common] Restrict the minimum dt in time controller

* Improve output
parent cf66e761
......@@ -79,9 +79,11 @@ public:
/// suggest timestep
inline void suggest_timestep (R suggestion) {
use_dt_suggestion = true;
suggested_dt = suggestion;
dt = std::min(dt,suggested_dt);
if (FloatCmp::lt(suggestion,dt)) {
_log->trace("Adapting time step due to a suggestion: "
"{:.2e} -> {:.2e}", dt, suggestion);
dt = suggestion;
}
}
/// Return current time
inline R getTime () const { return time; }
......@@ -127,14 +129,9 @@ public:
if(time >= tEnd-eps) // Simulation has ended. Do nothing
return true;
dt = std::max(dt,dtmin);
dt = std::min(dt*dtinc,dtmax);
if (use_dt_suggestion)
{
dt = std::min(dt,suggested_dt);
use_dt_suggestion = false;
}
changeTime = tsc.getNextTimeStamp(time);
if(time >= changeTime-eps && time <= changeTime){
// small step to ensure that next time step starts with new BC
......@@ -164,7 +161,10 @@ public:
DUNE_THROW(Exception,"Solver fails at minimal time step");
}
auto failed_dt = dt;
dt = std::max(dt*dtdec,dtmin);
_log->trace("Adapting time step to improve solver: "
"{:.2e} -> {:.2e}", failed_dt, dt);
}
// Calculate new iterations based on adapted time step
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment