3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
Public Member Functions | List of all members
Dumux::TimeManager< TypeTag > Class Template Reference

Manages the handling of time dependent problems. More...

#include <dumux/common/timemanager.hh>

Description

template<class TypeTag>
class Dumux::TimeManager< TypeTag >

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...
 

Constructor & Destructor Documentation

◆ TimeManager()

template<class TypeTag >
Dumux::TimeManager< TypeTag >::TimeManager ( bool  verbose = true)
inline

Member Function Documentation

◆ deserialize()

template<class TypeTag >
template<class Restarter >
void Dumux::TimeManager< TypeTag >::deserialize ( Restarter &  res)
inline

Read the time manager's state from a restart file.

Template Parameters
RestarterThe type of the object which takes care to deserialize data
Parameters
resThe deserializer object

◆ endTime()

template<class TypeTag >
Scalar Dumux::TimeManager< TypeTag >::endTime ( ) const
inline

Returns the number of (simulated) seconds which the simulation runs.

◆ episodeIndex()

template<class TypeTag >
int Dumux::TimeManager< TypeTag >::episodeIndex ( ) const
inline

Returns the index of the current episode.

The first episode has the index 0.

◆ episodeIsFinished()

template<class TypeTag >
bool Dumux::TimeManager< TypeTag >::episodeIsFinished ( ) const
inline

Returns true if the current episode is finished at the current time.

◆ episodeLength()

template<class TypeTag >
Scalar Dumux::TimeManager< TypeTag >::episodeLength ( ) const
inline

Returns the length of the current episode in simulated time \(\mathrm{[s]}\).

◆ episodeMaxTimeStepSize()

template<class TypeTag >
Scalar Dumux::TimeManager< TypeTag >::episodeMaxTimeStepSize ( ) const
inline

Aligns the time step size to the episode boundary if the current time step crosses the boundary of the current episode.

◆ episodeStartTime()

template<class TypeTag >
Scalar Dumux::TimeManager< TypeTag >::episodeStartTime ( ) const
inline

Returns the absolute time when the current episode started \(\mathrm{[s]}\).

◆ episodeWillBeFinished()

template<class TypeTag >
bool Dumux::TimeManager< TypeTag >::episodeWillBeFinished ( ) const
inline

Returns true if the current episode will be finished after the current time step.

◆ finished()

template<class TypeTag >
bool Dumux::TimeManager< TypeTag >::finished ( ) const
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.

◆ init()

template<class TypeTag >
void Dumux::TimeManager< TypeTag >::init ( Problem &  problem,
Scalar  tStart,
Scalar  dtInitial,
Scalar  tEnd,
bool  restart = false 
)
inline

Initialize the model and problem and write the initial condition to disk.

Parameters
problemThe physical problem which needs to be solved
tStartThe start time \(\mathrm{[s]}\) of the simulation (typically 0)
dtInitialThe initial time step size \(\mathrm{[s]}\)
tEndThe time at which the simulation is finished \(\mathrm{[s]}\)
restartSpecifies whether the initial condition should be written to disk

◆ maxTimeStepSize()

template<class TypeTag >
Scalar Dumux::TimeManager< TypeTag >::maxTimeStepSize ( ) const
inline

Aligns dt to the episode boundary or the end time of the simulation.

◆ previousTimeStepSize()

template<class TypeTag >
Scalar Dumux::TimeManager< TypeTag >::previousTimeStepSize ( ) const
inline

Returns the size of the previous time step \(\mathrm{[s]}\).

◆ run()

template<class TypeTag >
void Dumux::TimeManager< TypeTag >::run ( )
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.

◆ serialize()

template<class TypeTag >
template<class Restarter >
void Dumux::TimeManager< TypeTag >::serialize ( Restarter &  res)
inline

Write the time manager's state to a restart file.

Template Parameters
RestarterThe type of the object which takes care to serialize data
Parameters
resThe serializer object

◆ setEndTime()

template<class TypeTag >
void Dumux::TimeManager< TypeTag >::setEndTime ( Scalar  t)
inline

Set the time of simulated seconds at which the simulation runs.

Parameters
tThe time \(\mathrm{[s]}\) at which the simulation is finished

◆ setFinished()

template<class TypeTag >
void Dumux::TimeManager< TypeTag >::setFinished ( bool  yesno = true)
inline

Specify whether the simulation is finished.

Parameters
yesnoIf true the simulation is considered finished before the end time is reached, else it is only considered finished if the end time is reached.

◆ setTime() [1/2]

template<class TypeTag >
void Dumux::TimeManager< TypeTag >::setTime ( Scalar  t)
inline

Set the current simulated time, don't change the current time step index.

Parameters
tThe time \(\mathrm{[s]}\) which should be jumped to

◆ setTime() [2/2]

template<class TypeTag >
void Dumux::TimeManager< TypeTag >::setTime ( Scalar  t,
int  stepIdx 
)
inline

Set the current simulated time and the time step index.

Parameters
tThe time \(\mathrm{[s]}\) which should be jumped to
stepIdxThe new time step index

◆ setTimeStepSize()

template<class TypeTag >
void Dumux::TimeManager< TypeTag >::setTimeStepSize ( Scalar  dt)
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.

Parameters
dtThe new value for the time step size \(\mathrm{[s]}\)

◆ startNextEpisode() [1/2]

template<class TypeTag >
void Dumux::TimeManager< TypeTag >::startNextEpisode ( Scalar  len = 1e100)
inline

Start the next episode, but don't change the episode identifier.

Parameters
lenLength of the episode \(\mathrm{[s]}\), infinite if not specified.

◆ startNextEpisode() [2/2]

template<class TypeTag >
void Dumux::TimeManager< TypeTag >::startNextEpisode ( Scalar  tStart,
Scalar  len,
const std::string &  description = "" 
)
inline

Change the current episode of the simulation.

Parameters
tStartTime when the episode began \(\mathrm{[s]}\)
lenLength of the episode \(\mathrm{[s]}\)
descriptiondescriptive name of the episode

◆ time()

template<class TypeTag >
Scalar Dumux::TimeManager< TypeTag >::time ( ) const
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().

◆ timeStepIndex()

template<class TypeTag >
int Dumux::TimeManager< TypeTag >::timeStepIndex ( ) const
inline

Returns number of time steps which have been executed since the beginning of the simulation.

◆ timeStepSize()

template<class TypeTag >
Scalar Dumux::TimeManager< TypeTag >::timeStepSize ( ) const
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.

◆ wallTime()

template<class TypeTag >
double Dumux::TimeManager< TypeTag >::wallTime ( ) const
inline

Returns the current wall time (cpu time).

◆ willBeFinished()

template<class TypeTag >
bool Dumux::TimeManager< TypeTag >::willBeFinished ( ) const
inline

Returns true if the simulation is finished after the time level is incremented by the current time step size.


The documentation for this class was generated from the following file: