Manages the handling of time dependent problems. More...
#include <dumux/common/timemanager.hh>
Manages the handling of time dependent problems.
This class facilitates the time management of the simulation. It doesn't manage any user data, but keeps track of what the current time, time step size and "episode" of the simulation is. It triggers the initialization of the problem and is responsible for the time control of a simulation run.
The time manager allows to specify a sequence of "episodes" which determine the boundary conditions of a problem. This approach is handy if the problem is not static, i.e. the boundary conditions change over time.
An episode is a span of simulated time in which the problem behaves in a specific way. It is characterized by the (simulation) time it starts, its length and a consecutive index starting at 0.
Public Member Functions | |
TimeManager (bool verbose=true) | |
void | init (Problem &problem, Scalar tStart, Scalar dtInitial, Scalar tEnd, bool restart=false) |
Initialize the model and problem and write the initial condition to disk. More... | |
Simulated time and time step management | |
void | setTime (Scalar t) |
Set the current simulated time, don't change the current time step index. More... | |
void | setTime (Scalar t, int stepIdx) |
Set the current simulated time and the time step index. More... | |
Scalar | time () const |
Return the time \(\mathrm{[s]}\) before the time integration. To get the time after the time integration you have to add timeStepSize() to time(). More... | |
Scalar | endTime () const |
Returns the number of (simulated) seconds which the simulation runs. More... | |
void | setEndTime (Scalar t) |
Set the time of simulated seconds at which the simulation runs. More... | |
double | wallTime () const |
Returns the current wall time (cpu time). More... | |
void | setTimeStepSize (Scalar dt) |
Set the current time step size to a given value. More... | |
Scalar | timeStepSize () const |
Returns the suggested time step length \(\mathrm{[s]}\) so that we don't miss the beginning of the next episode or cross the end of the simulation. More... | |
Scalar | previousTimeStepSize () const |
Returns the size of the previous time step \(\mathrm{[s]}\). More... | |
int | timeStepIndex () const |
Returns number of time steps which have been executed since the beginning of the simulation. More... | |
void | setFinished (bool yesno=true) |
Specify whether the simulation is finished. More... | |
bool | finished () const |
Returns true if the simulation is finished. More... | |
bool | willBeFinished () const |
Returns true if the simulation is finished after the time level is incremented by the current time step size. More... | |
Scalar | maxTimeStepSize () const |
Aligns dt to the episode boundary or the end time of the simulation. More... | |
episode Episode management | |
void | startNextEpisode (Scalar tStart, Scalar len, const std::string &description="") |
Change the current episode of the simulation. More... | |
void | startNextEpisode (Scalar len=1e100) |
Start the next episode, but don't change the episode identifier. More... | |
int | episodeIndex () const |
Returns the index of the current episode. More... | |
Scalar | episodeStartTime () const |
Returns the absolute time when the current episode started \(\mathrm{[s]}\). More... | |
Scalar | episodeLength () const |
Returns the length of the current episode in simulated time \(\mathrm{[s]}\). More... | |
bool | episodeIsFinished () const |
Returns true if the current episode is finished at the current time. More... | |
bool | episodeWillBeFinished () const |
Returns true if the current episode will be finished after the current time step. More... | |
Scalar | episodeMaxTimeStepSize () const |
Aligns the time step size to the episode boundary if the current time step crosses the boundary of the current episode. More... | |
void | run () |
Runs the simulation using a given problem class. More... | |
Saving/restoring the object state | |
template<class Restarter > | |
void | serialize (Restarter &res) |
Write the time manager's state to a restart file. More... | |
template<class Restarter > | |
void | deserialize (Restarter &res) |
Read the time manager's state from a restart file. More... | |
|
inline |
|
inline |
Read the time manager's state from a restart file.
Restarter | The type of the object which takes care to deserialize data |
res | The deserializer object |
|
inline |
Returns the number of (simulated) seconds which the simulation runs.
|
inline |
Returns the index of the current episode.
The first episode has the index 0.
|
inline |
Returns true if the current episode is finished at the current time.
|
inline |
Returns the length of the current episode in simulated time \(\mathrm{[s]}\).
|
inline |
Aligns the time step size to the episode boundary if the current time step crosses the boundary of the current episode.
|
inline |
Returns the absolute time when the current episode started \(\mathrm{[s]}\).
|
inline |
Returns true if the current episode will be finished after the current time step.
|
inline |
Returns true if the simulation is finished.
This is the case if either setFinished(true) has been called or if the end time is reached.
|
inline |
Initialize the model and problem and write the initial condition to disk.
problem | The physical problem which needs to be solved |
tStart | The start time \(\mathrm{[s]}\) of the simulation (typically 0) |
dtInitial | The initial time step size \(\mathrm{[s]}\) |
tEnd | The time at which the simulation is finished \(\mathrm{[s]}\) |
restart | Specifies whether the initial condition should be written to disk |
|
inline |
Aligns dt to the episode boundary or the end time of the simulation.
|
inline |
Returns the size of the previous time step \(\mathrm{[s]}\).
|
inline |
Runs the simulation using a given problem class.
This method makes sure that time step sizes are aligned to episode boundaries, amongst other stuff.
|
inline |
Write the time manager's state to a restart file.
Restarter | The type of the object which takes care to serialize data |
res | The serializer object |
|
inline |
Set the time of simulated seconds at which the simulation runs.
t | The time \(\mathrm{[s]}\) at which the simulation is finished |
|
inline |
Specify whether the simulation is finished.
yesno | If true the simulation is considered finished before the end time is reached, else it is only considered finished if the end time is reached. |
|
inline |
Set the current simulated time, don't change the current time step index.
t | The time \(\mathrm{[s]}\) which should be jumped to |
|
inline |
Set the current simulated time and the time step index.
t | The time \(\mathrm{[s]}\) which should be jumped to |
stepIdx | The new time step index |
|
inline |
Set the current time step size to a given value.
If the step size would exceed the length of the current episode, the timeStep() method will take care that the step size won't exceed the episode or the end of the simulation, though.
dt | The new value for the time step size \(\mathrm{[s]}\) |
|
inline |
Start the next episode, but don't change the episode identifier.
len | Length of the episode \(\mathrm{[s]}\), infinite if not specified. |
|
inline |
Change the current episode of the simulation.
tStart | Time when the episode began \(\mathrm{[s]}\) |
len | Length of the episode \(\mathrm{[s]}\) |
description | descriptive name of the episode |
|
inline |
Return the time \(\mathrm{[s]}\) before the time integration. To get the time after the time integration you have to add timeStepSize() to time().
|
inline |
Returns number of time steps which have been executed since the beginning of the simulation.
|
inline |
Returns the suggested time step length \(\mathrm{[s]}\) so that we don't miss the beginning of the next episode or cross the end of the simulation.
|
inline |
Returns the current wall time (cpu time).
|
inline |
Returns true if the simulation is finished after the time level is incremented by the current time step size.