1 #ifndef DUNE_FEM_TIMEPROVIDER_HH 2 #define DUNE_FEM_TIMEPROVIDER_HH 41 :
time_( parameter.getValue(
"fem.timeprovider.starttime",
42 static_cast<double>(0.0) ) ),
70 std::tuple<const double&,const int&,const double&,const bool&,const double&>
77 std::tuple<double&,int&,double&,bool&,double&>
87 ThisType &
operator= (
const ThisType & ) =
delete;
94 inline double time ()
const 193 dtEstimateValid_ =
false;
215 template<
class CollectiveCommunication =
typename MPIManager::CollectiveCommunication >
232 const CollectiveCommunicationType &comm,
234 : BaseType( startTime, parameter ), comm_( comm )
242 : BaseType( startTime, parameter ), comm_(
MPIManager::comm() )
256 : BaseType( parameter.getValue< double>(
"fem.timeprovider.starttime", 0.0 ), parameter ), comm_(
MPIManager::comm() )
258 dt_ = parameter.getValidValue<
double >(
"fem.timeprovider.fixedtimestep", [] (
double v ) {
return v > 0.0;} );
264 : BaseType( parameter.getValue< double>(
"fem.timeprovider.starttime", 0.0 ), parameter ), comm_( comm )
266 dt_ = parameter.getValidValue<
double >(
"fem.timeprovider.fixedtimestep", [] (
double v ) {
return v > 0.0;} );
273 ThisType &
operator= (
const ThisType & ) =
delete;
274 ThisType &
operator= ( ThisType && ) =
delete;
280 DUNE_THROW( InvalidStateException,
"Invalid Time Step in FixedStepTimeProvider" );
286 using BaseType::advance;
287 using BaseType::initTimeStepEstimate;
288 using BaseType::time_;
290 using BaseType::valid_;
298 const CollectiveCommunicationType &
comm_;
402 template<
class CollectiveCommunication =
typename MPIManager::CollectiveCommunication >
414 using BaseType::parameter_;
419 [] (
double val ) {
return val > 0.0; } );
425 [] (
int step ) {
return step > 0; } );
434 : BaseType( parameter ),
436 cfl_( getCflFactor() ),
437 updateStep_( getUpdateStep() ),
438 counter_( updateStep_ )
442 : BaseType( parameter ),
444 cfl_( getCflFactor() ),
445 updateStep_( getUpdateStep() ),
446 counter_( updateStep_ )
456 : BaseType( startTime ),
458 cfl_( getCflFactor() ),
459 updateStep_( getUpdateStep() ),
460 counter_( updateStep_ )
472 : BaseType( startTime ),
476 counter_( updateStep_ )
484 ThisType &
operator= (
const ThisType & ) =
delete;
500 initTimeStep( timeStep );
526 initTimeStep(timeStep);
538 using BaseType::advance;
539 using BaseType::initTimeStepEstimate;
546 if( counter_ >= updateStep_ )
580 const_cast< double &
>( cfl_ ) = getCflFactor();
585 using BaseType::invdt_;
586 using BaseType::dtEstimate_;
587 using BaseType::dtUpperBound_;
588 using BaseType::valid_;
589 using BaseType::timeStep_;
591 const CollectiveCommunicationType&
comm_;
611 template<
class Gr
id >
613 :
public TimeProvider< typename Grid::Traits::CollectiveCommunication >
625 : BaseType( grid.comm() ),
626 dm_( DofManagerType ::instance( grid ) ),
632 : BaseType( startTime, grid.comm() ),
633 dm_( DofManagerType ::instance( grid ) ),
640 : BaseType( startTime, cfl, grid.comm() ),
641 dm_( DofManagerType ::instance( grid ) ),
648 using BaseType :: counter_ ;
649 using BaseType :: updateStep_ ;
655 const int currentSequence = dm_.sequence();
657 if( sequence_ != currentSequence )
660 counter_ = updateStep_ ;
661 sequence_ = currentSequence ;
665 BaseType :: initTimeStep( dtEstimate );
668 const DofManagerType&
dm_;
676 #endif // #ifndef DUNE_FEM_TIMEPROVIDER_HH CollectiveCommunication CollectiveCommunicationType
Definition: timeprovider.hh:410
int sequence_
Definition: timeprovider.hh:669
TimeProvider(const double startTime, const CollectiveCommunicationType &comm=MPIManager::comm())
constructor taking start time
Definition: timeprovider.hh:454
double dt_
Definition: timeprovider.hh:172
virtual ~GridTimeProvider()
Definition: timeprovider.hh:645
void initTimeStepEstimate()
Definition: timeprovider.hh:189
virtual void backup() const
backup persistent object
Definition: timeprovider.hh:572
void next()
goto next time step
Definition: timeprovider.hh:277
virtual ~TimeProviderBase()
Definition: timeprovider.hh:65
static constexpr T min(T a)
Definition: utility.hh:81
the same functionality as the Dune::TimeProvider.
Definition: timeprovider.hh:612
void init()
init dt with time step estimate
Definition: timeprovider.hh:488
Definition: timeprovider.hh:216
int timeStep() const
obtain number of the current time step
Definition: timeprovider.hh:103
virtual ~TimeProvider()
Definition: timeprovider.hh:479
void provideTimeStepEstimate(const double dtEstimate)
set time step estimate to minimum of given value and internal time step estiamte
Definition: timeprovider.hh:142
double deltaT() const
obtain the size of the current time step
Definition: timeprovider.hh:113
double time_
Definition: timeprovider.hh:170
static const CollectiveCommunication & comm()
Definition: mpimanager.hh:108
double inverseDeltaT() const
obtain the size of the inverse of the current time step
Definition: timeprovider.hh:123
static constexpr T max(T a)
Definition: utility.hh:65
virtual ~FixedStepTimeProvider()
Definition: timeprovider.hh:269
TimeProviderBase(const ParameterReader ¶meter=Parameter::container())
Definition: timeprovider.hh:40
CollectiveCommunication CollectiveCommunicationType
Definition: timeprovider.hh:223
GridTimeProvider(const Grid &grid)
Definition: timeprovider.hh:624
ThisType & operator=(const ThisType &)=delete
bool timeStepValid() const
return if this time step should be used
Definition: timeprovider.hh:164
TimeProvider(const double startTime, const double cfl, const CollectiveCommunicationType &comm=MPIManager::comm())
constructor taking start time and CFL constant
Definition: timeprovider.hh:469
Definition: datacollector.hh:45
virtual void restore()=0
restore persistent object
void backup() const
backup persistent object
Definition: timeprovider.hh:68
const int updateStep_
Definition: timeprovider.hh:593
void init(const double timeStep)
init dt with provided time step
Definition: timeprovider.hh:498
void next()
goto next time step
Definition: timeprovider.hh:508
void restore(const double time, const int timeStep)
restore time and timestep from outside (i.e. from former calculation)
Definition: timeprovider.hh:566
GridTimeProvider(const double startTime, const Grid &grid)
Definition: timeprovider.hh:630
FixedStepTimeProvider(const CollectiveCommunicationType &comm, const ParameterReader ¶meter=Parameter::container())
Definition: timeprovider.hh:262
void restore()
restore persistent object
Definition: timeprovider.hh:75
virtual void backup() const =0
backup persistent object
GridTimeProvider(const double startTime, const double cfl, const Grid &grid)
Definition: timeprovider.hh:637
ParameterReader parameter_
Definition: timeprovider.hh:178
general base for time providers
Definition: timeprovider.hh:35
const DofManagerType & dm_
Definition: timeprovider.hh:668
int counter_
Definition: timeprovider.hh:594
int timeStep_
Definition: timeprovider.hh:171
TimeProvider DefaultTimeProvider
Definition: timeprovider.hh:600
double dtEstimate_
Definition: timeprovider.hh:176
virtual void restore()
restore persistent object
Definition: timeprovider.hh:577
void initTimeStep(const double dtEstimate)
Definition: timeprovider.hh:541
Grid::Traits::CollectiveCommunication CollectiveCommunicationType
Definition: timeprovider.hh:622
Definition: coordinate.hh:4
Definition: mpimanager.hh:19
FixedStepTimeProvider(const double startTime, const double timeStepSize, const ParameterReader ¶meter=Parameter::container())
Definition: timeprovider.hh:240
TimeProviderBase(const double startTime, const ParameterReader ¶meter=Parameter::container())
Definition: timeprovider.hh:53
void initTimeStep(const double dtEstimate)
Definition: timeprovider.hh:653
T getValidValue(const std::string &key, const Validator &validator) const
get optional parameter
Definition: reader.hh:187
static ParameterContainer & container()
Definition: io/parameter.hh:190
const CollectiveCommunicationType & comm_
Definition: timeprovider.hh:298
const double cfl_
Definition: timeprovider.hh:592
static void restoreValue(const std::string &token, T &value)
Definition: persistencemanager.hh:385
base class for auto persistent objects
Definition: persistencemanager.hh:562
base class for persistent objects
Definition: persistencemanager.hh:96
TimeProvider(const ParameterReader ¶meter=Parameter::container())
default constructor
Definition: timeprovider.hh:433
bool dtEstimateValid_
Definition: timeprovider.hh:175
manager for global simulation time of time-dependent solutions
Definition: timeprovider.hh:403
bool valid_
Definition: timeprovider.hh:174
double factor() const
return the global factor number
Definition: timeprovider.hh:532
double dtUpperBound_
Definition: timeprovider.hh:177
void invalidateTimeStep()
count current time step a not valid
Definition: timeprovider.hh:158
const CollectiveCommunicationType & comm_
Definition: timeprovider.hh:591
FixedStepTimeProvider(const ParameterReader ¶meter=Parameter::container())
constructor
Definition: timeprovider.hh:255
TimeProvider(const CollectiveCommunicationType &comm, const ParameterReader ¶meter=Parameter::container())
Definition: timeprovider.hh:441
void next(const double timeStep)
goto next time step
Definition: timeprovider.hh:523
int getUpdateStep() const
Definition: timeprovider.hh:422
double time() const
obtain the current time
Definition: timeprovider.hh:94
void advance()
Definition: timeprovider.hh:180
void provideTimeStepUpperBound(const double upperBound)
set upper bound for time step to minimum of given value and internal bound
Definition: timeprovider.hh:151
static void backupValue(const std::string &token, const T &value)
Definition: persistencemanager.hh:379
double timeStepEstimate() const
obtain current estimate on time step
Definition: timeprovider.hh:133
double invdt_
Definition: timeprovider.hh:173
double getCflFactor() const
Definition: timeprovider.hh:416
FixedStepTimeProvider(const double startTime, const double timeStepSize, const CollectiveCommunicationType &comm, const ParameterReader ¶meter=Parameter::container())
constructor
Definition: timeprovider.hh:231
void initTimeStep()
Definition: timeprovider.hh:292