24#ifndef DUMUX_TIME_MANAGER_HH
25#define DUMUX_TIME_MANAGER_HH
27#warning "This file is deprecated. Use the TimeLoop class in common/timeloop.hh"
31#include <dune/common/float_cmp.hh>
32#include <dune/common/timer.hh>
33#include <dune/common/parallel/mpihelper.hh>
61template <
class TypeTag>
75 Dune::MPIHelper::getCollectiveCommunication().rank() == 0;
78 episodeStartTime_ = 0;
84 previousTimeStepSize_ = timeStepSize_;
88 episodeLength_ = 1e100;
105 bool restart =
false)
111 timeStepSize_ = dtInitial;
112 previousTimeStepSize_ = dtInitial;
116 std::cout <<
"Initializing problem '" << problem_->name() <<
"'\n";
123 problem_->restart(tStart);
127 time_ -= timeStepSize_;
128 if (problem_->shouldWriteOutput())
129 problem_->writeOutput();
130 time_ += timeStepSize_;
134 int numProcesses = Dune::MPIHelper::getCollectiveCommunication().size();
135 std::cout <<
"Initialization took " << timer_.elapsed() <<
" seconds on "
136 << numProcesses <<
" processes.\n"
137 <<
"The cumulative CPU time was " << timer_.elapsed()*numProcesses <<
" seconds.\n";
163 { time_ = t; timeStepIdx_ = stepIdx; }
191 {
return timer_.elapsed(); }
215 {
return timeStepSize_; }
221 {
return previousTimeStepSize_; }
228 {
return timeStepIdx_; }
238 { finished_ = yesno; }
268 problem_->maxTimeStepSize()),
291 const std::string &description =
"")
294 episodeStartTime_ = tStart;
295 episodeLength_ = len;
296 episodeDescription_ = description;
308 episodeStartTime_ = time_;
309 episodeLength_ = len;
318 {
return episodeIndex_; }
325 {
return episodeStartTime_; }
332 {
return episodeLength_; }
385 problem_->preTimeStep();
388 problem_->timeIntegration();
392 problem_->postTimeStep();
395 if (problem_->shouldWriteOutput())
396 problem_->writeOutput();
399 problem_->advanceTimeLevel();
402 if (problem_->shouldWriteRestartFile())
403 problem_->serialize();
412 <<
"Wall time:"<<timer_.elapsed()
414 <<
", time step size:"<<dt
421 problem_->episodeEnd();
428 Scalar nextDt = max(previousTimeStepSize_,
timeStepSize());
429 previousTimeStepSize_ = nextDt;
444 int numProcesses = Dune::MPIHelper::getCollectiveCommunication().size();
445 std::cout <<
"Simulation took " << timer_.elapsed() <<
" seconds on "
446 << numProcesses <<
" processes.\n"
447 <<
"The cumulative CPU time was " << timer_.elapsed()*numProcesses <<
" seconds.\n";
462 template <
class Restarter>
465 res.serializeSectionBegin(
"TimeManager");
466 res.serializeStream() << episodeIndex_ <<
" "
467 << episodeStartTime_ <<
" "
468 << episodeLength_ <<
" "
470 << timeStepIdx_ + 1 <<
" ";
471 res.serializeSectionEnd();
481 template <
class Restarter>
484 res.deserializeSectionBegin(
"TimeManager");
485 res.deserializeStream() >> episodeIndex_
490 res.deserializeSectionEnd();
500 Scalar episodeStartTime_;
501 Scalar episodeLength_;
502 std::string episodeDescription_;
508 Scalar timeStepSize_;
509 Scalar previousTimeStepSize_;
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
Manages the handling of time dependent problems.
Definition: timemanager.hh:63
bool episodeWillBeFinished() const
Returns true if the current episode will be finished after the current time step.
Definition: timemanager.hh:345
Scalar timeStepSize() const
Returns the suggested time step length so that we don't miss the beginning of the next episode or cr...
Definition: timemanager.hh:214
TimeManager(bool verbose=true)
Definition: timemanager.hh:71
Scalar maxTimeStepSize() const
Aligns dt to the episode boundary or the end time of the simulation.
Definition: timemanager.hh:260
int timeStepIndex() const
Returns number of time steps which have been executed since the beginning of the simulation.
Definition: timemanager.hh:227
Scalar episodeStartTime() const
Returns the absolute time when the current episode started .
Definition: timemanager.hh:324
void deserialize(Restarter &res)
Read the time manager's state from a restart file.
Definition: timemanager.hh:482
bool willBeFinished() const
Returns true if the simulation is finished after the time level is incremented by the current time st...
Definition: timemanager.hh:253
double wallTime() const
Returns the current wall time (cpu time).
Definition: timemanager.hh:190
void serialize(Restarter &res)
Write the time manager's state to a restart file.
Definition: timemanager.hh:463
void setTimeStepSize(Scalar dt)
Set the current time step size to a given value.
Definition: timemanager.hh:203
void startNextEpisode(Scalar len=1e100)
Start the next episode, but don't change the episode identifier.
Definition: timemanager.hh:305
Scalar episodeMaxTimeStepSize() const
Aligns the time step size to the episode boundary if the current time step crosses the boundary of th...
Definition: timemanager.hh:352
bool episodeIsFinished() const
Returns true if the current episode is finished at the current time.
Definition: timemanager.hh:338
void setEndTime(Scalar t)
Set the time of simulated seconds at which the simulation runs.
Definition: timemanager.hh:184
void setTime(Scalar t, int stepIdx)
Set the current simulated time and the time step index.
Definition: timemanager.hh:162
void run()
Runs the simulation using a given problem class.
Definition: timemanager.hh:377
Scalar episodeLength() const
Returns the length of the current episode in simulated time .
Definition: timemanager.hh:331
void setFinished(bool yesno=true)
Specify whether the simulation is finished.
Definition: timemanager.hh:237
bool finished() const
Returns true if the simulation is finished.
Definition: timemanager.hh:246
int episodeIndex() const
Returns the index of the current episode.
Definition: timemanager.hh:317
void setTime(Scalar t)
Set the current simulated time, don't change the current time step index.
Definition: timemanager.hh:153
Scalar previousTimeStepSize() const
Returns the size of the previous time step .
Definition: timemanager.hh:220
Scalar endTime() const
Returns the number of (simulated) seconds which the simulation runs.
Definition: timemanager.hh:176
void init(Problem &problem, Scalar tStart, Scalar dtInitial, Scalar tEnd, bool restart=false)
Initialize the model and problem and write the initial condition to disk.
Definition: timemanager.hh:101
void startNextEpisode(Scalar tStart, Scalar len, const std::string &description="")
Change the current episode of the simulation.
Definition: timemanager.hh:289
Scalar time() const
Return the time before the time integration. To get the time after the time integration you have to ...
Definition: timemanager.hh:170
Base file for properties related to sequential models.