OGS
|
Iteration number based adaptive time stepping.
This algorithm estimates a time step size depending on the number of iterations (e.g. of iterative linear solvers, nonlinear methods, partitioned coupling) needed in the last time step (see Hoffmann (2010) for Newton-Raphson case). The new time step \(\Delta t_{n+1}\) size is calculated as
\[ \Delta t_{n+1} = \alpha \Delta t_n \]
with the previous time step size \(\Delta t_{n}\) and a multiplier coefficient \(\alpha\) depending on the iteration number. Note that a time step size is always bounded by the minimum and maximum allowed value.
\[ \Delta t_{\min} \le \Delta t \le \Delta t_{\max} \]
For example, users can setup the following time stepping strategy based on the iteration number of the Newton-Raphson method in the last time step.
Num. of Newton steps | 0-2 | 3-6 | 7-8 | 9< |
---|---|---|---|---|
Time step size multiplier | 1.6 | 1. | 0.5 | 0.25 (repeat time step) |
Upper and lower bound | \( 1. \le \Delta t \le 10.\) |
A time step size is increased for the small iteration number, and decreased for the large iteration number. If the iteration number exceeds a user-defined threshold (e.g. 9), a time step is repeated with a smaller time step size.
Reference
Definition at line 66 of file IterationNumberBasedTimeStepping.h.
#include <IterationNumberBasedTimeStepping.h>
Public Member Functions | |
IterationNumberBasedTimeStepping (double const t_initial, double const t_end, double const min_dt, double const max_dt, double const initial_dt, std::vector< int > &&iter_times_vector, std::vector< double > &&multiplier_vector) | |
~IterationNumberBasedTimeStepping () override=default | |
std::tuple< bool, double > | next (double solution_error, int number_iterations) override |
bool | accepted () const override |
return if current time step is accepted or not More... | |
void | setAcceptedOrNot (bool accepted) override |
bool | isSolutionErrorComputationNeeded () const override |
bool | canReduceTimestepSize () const override |
Query the timestepper if further time step size reduction is possible. More... | |
Public Member Functions inherited from NumLib::TimeStepAlgorithm | |
TimeStepAlgorithm (const double t0, const double t_end) | |
TimeStepAlgorithm (const double t0, const double t_end, const double dt) | |
TimeStepAlgorithm (const double t0, const double t_end, const std::vector< double > &all_step_sizes) | |
virtual | ~TimeStepAlgorithm ()=default |
double | begin () const |
return the beginning of time steps More... | |
double | end () const |
return the end of time steps More... | |
const TimeStep | getTimeStep () const |
return current time step More... | |
void | resetCurrentTimeStep (const double dt) |
reset the current step size from the previous time More... | |
const std::vector< double > & | getTimeStepSizeHistory () const |
return a history of time step sizes More... | |
Private Member Functions | |
double | getNextTimeStepSize () const |
Calculate the next time step size. More... | |
double | findMultiplier (int number_iterations) const |
Find a multiplier for the given number of iterations. More... | |
Private Attributes | |
const std::vector< int > | _iter_times_vector |
const std::vector< double > | _multiplier_vector |
This vector stores the multiplier coefficients. More... | |
const double | _min_dt |
The minimum allowed time step size. More... | |
const double | _max_dt |
The maximum allowed time step size. More... | |
const double | _initial_dt |
Initial time step size. More... | |
const int | _max_iter |
The maximum allowed iteration number to accept current time step. More... | |
int | _iter_times = 0 |
The number of nonlinear iterations. More... | |
bool | _previous_time_step_accepted = true |
bool | _accepted = true |
True, if the current time step is accepted. More... | |
Additional Inherited Members | |
Protected Attributes inherited from NumLib::TimeStepAlgorithm | |
const double | _t_initial |
initial time More... | |
const double | _t_end |
end time More... | |
TimeStep | _ts_prev |
previous time step information More... | |
TimeStep | _ts_current |
current time step information More... | |
std::vector< double > | _dt_vector |
a vector of time step sizes More... | |
NumLib::IterationNumberBasedTimeStepping::IterationNumberBasedTimeStepping | ( | double const | t_initial, |
double const | t_end, | ||
double const | min_dt, | ||
double const | max_dt, | ||
double const | initial_dt, | ||
std::vector< int > && | iter_times_vector, | ||
std::vector< double > && | multiplier_vector | ||
) |
t_initial | start time |
t_end | end time |
min_dt | the minimum allowed time step size |
max_dt | the maximum allowed time step size |
initial_dt | initial time step size |
iter_times_vector | a vector of iteration numbers ( \(i_1\), \(i_2\), ..., \(i_n\)) which defines intervals as \([i_1,i_2)\), \([i_2,i_3)\), ..., \([i_n,\infty)\). If an iteration number is larger than \(i_n\), current time step is repeated with the new time step size. |
multiplier_vector | a vector of multiplier coefficients ( \(a_1\), \(a_2\), ..., \(a_n\)) corresponding to the intervals given by iter_times_vector. A time step size is calculated by \(\Delta t_{n+1} = a * \Delta t_{n}\) |
Definition at line 25 of file IterationNumberBasedTimeStepping.cpp.
References _iter_times_vector, _multiplier_vector, and OGS_FATAL.
|
overridedefault |
|
overridevirtual |
return if current time step is accepted or not
Implements NumLib::TimeStepAlgorithm.
Definition at line 139 of file IterationNumberBasedTimeStepping.cpp.
References _accepted.
Referenced by next(), and setAcceptedOrNot().
|
overridevirtual |
Query the timestepper if further time step size reduction is possible.
Reimplemented from NumLib::TimeStepAlgorithm.
Definition at line 144 of file IterationNumberBasedTimeStepping.cpp.
References _min_dt, NumLib::TimeStepAlgorithm::_ts_current, NumLib::TimeStepAlgorithm::_ts_prev, and NumLib::TimeStep::dt().
|
private |
Find a multiplier for the given number of iterations.
Definition at line 98 of file IterationNumberBasedTimeStepping.cpp.
References _accepted, _iter_times_vector, and _multiplier_vector.
Referenced by getNextTimeStepSize().
|
private |
Calculate the next time step size.
Definition at line 119 of file IterationNumberBasedTimeStepping.cpp.
References _initial_dt, _iter_times, _max_dt, _min_dt, NumLib::TimeStepAlgorithm::_ts_prev, NumLib::TimeStep::dt(), findMultiplier(), and NumLib::TimeStep::steps().
Referenced by next().
|
inlineoverridevirtual |
Get a flag to indicate whether this algorithm needs to compute solution error. The default return value is false.
Reimplemented from NumLib::TimeStepAlgorithm.
Definition at line 101 of file IterationNumberBasedTimeStepping.h.
|
overridevirtual |
Move to the next time step
solution_error | Solution error \(e_n\) between two successive time steps. |
number_iterations | Number of non-linear iterations used. |
Implements NumLib::TimeStepAlgorithm.
Definition at line 55 of file IterationNumberBasedTimeStepping.cpp.
References _iter_times, _previous_time_step_accepted, NumLib::TimeStepAlgorithm::_ts_current, NumLib::TimeStepAlgorithm::_ts_prev, accepted(), NumLib::TimeStep::dt(), getNextTimeStepSize(), NumLib::TimeStep::previous(), and NumLib::TimeStep::steps().
|
inlineoverridevirtual |
Set the status of the step.
accepted | A boolean parameter is needed to indicated whether the step is accepted or not. |
Reimplemented from NumLib::TimeStepAlgorithm.
Definition at line 99 of file IterationNumberBasedTimeStepping.h.
References _accepted, and accepted().
|
private |
True, if the current time step is accepted.
Definition at line 130 of file IterationNumberBasedTimeStepping.h.
Referenced by accepted(), findMultiplier(), and setAcceptedOrNot().
|
private |
Initial time step size.
Definition at line 122 of file IterationNumberBasedTimeStepping.h.
Referenced by getNextTimeStepSize().
|
private |
The number of nonlinear iterations.
Definition at line 126 of file IterationNumberBasedTimeStepping.h.
Referenced by getNextTimeStepSize(), and next().
|
private |
This vector stores the number of iterations to which the respective multiplier coefficient will be applied.
Definition at line 114 of file IterationNumberBasedTimeStepping.h.
Referenced by IterationNumberBasedTimeStepping(), and findMultiplier().
|
private |
The maximum allowed time step size.
Definition at line 120 of file IterationNumberBasedTimeStepping.h.
Referenced by getNextTimeStepSize().
|
private |
The maximum allowed iteration number to accept current time step.
Definition at line 124 of file IterationNumberBasedTimeStepping.h.
|
private |
The minimum allowed time step size.
Definition at line 118 of file IterationNumberBasedTimeStepping.h.
Referenced by canReduceTimestepSize(), and getNextTimeStepSize().
|
private |
This vector stores the multiplier coefficients.
Definition at line 116 of file IterationNumberBasedTimeStepping.h.
Referenced by IterationNumberBasedTimeStepping(), and findMultiplier().
|
private |
Definition at line 128 of file IterationNumberBasedTimeStepping.h.
Referenced by next().