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>
60template <
class TypeTag>
74 Dune::MPIHelper::getCollectiveCommunication().rank() == 0;
77 episodeStartTime_ = 0;
83 previousTimeStepSize_ = timeStepSize_;
87 episodeLength_ = 1e100;
104 bool restart =
false)
110 timeStepSize_ = dtInitial;
111 previousTimeStepSize_ = dtInitial;
115 std::cout <<
"Initializing problem '" << problem_->name() <<
"'\n";
122 problem_->restart(tStart);
126 time_ -= timeStepSize_;
127 if (problem_->shouldWriteOutput())
128 problem_->writeOutput();
129 time_ += timeStepSize_;
133 int numProcesses = Dune::MPIHelper::getCollectiveCommunication().size();
134 std::cout <<
"Initialization took " << timer_.elapsed() <<
" seconds on "
135 << numProcesses <<
" processes.\n"
136 <<
"The cumulative CPU time was " << timer_.elapsed()*numProcesses <<
" seconds.\n";
162 { time_ = t; timeStepIdx_ = stepIdx; }
190 {
return timer_.elapsed(); }
214 {
return timeStepSize_; }
220 {
return previousTimeStepSize_; }
227 {
return timeStepIdx_; }
237 { finished_ = yesno; }
267 problem_->maxTimeStepSize()),
290 const std::string &description =
"")
293 episodeStartTime_ = tStart;
294 episodeLength_ = len;
295 episodeDescription_ = description;
307 episodeStartTime_ = time_;
308 episodeLength_ = len;
317 {
return episodeIndex_; }
324 {
return episodeStartTime_; }
331 {
return episodeLength_; }
384 problem_->preTimeStep();
387 problem_->timeIntegration();
391 problem_->postTimeStep();
394 if (problem_->shouldWriteOutput())
395 problem_->writeOutput();
398 problem_->advanceTimeLevel();
401 if (problem_->shouldWriteRestartFile())
402 problem_->serialize();
411 <<
"Wall time:"<<timer_.elapsed()
413 <<
", time step size:"<<dt
420 problem_->episodeEnd();
427 Scalar nextDt = max(previousTimeStepSize_,
timeStepSize());
428 previousTimeStepSize_ = nextDt;
443 int numProcesses = Dune::MPIHelper::getCollectiveCommunication().size();
444 std::cout <<
"Simulation took " << timer_.elapsed() <<
" seconds on "
445 << numProcesses <<
" processes.\n"
446 <<
"The cumulative CPU time was " << timer_.elapsed()*numProcesses <<
" seconds.\n";
461 template <
class Restarter>
464 res.serializeSectionBegin(
"TimeManager");
465 res.serializeStream() << episodeIndex_ <<
" "
466 << episodeStartTime_ <<
" "
467 << episodeLength_ <<
" "
469 << timeStepIdx_ + 1 <<
" ";
470 res.serializeSectionEnd();
480 template <
class Restarter>
483 res.deserializeSectionBegin(
"TimeManager");
484 res.deserializeStream() >> episodeIndex_
489 res.deserializeSectionEnd();
499 Scalar episodeStartTime_;
500 Scalar episodeLength_;
501 std::string episodeDescription_;
507 Scalar timeStepSize_;
508 Scalar previousTimeStepSize_;
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
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:62
bool episodeWillBeFinished() const
Returns true if the current episode will be finished after the current time step.
Definition: timemanager.hh:344
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:213
TimeManager(bool verbose=true)
Definition: timemanager.hh:70
Scalar maxTimeStepSize() const
Aligns dt to the episode boundary or the end time of the simulation.
Definition: timemanager.hh:259
int timeStepIndex() const
Returns number of time steps which have been executed since the beginning of the simulation.
Definition: timemanager.hh:226
Scalar episodeStartTime() const
Returns the absolute time when the current episode started .
Definition: timemanager.hh:323
void deserialize(Restarter &res)
Read the time manager's state from a restart file.
Definition: timemanager.hh:481
bool willBeFinished() const
Returns true if the simulation is finished after the time level is incremented by the current time st...
Definition: timemanager.hh:252
double wallTime() const
Returns the current wall time (cpu time).
Definition: timemanager.hh:189
void serialize(Restarter &res)
Write the time manager's state to a restart file.
Definition: timemanager.hh:462
void setTimeStepSize(Scalar dt)
Set the current time step size to a given value.
Definition: timemanager.hh:202
void startNextEpisode(Scalar len=1e100)
Start the next episode, but don't change the episode identifier.
Definition: timemanager.hh:304
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:351
bool episodeIsFinished() const
Returns true if the current episode is finished at the current time.
Definition: timemanager.hh:337
void setEndTime(Scalar t)
Set the time of simulated seconds at which the simulation runs.
Definition: timemanager.hh:183
void setTime(Scalar t, int stepIdx)
Set the current simulated time and the time step index.
Definition: timemanager.hh:161
void run()
Runs the simulation using a given problem class.
Definition: timemanager.hh:376
Scalar episodeLength() const
Returns the length of the current episode in simulated time .
Definition: timemanager.hh:330
void setFinished(bool yesno=true)
Specify whether the simulation is finished.
Definition: timemanager.hh:236
bool finished() const
Returns true if the simulation is finished.
Definition: timemanager.hh:245
int episodeIndex() const
Returns the index of the current episode.
Definition: timemanager.hh:316
void setTime(Scalar t)
Set the current simulated time, don't change the current time step index.
Definition: timemanager.hh:152
Scalar previousTimeStepSize() const
Returns the size of the previous time step .
Definition: timemanager.hh:219
Scalar endTime() const
Returns the number of (simulated) seconds which the simulation runs.
Definition: timemanager.hh:175
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:100
void startNextEpisode(Scalar tStart, Scalar len, const std::string &description="")
Change the current episode of the simulation.
Definition: timemanager.hh:288
Scalar time() const
Return the time before the time integration. To get the time after the time integration you have to ...
Definition: timemanager.hh:169
Base file for properties related to sequential models.