DUNE-FEM (unstable)

Dune::Fem::TimeProvider< Communication > Class Template Reference

manager for global simulation time of time-dependent solutions More...

#include <dune/fem/solver/timeprovider.hh>

Public Member Functions

 TimeProvider (const ParameterReader &parameter=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

template<class Communication = typename MPIManager::Communication>
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:

// create time provider
TimeProvider tp( startTime );
SpaceOperator spaceOperator;
typedef SpaceOperator::DestinationType DestinationType;
OdeSolver<DestinationType> odeSolver(spaceOperator,tp,order);
DestinationType U;
initialize(U);
// set the initial time step estimate
odeSolver.initialize( U );
// time loop
for( tp.init(); tp.time() < endTime; tp.next() )
{
// do calculation
odeSolver.solve(U);
}
manager for global simulation time of time-dependent solutions
Definition: timeprovider.hh:405

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

for( tp.init(1e-3); tp.time() < endTime; tp.next(1e-3) )
{
// do calculation
odeSolver.solve(U);
}

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]

template<class Communication = typename MPIManager::Communication>
Dune::Fem::TimeProvider< Communication >::TimeProvider ( const ParameterReader &  parameter = Parameter::container())
inlineexplicit

default constructor

Parameters
[in]commcollective communication (default Dune::Fem::MPIManager::comm())

◆ TimeProvider() [2/3]

template<class Communication = typename MPIManager::Communication>
Dune::Fem::TimeProvider< Communication >::TimeProvider ( const double  startTime,
const CommunicationType comm = MPIManager::comm() 
)
inlineexplicit

constructor taking start time

Parameters
[in]startTimeinitial time
[in]commcollective communication (default Dune::Fem::MPIManager::comm())

◆ TimeProvider() [3/3]

template<class Communication = typename MPIManager::Communication>
Dune::Fem::TimeProvider< Communication >::TimeProvider ( const double  startTime,
const double  cfl,
const CommunicationType comm = MPIManager::comm() 
)
inline

constructor taking start time and CFL constant

Parameters
[in]startTimeinitial time
[in]cflCFL constant
[in]commcollective communication (default Dune::Fem::MPIManager::comm())

Member Function Documentation

◆ deltaT()

double Dune::Fem::TimeProviderBase::deltaT ( ) const
inlineinherited

◆ factor()

template<class Communication = typename MPIManager::Communication>
double Dune::Fem::TimeProvider< Communication >::factor ( ) const
inline

return the global factor number

Returns
time step factor

◆ init()

template<class Communication = typename MPIManager::Communication>
void Dune::Fem::TimeProvider< Communication >::init ( const double  timeStep)
inline

init dt with provided time step

Parameters
[in]timeStepvalue of the first time step (is multiplied with factor)

References Dune::Fem::TimeProviderBase::timeStep().

◆ inverseDeltaT()

double Dune::Fem::TimeProviderBase::inverseDeltaT ( ) const
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]

template<class Communication = typename MPIManager::Communication>
void Dune::Fem::TimeProvider< Communication >::next ( )
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]

template<class Communication = typename MPIManager::Communication>
void Dune::Fem::TimeProvider< Communication >::next ( const double  timeStep)
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]timeStepvalue of the next time step (is multiplied with factor)

References Dune::Fem::TimeProviderBase::timeStep().

◆ provideTimeStepEstimate()

void Dune::Fem::TimeProviderBase::provideTimeStepEstimate ( const double  dtEstimate)
inlineinherited

set time step estimate to minimum of given value and internal time step estiamte

Parameters
[in]dtEstimatetime step size estimate

Referenced by DuneODE::ExplicitRungeKuttaSolver< DestinationImp >::initialize(), DuneODE::ExplMultiStepBase< Operator >::solve(), DuneODE::ExplicitRungeKuttaSolver< DestinationImp >::solve(), and DuneODE::ExplMultiStepBase< Operator >::solveRK().

◆ provideTimeStepUpperBound()

void Dune::Fem::TimeProviderBase::provideTimeStepUpperBound ( const double  upperBound)
inlineinherited

set upper bound for time step to minimum of given value and internal bound

Parameters
[in]upperBoundtime step size estimate

◆ restore()

template<class Communication = typename MPIManager::Communication>
void Dune::Fem::TimeProvider< Communication >::restore ( const double  time,
const int  timeStep 
)
inline

restore time and timestep from outside (i.e. from former calculation)

Parameters
[in]timenew time
[in]timeStepnew time step counter

References Dune::Fem::TimeProviderBase::time(), and Dune::Fem::TimeProviderBase::timeStep().

◆ time()

◆ timeStep()

int Dune::Fem::TimeProviderBase::timeStep ( ) const
inlineinherited

◆ timeStepEstimate()

double Dune::Fem::TimeProviderBase::timeStepEstimate ( ) const
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:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 20, 23:30, 2024)