dune-fem 2.8.0
|
manager for global simulation time of time-dependent solutions More...
#include <dune/fem/solver/timeprovider.hh>
Public Types | |
typedef CollectiveCommunication | CollectiveCommunicationType |
Public Member Functions | |
TimeProvider (const ParameterReader ¶meter=Parameter::container()) | |
default constructor | |
TimeProvider (const CollectiveCommunicationType &comm, const ParameterReader ¶meter=Parameter::container()) | |
TimeProvider (const double startTime, const CollectiveCommunicationType &comm=MPIManager::comm()) | |
constructor taking start time | |
TimeProvider (const double startTime, const double cfl, const CollectiveCommunicationType &comm=MPIManager::comm()) | |
constructor taking start time and CFL constant | |
virtual | ~TimeProvider () |
TimeProvider (const ThisType &)=delete | |
ThisType & | operator= (const ThisType &)=delete |
void | init () |
init dt with time step estimate | |
void | init (const double timeStep) |
init dt with provided time step | |
void | next () |
goto next time step | |
void | next (const double timeStep) |
goto next time step | |
double | factor () const |
return the global factor number | |
void | restore (const double time, const int timeStep) |
restore time and timestep from outside (i.e. from former calculation) | |
virtual void | backup () const |
backup persistent object | |
virtual void | restore () |
restore persistent object | |
double | time () const |
obtain the current time | |
int | timeStep () const |
obtain number of the current time step | |
double | deltaT () const |
obtain the size of the current time step | |
double | inverseDeltaT () const |
obtain the size of the inverse of the current time step | |
double | timeStepEstimate () const |
obtain current estimate on time step | |
void | provideTimeStepEstimate (const double dtEstimate) |
set time step estimate to minimum of given value and internal time step estiamte | |
void | provideTimeStepUpperBound (const double upperBound) |
set upper bound for time step to minimum of given value and internal bound | |
void | invalidateTimeStep () |
count current time step a not valid | |
bool | timeStepValid () const |
return if this time step should be used | |
Protected Member Functions | |
double | getCflFactor () const |
int | getUpdateStep () const |
void | initTimeStep (const double dtEstimate) |
void | advance () |
void | initTimeStepEstimate () |
virtual void | insertSubData () |
insert possible sub data of object | |
virtual void | removeSubData () |
remove possible sub data of object | |
virtual void * | pointer () |
Protected Attributes | |
const CollectiveCommunicationType & | comm_ |
const double | cfl_ |
const int | updateStep_ |
int | counter_ |
ParameterReader | parameter_ |
double | dt_ |
double | invdt_ |
double | dtEstimate_ |
double | dtUpperBound_ |
bool | valid_ |
int | timeStep_ |
double | time_ |
bool | dtEstimateValid_ |
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:
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< CollectiveCommunication< C > > which takes a Dune::CollectiveCommunication 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.
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
typedef CollectiveCommunication Dune::Fem::TimeProvider< CollectiveCommunication >::CollectiveCommunicationType |
|
inlineexplicit |
default constructor
[in] | comm | collective communication (default Dune::Fem::MPIManager::comm()) |
|
inlineexplicit |
|
inlineexplicit |
constructor taking start time
[in] | startTime | initial time |
[in] | comm | collective communication (default Dune::Fem::MPIManager::comm()) |
|
inline |
constructor taking start time and CFL constant
[in] | startTime | initial time |
[in] | cfl | CFL constant |
[in] | comm | collective communication (default Dune::Fem::MPIManager::comm()) |
|
inlinevirtual |
|
delete |
|
inlineprotected |
|
inlinevirtual |
backup persistent object
Reimplemented from Dune::Fem::TimeProviderBase.
|
inlineinherited |
obtain the size of the current time step
|
inline |
return the global factor number
|
inlineprotected |
|
inlineprotected |
|
inline |
init dt with time step estimate
|
inline |
init dt with provided time step
[in] | timeStep | value of the first time step (is multiplied with factor) |
|
inlineprotected |
|
inlineprotected |
|
inlineprotectedvirtualinherited |
insert possible sub data of object
Reimplemented in Dune::Fem::DiscreteFunctionDefault< Impl >, Dune::Fem::DiscreteFunctionDefault< AdaptiveDiscreteFunction< DiscreteFunctionSpace > >, Dune::Fem::DiscreteFunctionDefault< BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > >, Dune::Fem::DiscreteFunctionDefault< CombinedDiscreteFunction< ContainedDiscreteFunctionImp, N > >, Dune::Fem::DiscreteFunctionDefault< HierarchicalDiscreteFunction< DiscreteFunctionSpace > >, Dune::Fem::DiscreteFunctionDefault< ISTLBlockVectorDiscreteFunction< DiscreteFunctionSpace, Block > >, Dune::Fem::DiscreteFunctionDefault< TupleDiscreteFunction< DiscreteFunctions ... > >, and Dune::Fem::DiscreteFunctionDefault< VectorDiscreteFunction< DiscreteFunctionSpace, Vector > >.
|
inlineinherited |
count current time step a not valid
|
inlineinherited |
obtain the size of the inverse of the current time step
|
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.
|
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.
[in] | timeStep | value of the next time step (is multiplied with factor) |
|
delete |
|
inlineprotectedvirtualinherited |
Reimplemented in Dune::Fem::PersistenceManager::WrapObject< ObjectType, false >.
|
inlineinherited |
set time step estimate to minimum of given value and internal time step estiamte
[in] | dtEstimate | time step size estimate |
|
inlineinherited |
set upper bound for time step to minimum of given value and internal bound
[in] | upperBound | time step size estimate |
|
inlineprotectedvirtualinherited |
remove possible sub data of object
Reimplemented in Dune::Fem::DiscreteFunctionDefault< Impl >, Dune::Fem::DiscreteFunctionDefault< AdaptiveDiscreteFunction< DiscreteFunctionSpace > >, Dune::Fem::DiscreteFunctionDefault< BlockVectorDiscreteFunction< DiscreteFunctionSpace, BlockVector > >, Dune::Fem::DiscreteFunctionDefault< CombinedDiscreteFunction< ContainedDiscreteFunctionImp, N > >, Dune::Fem::DiscreteFunctionDefault< HierarchicalDiscreteFunction< DiscreteFunctionSpace > >, Dune::Fem::DiscreteFunctionDefault< ISTLBlockVectorDiscreteFunction< DiscreteFunctionSpace, Block > >, Dune::Fem::DiscreteFunctionDefault< TupleDiscreteFunction< DiscreteFunctions ... > >, and Dune::Fem::DiscreteFunctionDefault< VectorDiscreteFunction< DiscreteFunctionSpace, Vector > >.
|
inlinevirtual |
restore persistent object
Reimplemented from Dune::Fem::TimeProviderBase.
|
inline |
restore time and timestep from outside (i.e. from former calculation)
[in] | time | new time |
[in] | timeStep | new time step counter |
|
inlineinherited |
obtain the current time
|
inlineinherited |
obtain number of the current time step
|
inlineinherited |
obtain current estimate on time step
|
inlineinherited |
return if this time step should be used
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |