DUNE-FEM (unstable)
manager for global simulation time of time-dependent solutions More...
#include <dune/fem/solver/timeprovider.hh>
Public Member Functions | |
TimeProvider (const ParameterReader ¶meter=Parameter::container()) | |
default constructor More... | |
TimeProvider (const double startTime, const CommunicationType &comm=MPIManager::comm()) | |
constructor taking start time More... | |
TimeProvider (const double startTime, const double cfl, const CommunicationType &comm=MPIManager::comm()) | |
constructor taking start time and CFL constant More... | |
void | init () |
init dt with time step estimate | |
void | init (const double timeStep) |
init dt with provided time step More... | |
void | next () |
goto next time step More... | |
void | next (const double timeStep) |
goto next time step More... | |
double | factor () const |
return the global factor number More... | |
void | restore (const double time, const int timeStep) |
restore time and timestep from outside (i.e. from former calculation) More... | |
virtual void | backup () const |
backup persistent object | |
virtual void | restore () |
restore persistent object | |
double | time () const |
obtain the current time More... | |
int | timeStep () const |
obtain number of the current time step More... | |
double | deltaT () const |
obtain the size of the current time step More... | |
double | inverseDeltaT () const |
obtain the size of the inverse of the current time step More... | |
double | timeStepEstimate () const |
obtain current estimate on time step More... | |
void | provideTimeStepEstimate (const double dtEstimate) |
set time step estimate to minimum of given value and internal time step estiamte More... | |
void | provideTimeStepUpperBound (const double upperBound) |
set upper bound for time step to minimum of given value and internal bound More... | |
void | invalidateTimeStep () |
count current time step a not valid | |
bool | timeStepValid () const |
return if this time step should be used | |
Protected Member Functions | |
virtual void | insertSubData () |
insert possible sub data of object | |
virtual void | removeSubData () |
remove possible sub data of object | |
Detailed Description
class Dune::Fem::TimeProvider< Communication >
manager for global simulation time of time-dependent solutions
When calculating possibly multiple time-dependent solutions, it is often necessary to use the same time in all calculations. This means that we have to use the same time step for all our calculations. A TimeProvider keeps track of this information in a simple and unified way.
An example of a time loop could look as follows:
Within the time loop, both tp.time() and tp.deltaT() are fixed and cannot be altered and an the next time step should be fixed in the loop, e.g., in the method solve of the ode solver an upper estimate for the next time step is provided; if more than one time step restriction has to be imposed, the minimum is taken for the next time step. By calling the method provideTimeStepEstimate(maxDt) in the body of the loop an upper estimate for the next time step can be supplied; to fix the next time step (ignoring the estimates) an optinal argument can be passed to the next method on the Dune::Fem::TimeProvider.
Obviously, we need to provide an initial estimate. In the above example, this is done by the initialize method of the ODE solver. In tp.init(), the first time step (deltaT) is set based on the estimate and this value can also be fixed independent of the estimate through an optional argument. The following loop would fix the time step to 1e-3
In order to allow the user to influence the calculation of the next time step from the estimate, the time provider also maintains an additional factor (which is constant during the entire simulation). Therefore the actual time step used, is calculated as follows:
\[ \mathrm{deltaT} = \mathrm{factor} * \mathrm{timeStepEstimate}. \]
Therefore in the above example 1e-3 might not be the acctual time step depending on the value of the factor in the TimeProvider. The default value for this factor is equal to one but can be changed either during the construction of the Dune::TimeProvider or by using the parameter fem.timeprovider.factor
. A further parameter read by the Dune::TimeProvider is fem.timeprovider.starttime defining the starting time of the simulation (default is zero).
The most general implementation is given in the class Dune::Fem::TimeProvider< Communication< C > > which takes a Dune::Communication instance in the constructor which is used in parallel computations is syncronize the time step. It defaults to Dune::Fem::MPIManager::comm() and also works for serial runs.
If the communication manager from a given grid is to be used the class Dune::Fem::GridTimeProvider using the GridType as template argument can be used instead, with the same functionality.
- DUNE-FEM parameter:
fem.timeprovider.factor
multiplication factor to use for each time step; defaults to 1.fem.timeprovider.starttime
time used for initializing the starting time defaults to zero.fem.timeprovider.updatestep
only do the update of the time step size every 'updatestep' to avoid the expensive communication to achieve this (for testing only); defaults to 1
Constructor & Destructor Documentation
◆ TimeProvider() [1/3]
|
inlineexplicit |
default constructor
- Parameters
-
[in] comm collective communication (default Dune::Fem::MPIManager::comm())
◆ TimeProvider() [2/3]
|
inlineexplicit |
constructor taking start time
- Parameters
-
[in] startTime initial time [in] comm collective communication (default Dune::Fem::MPIManager::comm())
◆ TimeProvider() [3/3]
|
inline |
constructor taking start time and CFL constant
- Parameters
-
[in] startTime initial time [in] cfl CFL constant [in] comm collective communication (default Dune::Fem::MPIManager::comm())
Member Function Documentation
◆ deltaT()
|
inlineinherited |
obtain the size of the current time step
- Returns
- the size of the current time step
References Dune::Fem::TimeProviderBase::timeStepValid().
Referenced by DuneODE::ExplMultiStepBase< Operator >::solve(), DuneODE::ExplicitRungeKuttaSolver< DestinationImp >::solve(), and DuneODE::ExplMultiStepBase< Operator >::solveRK().
◆ factor()
|
inline |
return the global factor number
- Returns
- time step factor
◆ init()
|
inline |
init dt with provided time step
- Parameters
-
[in] timeStep value of the first time step (is multiplied with factor)
References Dune::Fem::TimeProviderBase::timeStep().
◆ inverseDeltaT()
|
inlineinherited |
obtain the size of the inverse of the current time step
- Returns
- the size of the inverse of the current time step
References Dune::Fem::TimeProviderBase::timeStepValid().
◆ next() [1/2]
|
inline |
goto next time step
Sets the size of the next time step to the current time step estimate and sets the estimate to infinity.
◆ next() [2/2]
|
inline |
goto next time step
Sets the size of the next time step to the provided time step value and sets the estimate to infinity.
- Parameters
-
[in] timeStep value of the next time step (is multiplied with factor)
References Dune::Fem::TimeProviderBase::timeStep().
◆ provideTimeStepEstimate()
|
inlineinherited |
set time step estimate to minimum of given value and internal time step estiamte
- Parameters
-
[in] dtEstimate time step size estimate
Referenced by DuneODE::ExplicitRungeKuttaSolver< DestinationImp >::initialize(), DuneODE::ExplMultiStepBase< Operator >::solve(), DuneODE::ExplicitRungeKuttaSolver< DestinationImp >::solve(), and DuneODE::ExplMultiStepBase< Operator >::solveRK().
◆ provideTimeStepUpperBound()
|
inlineinherited |
set upper bound for time step to minimum of given value and internal bound
- Parameters
-
[in] upperBound time step size estimate
◆ restore()
|
inline |
restore time and timestep from outside (i.e. from former calculation)
- Parameters
-
[in] time new time [in] timeStep new time step counter
References Dune::Fem::TimeProviderBase::time(), and Dune::Fem::TimeProviderBase::timeStep().
◆ time()
|
inlineinherited |
obtain the current time
- Returns
- the current time
Referenced by Dune::Fem::TimeProvider< Communication >::restore(), DuneODE::ExplMultiStepBase< Operator >::solve(), DuneODE::ExplicitRungeKuttaSolver< DestinationImp >::solve(), DuneODE::ExplMultiStepBase< Operator >::solveRK(), and Dune::Fem::DataOutput< GridImp, DataImp >::write().
◆ timeStep()
|
inlineinherited |
obtain number of the current time step
- Returns
- the current time step counter
References Dune::Fem::TimeProviderBase::timeStepValid().
Referenced by Dune::Fem::TimeProvider< Communication >::init(), Dune::Fem::TimeProvider< Communication >::next(), Dune::Fem::TimeProvider< Communication >::restore(), and Dune::Fem::CheckPointer< GridImp >::willWrite().
◆ timeStepEstimate()
|
inlineinherited |
obtain current estimate on time step
- Returns
- the current estimate for the time step
The documentation for this class was generated from the following file:
- dune/fem/solver/timeprovider.hh