version 3.10-dev
Dumux::TimeLoop< Scalar > Class Template Reference

The default time loop for instationary simulations.

#include <dumux/common/timeloop.hh>

Inheritance diagram for Dumux::TimeLoop< Scalar >:

Public Types

using Scalar = Scalar
 

Public Member Functions

 TimeLoop (Scalar startTime, Scalar dt, Scalar tEnd, bool verbose=true)
 
template<class Rep1 , class Period1 , class Rep2 , class Period2 , class Rep3 , class Period3 >
 TimeLoop (std::chrono::duration< Rep1, Period1 > startTime, std::chrono::duration< Rep2, Period2 > dt, std::chrono::duration< Rep3, Period3 > tEnd, bool verbose=true)
 
void setTimeStepSize (std::chrono::duration< Rep, Period > dt)
 Set the current time step size to a given value. More...
 

Simulated time and time step management

static constexpr Scalar baseEps_ = 1e-10
 
Dune::Timer timer_
 
Scalar time_
 
Scalar endTime_
 
Scalar startTime_
 
Scalar timeStepSize_
 
Scalar previousTimeStepSize_
 
Scalar userSetMaxTimeStepSize_
 
Scalar timeAfterLastTimeStep_
 
Scalar timeStepWallClockTime_
 
int timeStepIdx_
 
bool finished_
 
bool verbose_
 
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...
 
template<class Rep1 , class Period1 , class Rep2 , class Period2 , class Rep3 , class Period3 >
void reset (std::chrono::duration< Rep1, Period1 > startTime, std::chrono::duration< Rep2, Period2 > dt, std::chrono::duration< Rep3, Period3 > tEnd, bool verbose=true)
 Reset the time loop. More...
 
void reset (Scalar startTime, Scalar dt, Scalar tEnd, bool verbose=true)
 Reset the time loop. More...
 
void advanceTimeStep () override
 Advance time step. More...
 
template<class ScalarOrDuration >
void setTime (ScalarOrDuration t)
 Set the current simulated time, don't change the current time step index. More...
 
template<class ScalarOrDuration >
void setTime (ScalarOrDuration 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...
 
template<class ScalarOrDuration >
void setMaxTimeStepSize (ScalarOrDuration 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...
 
Scalar maxTimeStepSize () const override
 The current maximum 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...
 

Member Typedef Documentation

◆ Scalar

using Dumux::TimeLoopBase< Scalar >::Scalar = Scalar
inherited

Constructor & Destructor Documentation

◆ TimeLoop() [1/2]

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

◆ TimeLoop() [2/2]

template<class Scalar >
template<class Rep1 , class Period1 , class Rep2 , class Period2 , class Rep3 , class Period3 >
Dumux::TimeLoop< Scalar >::TimeLoop ( std::chrono::duration< Rep1, Period1 >  startTime,
std::chrono::duration< Rep2, Period2 >  dt,
std::chrono::duration< Rep3, Period3 >  tEnd,
bool  verbose = true 
)
inline

Member Function Documentation

◆ advanceTimeStep()

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

◆ endTime()

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

◆ finalize()

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

◆ finished()

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

This is the case if either setFinished(true) has been called or if the end time is reached.

Implements Dumux::TimeLoopBase< Scalar >.

◆ maxTimeStepSize()

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::maxTimeStepSize ( ) const
inlineoverridevirtual
Note
This gets aligned on every setTimeStepSize call to end time and other possible check points

Implements Dumux::TimeLoopBase< Scalar >.

Reimplemented in Dumux::CheckPointTimeLoop< Scalar >.

◆ previousTimeStepSize()

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

◆ reportTimeStep()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::reportTimeStep ( ) const
inline
Note
Always call this after TimeLoop::advanceTimeStep()

◆ reset() [1/2]

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

◆ reset() [2/2]

template<class Scalar >
template<class Rep1 , class Period1 , class Rep2 , class Period2 , class Rep3 , class Period3 >
void Dumux::TimeLoop< Scalar >::reset ( std::chrono::duration< Rep1, Period1 >  startTime,
std::chrono::duration< Rep2, Period2 >  dt,
std::chrono::duration< Rep3, Period3 >  tEnd,
bool  verbose = true 
)
inline

◆ resetTimer()

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

◆ setEndTime()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::setEndTime ( Scalar  t)
inline
Parameters
tThe time \(\mathrm{[s]}\) at which the simulation is finished

◆ setFinished()

template<class Scalar >
void Dumux::TimeLoop< Scalar >::setFinished ( bool  finished = true)
inline
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 >
template<class ScalarOrDuration >
void Dumux::TimeLoop< Scalar >::setMaxTimeStepSize ( ScalarOrDuration  maxDt)
inline
Parameters
maxDtThe new value for the maximum time step size \(\mathrm{[s]}\)
Note
This may also reduce the currently set timestep size if needed to comply with the set maximum

◆ setTime() [1/2]

template<class Scalar >
template<class ScalarOrDuration >
void Dumux::TimeLoop< Scalar >::setTime ( ScalarOrDuration  t)
inline
Parameters
tThe time \(\mathrm{[s]}\) which should be jumped to

◆ setTime() [2/2]

template<class Scalar >
template<class ScalarOrDuration >
void Dumux::TimeLoop< Scalar >::setTime ( ScalarOrDuration  t,
int  stepIdx 
)
inline
Parameters
tThe time \(\mathrm{[s]}\) which should be jumped to
stepIdxThe new time step index

◆ setTimeStepSize() [1/2]

template<class Scalar >
void Dumux::TimeLoop< Scalar >::setTimeStepSize ( Scalar  dt)
inlinefinalvirtual

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

◆ setTimeStepSize() [2/2]

void Dumux::TimeLoopBase< Scalar >::setTimeStepSize ( std::chrono::duration< Rep, Period >  dt)
inlineinherited
Parameters
dtThe new value for the time step size \(\mathrm{[s]}\)

◆ setVerbose()

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

◆ start()

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

◆ stop()

template<class Scalar >
double Dumux::TimeLoop< Scalar >::stop ( )
inline
Returns
the wall clock time (CPU time) spent until now

◆ time()

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

◆ timeStepIndex()

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

◆ timeStepSize()

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

◆ verbose()

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

◆ wallClockTime()

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

◆ willBeFinished()

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

Member Data Documentation

◆ baseEps_

template<class Scalar >
constexpr Scalar Dumux::TimeLoop< Scalar >::baseEps_ = 1e-10
staticconstexprprotected

◆ endTime_

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

◆ finished_

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

◆ previousTimeStepSize_

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

◆ startTime_

template<class Scalar >
Scalar Dumux::TimeLoop< Scalar >::startTime_
protected

◆ time_

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

◆ timeAfterLastTimeStep_

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

◆ timer_

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

◆ timeStepIdx_

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

◆ timeStepSize_

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

◆ timeStepWallClockTime_

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

◆ userSetMaxTimeStepSize_

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

◆ verbose_

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

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