dune-fem 2.8.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Dune::Fem::TimeProvider< CollectiveCommunication > Class Template Reference

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

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

Inheritance diagram for Dune::Fem::TimeProvider< CollectiveCommunication >:
Inheritance graph

Public Types

typedef CollectiveCommunication CollectiveCommunicationType
 

Public Member Functions

 TimeProvider (const ParameterReader &parameter=Parameter::container())
 default constructor
 
 TimeProvider (const CollectiveCommunicationType &comm, const ParameterReader &parameter=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
 
ThisTypeoperator= (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 CollectiveCommunicationTypecomm_
 
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_
 

Detailed Description

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
class Dune::Fem::TimeProvider< CollectiveCommunication >

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

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

Member Typedef Documentation

◆ CollectiveCommunicationType

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
typedef CollectiveCommunication Dune::Fem::TimeProvider< CollectiveCommunication >::CollectiveCommunicationType

Constructor & Destructor Documentation

◆ TimeProvider() [1/5]

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

default constructor

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

◆ TimeProvider() [2/5]

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
Dune::Fem::TimeProvider< CollectiveCommunication >::TimeProvider ( const CollectiveCommunicationType comm,
const ParameterReader parameter = Parameter::container() 
)
inlineexplicit

◆ TimeProvider() [3/5]

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

constructor taking start time

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

◆ TimeProvider() [4/5]

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
Dune::Fem::TimeProvider< CollectiveCommunication >::TimeProvider ( const double  startTime,
const double  cfl,
const CollectiveCommunicationType 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())

◆ ~TimeProvider()

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
virtual Dune::Fem::TimeProvider< CollectiveCommunication >::~TimeProvider ( )
inlinevirtual

◆ TimeProvider() [5/5]

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
Dune::Fem::TimeProvider< CollectiveCommunication >::TimeProvider ( const ThisType )
delete

Member Function Documentation

◆ advance()

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
void Dune::Fem::TimeProviderBase::advance ( )
inlineprotected

◆ backup()

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
virtual void Dune::Fem::TimeProvider< CollectiveCommunication >::backup ( ) const
inlinevirtual

backup persistent object

Reimplemented from Dune::Fem::TimeProviderBase.

◆ deltaT()

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

obtain the size of the current time step

Returns
the size of the current time step

◆ factor()

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

return the global factor number

Returns
time step factor

◆ getCflFactor()

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
double Dune::Fem::TimeProvider< CollectiveCommunication >::getCflFactor ( ) const
inlineprotected

◆ getUpdateStep()

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
int Dune::Fem::TimeProvider< CollectiveCommunication >::getUpdateStep ( ) const
inlineprotected

◆ init() [1/2]

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
void Dune::Fem::TimeProvider< CollectiveCommunication >::init ( )
inline

init dt with time step estimate

◆ init() [2/2]

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

init dt with provided time step

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

◆ initTimeStep()

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
void Dune::Fem::TimeProvider< CollectiveCommunication >::initTimeStep ( const double  dtEstimate)
inlineprotected

◆ initTimeStepEstimate()

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
void Dune::Fem::TimeProviderBase::initTimeStepEstimate ( )
inlineprotected

◆ insertSubData()

virtual void Dune::Fem::PersistentObject::insertSubData ( )
inlineprotectedvirtualinherited

◆ invalidateTimeStep()

void Dune::Fem::TimeProviderBase::invalidateTimeStep ( )
inlineinherited

count current time step a not valid

◆ 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

◆ next() [1/2]

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
void Dune::Fem::TimeProvider< CollectiveCommunication >::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 CollectiveCommunication = typename MPIManager::CollectiveCommunication>
void Dune::Fem::TimeProvider< CollectiveCommunication >::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)

◆ operator=()

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
ThisType & Dune::Fem::TimeProvider< CollectiveCommunication >::operator= ( const ThisType )
delete

◆ pointer()

virtual void * Dune::Fem::PersistentObject::pointer ( )
inlineprotectedvirtualinherited

◆ 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

◆ 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

◆ removeSubData()

virtual void Dune::Fem::PersistentObject::removeSubData ( )
inlineprotectedvirtualinherited

◆ restore() [1/2]

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
virtual void Dune::Fem::TimeProvider< CollectiveCommunication >::restore ( )
inlinevirtual

restore persistent object

Reimplemented from Dune::Fem::TimeProviderBase.

◆ restore() [2/2]

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
void Dune::Fem::TimeProvider< CollectiveCommunication >::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

◆ time()

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

obtain the current time

Returns
the current time

◆ timeStep()

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

obtain number of the current time step

Returns
the current time step counter

◆ timeStepEstimate()

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

obtain current estimate on time step

Returns
the current estimate for the time step

◆ timeStepValid()

bool Dune::Fem::TimeProviderBase::timeStepValid ( ) const
inlineinherited

return if this time step should be used

Member Data Documentation

◆ cfl_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
const double Dune::Fem::TimeProvider< CollectiveCommunication >::cfl_
protected

◆ comm_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
const CollectiveCommunicationType& Dune::Fem::TimeProvider< CollectiveCommunication >::comm_
protected

◆ counter_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
int Dune::Fem::TimeProvider< CollectiveCommunication >::counter_
protected

◆ dt_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
double Dune::Fem::TimeProviderBase::dt_
protected

◆ dtEstimate_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
double Dune::Fem::TimeProviderBase::dtEstimate_
protected

◆ dtEstimateValid_

bool Dune::Fem::TimeProviderBase::dtEstimateValid_
protectedinherited

◆ dtUpperBound_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
double Dune::Fem::TimeProviderBase::dtUpperBound_
protected

◆ invdt_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
double Dune::Fem::TimeProviderBase::invdt_
protected

◆ parameter_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
ParameterReader Dune::Fem::TimeProviderBase::parameter_
protected

◆ time_

double Dune::Fem::TimeProviderBase::time_
protectedinherited

◆ timeStep_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
int Dune::Fem::TimeProviderBase::timeStep_
protected

◆ updateStep_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
const int Dune::Fem::TimeProvider< CollectiveCommunication >::updateStep_
protected

◆ valid_

template<class CollectiveCommunication = typename MPIManager::CollectiveCommunication>
bool Dune::Fem::TimeProviderBase::valid_
protected

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