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

A time loop with a check point mechanism. More...

#include <dumux/common/timeloop.hh>

Inheritance diagram for Dumux::CheckPointTimeLoop< Scalar >:

Description

template<class Scalar>
class Dumux::CheckPointTimeLoop< Scalar >

A time loop with a check point mechanism.

Public Member Functions

 CheckPointTimeLoop (Scalar startTime, Scalar dt, Scalar tEnd, bool verbose=true)
 
void advanceTimeStep () override
 Advance time step. More...
 
Scalar maxTimeStepSize () const override
 The current maximum time step size. More...
 
void setPeriodicCheckPoint (Scalar interval, Scalar offset=0.0)
 Set a periodic check point. More...
 
void disablePeriodicCheckPoints ()
 disable periodic check points More...
 
void removeAllCheckPoints ()
 remove all check points More...
 
bool isCheckPoint () const
 Whether now is a time checkpoint. More...
 
void setCheckPoint (Scalar t)
 add a checkpoint to the queue More...
 
void setCheckPoint (const std::vector< Scalar > &checkPoints)
 add checkpoints to the queue from a vector of time points More...
 
template<class ForwardIterator >
void setCheckPoint (ForwardIterator first, ForwardIterator last)
 add checkpoints to the queue from a container from the first iterator to the last iterator More...
 

Simulated time and time step management

void start ()
 Tells the time loop to start tracking the time. More...
 
double stop ()
 Tells the time loop to stop tracking the time. More...
 
void resetTimer ()
 Reset the timer. More...
 
void reset (Scalar startTime, Scalar dt, Scalar tEnd, bool verbose=true)
 Reset the time loop. More...
 
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 final
 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 wallClockTime () const
 Returns the current wall clock time (cpu time) spend in this time loop. More...
 
void setTimeStepSize (Scalar dt) final
 Set the current time step size to a given value. More...
 
void setMaxTimeStepSize (Scalar maxDt)
 Set the maximum time step size to a given value. More...
 
Scalar timeStepSize () const final
 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...
 
int timeStepIndex () const
 Returns number of time steps which have been executed since the beginning of the simulation. More...
 
Scalar previousTimeStepSize () const
 The previous time step size. More...
 
void setFinished (bool finished=true)
 Specify whether the simulation is finished. More...
 
bool finished () const override
 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...
 
void reportTimeStep () const
 State info on cpu time. More...
 
template<class Communicator = Dune::Communication<typename Dune::MPIHelper::MPICommunicator>>
void finalize (const Communicator &comm=Dune::MPIHelper::getCommunication())
 Print final status and stops tracking the time. More...
 
bool verbose () const
 If the time loop has verbose output. More...
 
void setVerbose (bool verbose=true)
 Sets time loop verbosity. More...
 
Dune::Timer timer_
 
Scalar time_
 
Scalar endTime_
 
Scalar timeStepSize_
 
Scalar previousTimeStepSize_
 
Scalar userSetMaxTimeStepSize_
 
Scalar timeAfterLastTimeStep_
 
Scalar timeStepWallClockTime_
 
int timeStepIdx_
 
bool finished_
 
bool verbose_
 

Constructor & Destructor Documentation

◆ CheckPointTimeLoop()

template<class Scalar >
Dumux::CheckPointTimeLoop< Scalar >::CheckPointTimeLoop ( Scalar  startTime,
Scalar  dt,
Scalar  tEnd,
bool  verbose = true 
)
inline

Member Function Documentation

◆ advanceTimeStep()

template<class Scalar >
void Dumux::CheckPointTimeLoop< Scalar >::advanceTimeStep ( )
inlineoverridevirtual

Advance time step.

Check point management, TimeLoop::isCheckPoint() has to be called after this!

Reimplemented from Dumux::TimeLoop< Scalar >.

◆ disablePeriodicCheckPoints()

template<class Scalar >
void Dumux::CheckPointTimeLoop< Scalar >::disablePeriodicCheckPoints ( )
inline

disable periodic check points

◆ endTime()

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::endTime ( ) const
inlineinherited

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

◆ finalize()

template<class Scalar >
template<class Communicator = Dune::Communication<typename Dune::MPIHelper::MPICommunicator>>
void Dumux::TimeLoop< Scalar >::finalize ( const Communicator &  comm = Dune::MPIHelper::getCommunication())
inlineinherited

Print final status and stops tracking the time.

◆ finished()

template<class Scalar >
bool Dumux::TimeLoop< Scalar >::finished ( ) const
inlineoverridevirtualinherited

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.

Implements Dumux::TimeLoopBase< Scalar >.

◆ isCheckPoint()

template<class Scalar >
bool Dumux::CheckPointTimeLoop< Scalar >::isCheckPoint ( ) const
inline

Whether now is a time checkpoint.

Note
has to be called after TimeLoop::advanceTimeStep()

◆ maxTimeStepSize()

template<class Scalar >
Scalar Dumux::CheckPointTimeLoop< Scalar >::maxTimeStepSize ( ) const
inlineoverridevirtual

The current maximum time step size.

Note
This gets aligned on every setTimeStepSize call to end time and other possible check points

Reimplemented from Dumux::TimeLoop< Scalar >.

◆ previousTimeStepSize()

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::previousTimeStepSize ( ) const
inlineinherited

The previous time step size.

◆ removeAllCheckPoints()

template<class Scalar >
void Dumux::CheckPointTimeLoop< Scalar >::removeAllCheckPoints ( )
inline

remove all check points

◆ reportTimeStep()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::reportTimeStep ( ) const
inlineinherited

State info on cpu time.

Note
Always call this after TimeLoop::advanceTimeStep()

◆ reset()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::reset ( Scalar  startTime,
Scalar  dt,
Scalar  tEnd,
bool  verbose = true 
)
inlineinherited

Reset the time loop.

◆ resetTimer()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::resetTimer ( )
inlineinherited

Reset the timer.

◆ setCheckPoint() [1/3]

template<class Scalar >
void Dumux::CheckPointTimeLoop< Scalar >::setCheckPoint ( const std::vector< Scalar > &  checkPoints)
inline

add checkpoints to the queue from a vector of time points

Note
checkpoints have to be provided in ascending order
Parameters
checkPointsthe vector of check points
Note
This also updates the time step size and potentially reduces the time step size to meet the next check point

◆ setCheckPoint() [2/3]

template<class Scalar >
template<class ForwardIterator >
void Dumux::CheckPointTimeLoop< Scalar >::setCheckPoint ( ForwardIterator  first,
ForwardIterator  last 
)
inline

add checkpoints to the queue from a container from the first iterator to the last iterator

Note
checkpoints have to be provided in ascending order
Parameters
firstiterator to the first element to be inserted
lastiterator to the one-after-last element to be inserted
Note
This also updates the time step size and potentially reduces the time step size to meet the next check point

◆ setCheckPoint() [3/3]

template<class Scalar >
void Dumux::CheckPointTimeLoop< Scalar >::setCheckPoint ( Scalar  t)
inline

add a checkpoint to the queue

Note
checkpoints have to be provided in ascending order
Parameters
tthe check point (in seconds)
Note
This also updates the time step size and potentially reduces the time step size to meet the next check point

◆ setEndTime()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::setEndTime ( Scalar  t)
inlineinherited

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 Scalar >
void Dumux::TimeLoop< Scalar >::setFinished ( bool  finished = true)
inlineinherited

Specify whether the simulation is finished.

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

◆ setMaxTimeStepSize()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::setMaxTimeStepSize ( Scalar  maxDt)
inlineinherited

Set the maximum time step size to a given value.

Parameters
maxDtThe new value for the maximum time step size \(\mathrm{[s]}\)
Note
This also updates the time step size

◆ setPeriodicCheckPoint()

template<class Scalar >
void Dumux::CheckPointTimeLoop< Scalar >::setPeriodicCheckPoint ( Scalar  interval,
Scalar  offset = 0.0 
)
inline

Set a periodic check point.

Note
You can query if we are at a time check point with isCheckPoint()
Parameters
intervalSet a periodic checkout every [interval] seconds
offsettime from which the periodic check points are supposed to start (simulation time) the first checkpoint will be at time = offset.
Note
If offset is in the past the first check point will be at the next periodic check point greater or equal than time
This also updates the time step size and potentially reduces the time step size to meet the next check point

◆ setTime() [1/2]

template<class Scalar >
void Dumux::TimeLoop< Scalar >::setTime ( Scalar  t)
inlineinherited

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 Scalar >
void Dumux::TimeLoop< Scalar >::setTime ( Scalar  t,
int  stepIdx 
)
inlineinherited

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 Scalar >
void Dumux::TimeLoop< Scalar >::setTimeStepSize ( Scalar  dt)
inlinefinalvirtualinherited

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]}\)

Implements Dumux::TimeLoopBase< Scalar >.

◆ setVerbose()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::setVerbose ( bool  verbose = true)
inlineinherited

Sets time loop verbosity.

◆ start()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::start ( )
inlineinherited

Tells the time loop to start tracking the time.

◆ stop()

template<class Scalar >
double Dumux::TimeLoop< Scalar >::stop ( )
inlineinherited

Tells the time loop to stop tracking the time.

Returns
the wall clock time (CPU time) spent until now

◆ time()

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::time ( ) const
inlinefinalvirtualinherited

Return the time \(\mathrm{[s]}\) before the time integration. To get the time after the time integration you have to add timeStepSize() to time().

Implements Dumux::TimeLoopBase< Scalar >.

◆ timeStepIndex()

template<class Scalar >
int Dumux::TimeLoop< Scalar >::timeStepIndex ( ) const
inlineinherited

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

◆ timeStepSize()

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::timeStepSize ( ) const
inlinefinalvirtualinherited

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.

Implements Dumux::TimeLoopBase< Scalar >.

◆ verbose()

template<class Scalar >
bool Dumux::TimeLoop< Scalar >::verbose ( ) const
inlineinherited

If the time loop has verbose output.

◆ wallClockTime()

template<class Scalar >
double Dumux::TimeLoop< Scalar >::wallClockTime ( ) const
inlineinherited

Returns the current wall clock time (cpu time) spend in this time loop.

◆ willBeFinished()

template<class Scalar >
bool Dumux::TimeLoop< Scalar >::willBeFinished ( ) const
inlineinherited

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

Member Data Documentation

◆ endTime_

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::endTime_
protectedinherited

◆ finished_

template<class Scalar >
bool Dumux::TimeLoop< Scalar >::finished_
protectedinherited

◆ previousTimeStepSize_

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::previousTimeStepSize_
protectedinherited

◆ time_

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::time_
protectedinherited

◆ timeAfterLastTimeStep_

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::timeAfterLastTimeStep_
protectedinherited

◆ timer_

template<class Scalar >
Dune::Timer Dumux::TimeLoop< Scalar >::timer_
protectedinherited

◆ timeStepIdx_

template<class Scalar >
int Dumux::TimeLoop< Scalar >::timeStepIdx_
protectedinherited

◆ timeStepSize_

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::timeStepSize_
protectedinherited

◆ timeStepWallClockTime_

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::timeStepWallClockTime_
protectedinherited

◆ userSetMaxTimeStepSize_

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::userSetMaxTimeStepSize_
protectedinherited

◆ verbose_

template<class Scalar >
bool Dumux::TimeLoop< Scalar >::verbose_
protectedinherited

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