Commit b76f127f authored by wenqing's avatar wenqing

[dt] Corrected dt for IterationNumberBasedTimeStepping when a time step is rejected.

parent 8becbac6
......@@ -57,10 +57,15 @@ std::tuple<bool, double> IterationNumberBasedTimeStepping::next(
{
_iter_times = number_iterations;
if (_previous_time_step_accepted)
{
_ts_prev = _ts_current;
}
// confirm current time and move to the next if accepted
if (accepted())
{
_ts_prev = _ts_current;
_previous_time_step_accepted = true;
return std::make_tuple(true, getNextTimeStepSize());
}
else
......@@ -83,6 +88,9 @@ std::tuple<bool, double> IterationNumberBasedTimeStepping::next(
_ts_prev = // essentially equal to _ts_prev.dt = _ts_current.dt.
TimeStep{_ts_prev.previous(), _ts_prev.previous() + dt,
_ts_prev.steps()};
_previous_time_step_accepted = false;
return std::make_tuple(false, dt);
}
return {};
......
......@@ -102,7 +102,7 @@ public:
bool canReduceTimestepSize() const override;
/// Return the number of repeated steps.
/// Return the number of the total repeated steps.
int getNumberOfRepeatedSteps() const { return _n_rejected_steps; }
private:
......@@ -127,9 +127,11 @@ private:
const int _max_iter;
/// The number of nonlinear iterations.
int _iter_times = 0;
/// The number of rejected steps.
/// The number of total rejected steps.
int _n_rejected_steps = 0;
/// True, if the timestep is accepted.
bool _previous_time_step_accepted = true;
/// True, if the current time step is accepted.
bool _accepted = true;
};
......
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