simulator.hh
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
28 #ifndef EWOMS_SIMULATOR_HH
29 #define EWOMS_SIMULATOR_HH
30 
31 #include <ewoms/io/restart.hh>
33 
35 #include <ewoms/common/timer.hh>
37 
38 #include <dune/common/version.hh>
39 #include <dune/common/parallel/mpihelper.hh>
40 
41 #include <iostream>
42 #include <fstream>
43 #include <iomanip>
44 #include <vector>
45 #include <string>
46 #include <memory>
47 
48 
49 namespace Ewoms {
50 namespace Properties {
51 NEW_PROP_TAG(Scalar);
52 NEW_PROP_TAG(GridManager);
53 NEW_PROP_TAG(GridView);
54 NEW_PROP_TAG(Model);
55 NEW_PROP_TAG(Problem);
56 NEW_PROP_TAG(EndTime);
57 NEW_PROP_TAG(RestartTime);
58 NEW_PROP_TAG(InitialTimeStepSize);
59 NEW_PROP_TAG(PredeterminedTimeStepsFile);
60 }
61 
74 template <class TypeTag>
75 class Simulator
76 {
77  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
78  typedef typename GET_PROP_TYPE(TypeTag, GridManager) GridManager;
79  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
80  typedef typename GET_PROP_TYPE(TypeTag, Model) Model;
81  typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
82 
83 public:
84  // do not allow to copy simulators around
85  Simulator(const Simulator& ) = delete;
86 
87  Simulator(bool verbose = true)
88  {
89  Ewoms::TimerGuard setupTimerGuard(setupTimer_);
90 
91  setupTimer_.start();
92 
93  verbose_ = verbose && Dune::MPIHelper::getCollectiveCommunication().rank() == 0;
94 
95  timeStepIdx_ = 0;
96  startTime_ = 0.0;
97  time_ = 0.0;
98  endTime_ = EWOMS_GET_PARAM(TypeTag, Scalar, EndTime);
99  timeStepSize_ = EWOMS_GET_PARAM(TypeTag, Scalar, InitialTimeStepSize);
100 
101  const std::string& predetTimeStepFile =
102  EWOMS_GET_PARAM(TypeTag, std::string, PredeterminedTimeStepsFile);
103  if (!predetTimeStepFile.empty()) {
104  std::ifstream is(predetTimeStepFile);
105  while (!is.eof()) {
106  Scalar dt;
107  is >> dt;
108  forcedTimeSteps_.push_back(dt);
109  }
110  }
111 
112  episodeIdx_ = 0;
113  episodeStartTime_ = 0;
114  episodeLength_ = std::numeric_limits<Scalar>::max();
115 
116  finished_ = false;
117 
118  if (verbose_)
119  std::cout << "Allocating the grid\n" << std::flush;
120  gridManager_.reset(new GridManager(*this));
121 
122  if (verbose_)
123  std::cout << "Distributing the grid\n" << std::flush;
124  gridManager_->loadBalance();
125 
126  if (verbose_)
127  std::cout << "Allocating the model\n" << std::flush;
128  model_.reset(new Model(*this));
129 
130  if (verbose_)
131  std::cout << "Allocating the problem\n" << std::flush;
132  problem_.reset(new Problem(*this));
133 
134  if (verbose_)
135  std::cout << "Finish init of the model\n" << std::flush;
136  model_->finishInit();
137 
138  if (verbose_)
139  std::cout << "Finish init of the problem\n" << std::flush;
140  problem_->finishInit();
141 
142  setupTimer_.stop();
143 
144  if (verbose_)
145  std::cout << "Construction of simulation done\n" << std::flush;
146  }
147 
151  static void registerParameters()
152  {
153  EWOMS_REGISTER_PARAM(TypeTag, Scalar, EndTime,
154  "The simulation time at which the simulation is finished [s]");
155  EWOMS_REGISTER_PARAM(TypeTag, Scalar, InitialTimeStepSize,
156  "The size of the initial time step [s]");
157  EWOMS_REGISTER_PARAM(TypeTag, Scalar, RestartTime,
158  "The simulation time at which a restart should be attempted [s]");
159  EWOMS_REGISTER_PARAM(TypeTag, std::string, PredeterminedTimeStepsFile,
160  "A file with a list of predetermined time step sizes (one "
161  "time step per line)");
162 
163  GridManager::registerParameters();
164  Model::registerParameters();
165  Problem::registerParameters();
166  }
167 
171  GridManager& gridManager()
172  { return *gridManager_; }
173 
177  const GridManager& gridManager() const
178  { return *gridManager_; }
179 
183  const GridView& gridView() const
184  { return gridManager_->gridView(); }
185 
189  Model& model()
190  { return *model_; }
191 
195  const Model& model() const
196  { return *model_; }
197 
202  Problem& problem()
203  { return *problem_; }
204 
209  const Problem& problem() const
210  { return *problem_; }
211 
217  void setStartTime(Scalar t)
218  { startTime_ = t; }
219 
223  Scalar startTime() const
224  { return startTime_; }
225 
232  void setTime(Scalar t)
233  { time_ = t; }
234 
241  void setTime(Scalar t, unsigned stepIdx)
242  {
243  time_ = t;
244  timeStepIdx_ = stepIdx;
245  }
246 
254  Scalar time() const
255  { return time_; }
256 
262  void setEndTime(Scalar t)
263  { endTime_ = t; }
264 
269  Scalar endTime() const
270  { return endTime_; }
271 
276  const Ewoms::Timer& setupTimer() const
277  { return setupTimer_; }
278 
284  { return executionTimer_; }
285 
291  { return prePostProcessTimer_; }
292 
298  { return linearizeTimer_; }
299 
304  const Ewoms::Timer& solveTimer() const
305  { return solveTimer_; }
306 
311  const Ewoms::Timer& updateTimer() const
312  { return updateTimer_; }
313 
318  const Ewoms::Timer& writeTimer() const
319  { return writeTimer_; }
320 
331  void setTimeStepSize(Scalar value)
332  { timeStepSize_ = value; }
333 
339  void setTimeStepIndex(unsigned value)
340  { timeStepIdx_ = value; }
341 
347  Scalar timeStepSize() const
348  {
349  Scalar maximumTimeStepSize =
350  std::min(episodeMaxTimeStepSize(),
351  std::max( Scalar(0), endTime() - this->time()));
352 
353  return std::min(timeStepSize_, maximumTimeStepSize);
354  }
355 
360  int timeStepIndex() const
361  { return timeStepIdx_; }
362 
370  void setFinished(bool yesno = true)
371  { finished_ = yesno; }
372 
379  bool finished() const
380  {
381  assert(timeStepSize_ >= 0.0);
382  Scalar eps =
383  std::max(Scalar(std::abs(this->time())), timeStepSize())
384  *std::numeric_limits<Scalar>::epsilon()*1e3;
385  return finished_ || (this->time()*(1.0 + eps) >= endTime());
386  }
387 
392  bool willBeFinished() const
393  {
394  static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
395 
396  return finished_ || (this->time() + timeStepSize_)*(1.0 + eps) >= endTime();
397  }
398 
403  Scalar maxTimeStepSize() const
404  {
405  if (finished())
406  return 0.0;
407 
408  return std::min(episodeMaxTimeStepSize(),
409  std::max<Scalar>(0.0, endTime() - this->time()));
410  }
411 
419  {
420  ++episodeIdx_;
421  episodeStartTime_ = episodeStartTime;
422  episodeLength_ = episodeLength;
423  }
424 
432  void startNextEpisode(Scalar len = std::numeric_limits<Scalar>::max())
433  {
434  ++episodeIdx_;
435  episodeStartTime_ = startTime_ + time_;
436  episodeLength_ = len;
437  }
438 
444  void setEpisodeIndex(int episodeIdx)
445  { episodeIdx_ = episodeIdx; }
446 
452  int episodeIndex() const
453  { return episodeIdx_; }
454 
459  Scalar episodeStartTime() const
460  { return episodeStartTime_; }
461 
467  void setEpisodeLength(Scalar dt)
468  { episodeLength_ = dt; }
469 
474  Scalar episodeLength() const
475  { return episodeLength_; }
476 
481  bool episodeIsOver() const
482  {
483  static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
484 
485  return startTime() + this->time() >= (episodeStartTime_ + episodeLength())*(1 - eps);
486  }
487 
492  bool episodeWillBeOver() const
493  {
494  static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
495 
496  return startTime() + this->time() + timeStepSize()
497  >= (episodeStartTime_ + episodeLength())*(1 - eps);
498  }
499 
504  Scalar episodeMaxTimeStepSize() const
505  {
506  // if the current episode is over and the simulation
507  // wants to give it some extra time, we will return
508  // the time step size it suggested instead of trying
509  // to align it to the end of the episode.
510  if (episodeIsOver())
511  return 0.0;
512 
513  // make sure that we don't exceed the end of the
514  // current episode.
515  return std::max<Scalar>(0.0,
517  - (this->time() + this->startTime()));
518  }
519 
520  /*
521  * \}
522  */
523 
530  void run()
531  {
532  // create TimerGuard objects to hedge for exceptions
533  TimerGuard setupTimerGuard(setupTimer_);
534  TimerGuard executionTimerGuard(executionTimer_);
535  TimerGuard prePostProcessTimerGuard(prePostProcessTimer_);
536  TimerGuard writeTimerGuard(writeTimer_);
537 
538  setupTimer_.start();
539  Scalar restartTime = EWOMS_GET_PARAM(TypeTag, Scalar, RestartTime);
540  if (restartTime > -1e30) {
541  // try to restart a previous simulation
542  time_ = restartTime;
543 
544  Ewoms::Restart res;
545  res.deserializeBegin(*this, time_);
546  if (verbose_)
547  std::cout << "Deserialize from file '" << res.fileName() << "'\n" << std::flush;
548  this->deserialize(res);
549  problem_->deserialize(res);
550  model_->deserialize(res);
551  res.deserializeEnd();
552  if (verbose_)
553  std::cout << "Deserialization done."
554  << " Simulator time: " << time() << humanReadableTime(time())
555  << " Time step index: " << timeStepIndex()
556  << " Episode index: " << episodeIndex()
557  << "\n" << std::flush;
558  }
559  else {
560  // if no restart is done, apply the initial solution
561  if (verbose_)
562  std::cout << "Applying the initial solution of the \"" << problem_->name()
563  << "\" problem\n" << std::flush;
564 
565  Scalar oldTimeStepSize = timeStepSize_;
566  int oldTimeStepIdx = timeStepIdx_;
567  timeStepSize_ = 0.0;
568  timeStepIdx_ = -1;
569 
570  model_->applyInitialSolution();
571 
572  // write initial condition
573  if (problem_->shouldWriteOutput())
574  problem_->writeOutput();
575 
576  timeStepSize_ = oldTimeStepSize;
577  timeStepIdx_ = oldTimeStepIdx;
578  }
579  setupTimer_.stop();
580 
581  executionTimer_.start();
582  bool episodeBegins = episodeIsOver() || (timeStepIdx_ == 0);
583  // do the time steps
584  while (!finished()) {
585  prePostProcessTimer_.start();
586  if (episodeBegins) {
587  // notify the problem that a new episode has just been
588  // started.
589  problem_->beginEpisode();
590 
591  if (finished()) {
592  // the problem can chose to terminate the simulation in
593  // beginEpisode(), so we have handle this case.
594  problem_->endEpisode();
595  prePostProcessTimer_.stop();
596  break;
597  }
598  }
599  episodeBegins = false;
600 
601  if (verbose_) {
602  std::cout << "Begin time step " << timeStepIndex() + 1 << ". "
603  << "Start time: " << this->time() << " seconds" << humanReadableTime(this->time())
604  << ", step size: " << timeStepSize() << " seconds" << humanReadableTime(timeStepSize())
605  << "\n";
606  }
607 
608  // pre-process the current solution
609  problem_->beginTimeStep();
610  if (finished()) {
611  // the problem can chose to terminate the simulation in
612  // beginTimeStep(), so we have handle this case.
613  problem_->endTimeStep();
614  problem_->endEpisode();
615  prePostProcessTimer_.stop();
616  break;
617  }
618  prePostProcessTimer_.stop();
619 
620  try {
621  // execute the time integration scheme
622  problem_->timeIntegration();
623  }
624  catch (...) {
625  const auto& model = problem_->model();
626  prePostProcessTimer_ += model.prePostProcessTimer();
627  linearizeTimer_ += model.linearizeTimer();
628  solveTimer_ += model.solveTimer();
629  updateTimer_ += model.updateTimer();
630 
631  throw;
632  }
633 
634  const auto& model = problem_->model();
635  prePostProcessTimer_ += model.prePostProcessTimer();
636  linearizeTimer_ += model.linearizeTimer();
637  solveTimer_ += model.solveTimer();
638  updateTimer_ += model.updateTimer();
639 
640  // post-process the current solution
641  prePostProcessTimer_.start();
642  problem_->endTimeStep();
643  prePostProcessTimer_.stop();
644 
645  // write the result to disk
646  writeTimer_.start();
647  if (problem_->shouldWriteOutput())
648  problem_->writeOutput();
649  writeTimer_.stop();
650 
651  // do the next time integration
652  Scalar oldDt = timeStepSize();
653  problem_->advanceTimeLevel();
654 
655 
656  if (verbose_) {
657  std::cout << "Time step " << timeStepIndex() + 1 << " done. "
658  << "CPU time: " << executionTimer_.realTimeElapsed() << " seconds" << humanReadableTime(executionTimer_.realTimeElapsed())
659  << ", end time: " << this->time() + oldDt << " seconds" << humanReadableTime(this->time() + oldDt)
660  << ", step size: " << oldDt << " seconds" << humanReadableTime(oldDt)
661  << "\n" << std::flush;
662  }
663 
664  // advance the simulated time by the current time step size
665  time_ += oldDt;
666  ++timeStepIdx_;
667 
668  prePostProcessTimer_.start();
669  // notify the problem if an episode is finished
670  if (episodeIsOver()) {
671  // Notify the problem about the end of the current episode...
672  problem_->endEpisode();
673  episodeBegins = true;
674  }
675  else {
676  Scalar dt;
677  if (timeStepIdx_ < static_cast<int>(forcedTimeSteps_.size())) {
678  // use the next time step size from the input file
679  dt = forcedTimeSteps_[timeStepIdx_];
680  }
681  else {
682  // ask the problem to provide the next time step size
683  dt = problem_->nextTimeStepSize();
684  }
685 
686  setTimeStepSize(dt);
687  }
688  prePostProcessTimer_.stop();
689 
690  // write restart file if mandated by the problem
691  writeTimer_.start();
692  if (problem_->shouldWriteRestartFile())
693  serialize();
694  writeTimer_.stop();
695  }
696  executionTimer_.stop();
697 
698  problem_->finalize();
699  }
700 
707  static std::string humanReadableTime(Scalar timeInSeconds, bool isAmendment=true)
708  {
709  std::ostringstream oss;
710  oss << std::setprecision(4);
711  if (isAmendment)
712  oss << " (";
713  if (timeInSeconds >= 365.25*24*60*60) {
714  int years = static_cast<int>(timeInSeconds/(365.25*24*60*60));
715  int days = static_cast<int>((timeInSeconds - years*(365.25*24*60*60))/(24*60*60));
716 
717  double accuracy = 1e-2;
718  double hours =
719  std::round(1.0/accuracy*
720  (timeInSeconds
721  - years*(365.25*24*60*60)
722  - days*(24*60*60))/(60*60))
723  *accuracy;
724 
725  oss << years << " years, " << days << " days, " << hours << " hours";
726  }
727  else if (timeInSeconds >= 24.0*60*60) {
728  int days = static_cast<int>(timeInSeconds/(24*60*60));
729  int hours = static_cast<int>((timeInSeconds - days*(24*60*60))/(60*60));
730 
731  double accuracy = 1e-2;
732  double minutes =
733  std::round(1.0/accuracy*
734  (timeInSeconds
735  - days*(24*60*60)
736  - hours*(60*60))/60)
737  *accuracy;
738 
739  oss << days << " days, " << hours << " hours, " << minutes << " minutes";
740  }
741  else if (timeInSeconds >= 60.0*60) {
742  int hours = static_cast<int>(timeInSeconds/(60*60));
743  int minutes = static_cast<int>((timeInSeconds - hours*(60*60))/60);
744 
745  double accuracy = 1e-2;
746  double seconds =
747  std::round(1.0/accuracy*
748  (timeInSeconds
749  - hours*(60*60)
750  - minutes*60))
751  *accuracy;
752 
753  oss << hours << " hours, " << minutes << " minutes, " << seconds << " seconds";
754  }
755  else if (timeInSeconds >= 60.0) {
756  int minutes = static_cast<int>(timeInSeconds/60);
757 
758  double accuracy = 1e-3;
759  double seconds =
760  std::round(1.0/accuracy*
761  (timeInSeconds
762  - minutes*60))
763  *accuracy;
764 
765  oss << minutes << " minutes, " << seconds << " seconds";
766  }
767  else if (!isAmendment)
768  oss << timeInSeconds << " seconds";
769  else
770  return "";
771  if (isAmendment)
772  oss << ")";
773 
774  return oss.str();
775  }
776 
791  void serialize()
792  {
793  typedef Ewoms::Restart Restarter;
794  Restarter res;
795  res.serializeBegin(*this);
796  if (gridView().comm().rank() == 0)
797  std::cout << "Serialize to file '" << res.fileName() << "'"
798  << ", next time step size: " << timeStepSize()
799  << "\n" << std::flush;
800 
801  this->serialize(res);
802  problem_->serialize(res);
803  model_->serialize(res);
804  res.serializeEnd();
805  }
806 
814  template <class Restarter>
815  void serialize(Restarter& restarter)
816  {
817  restarter.serializeSectionBegin("Simulator");
818  restarter.serializeStream()
819  << episodeIdx_ << " "
820  << episodeStartTime_ << " "
821  << episodeLength_ << " "
822  << startTime_ << " "
823  << time_ << " "
824  << timeStepIdx_ << " ";
825  restarter.serializeSectionEnd();
826  }
827 
835  template <class Restarter>
836  void deserialize(Restarter& restarter)
837  {
838  restarter.deserializeSectionBegin("Simulator");
839  restarter.deserializeStream()
840  >> episodeIdx_
841  >> episodeStartTime_
842  >> episodeLength_
843  >> startTime_
844  >> time_
845  >> timeStepIdx_;
846  restarter.deserializeSectionEnd();
847  }
848 
849 private:
850  std::unique_ptr<GridManager> gridManager_;
851  std::unique_ptr<Model> model_;
852  std::unique_ptr<Problem> problem_;
853 
854  int episodeIdx_;
855  Scalar episodeStartTime_;
856  Scalar episodeLength_;
857 
858  Ewoms::Timer setupTimer_;
859  Ewoms::Timer executionTimer_;
860  Ewoms::Timer prePostProcessTimer_;
861  Ewoms::Timer linearizeTimer_;
862  Ewoms::Timer solveTimer_;
863  Ewoms::Timer updateTimer_;
864  Ewoms::Timer writeTimer_;
865 
866  std::vector<Scalar> forcedTimeSteps_;
867  Scalar startTime_;
868  Scalar time_;
869  Scalar endTime_;
870 
871  Scalar timeStepSize_;
872  int timeStepIdx_;
873 
874  bool finished_;
875  bool verbose_;
876 };
877 } // namespace Ewoms
878 
879 #endif
A simple class which makes sure that a timer gets stopped if an exception is thrown.
Definition: timerguard.hh:40
void setEpisodeLength(Scalar dt)
Sets the length in seconds of the current episode.
Definition: simulator.hh:467
Scalar maxTimeStepSize() const
Aligns the time step size to the episode boundary and to the end time of the simulation.
Definition: simulator.hh:403
bool willBeFinished() const
Returns true if the simulation is finished after the time level is incremented by the current time st...
Definition: simulator.hh:392
void serializeBegin(Simulator &simulator)
Write the current state of the model to disk.
Definition: restart.hh:97
void run()
Runs the simulation using a given problem class.
Definition: simulator.hh:530
Scalar episodeMaxTimeStepSize() const
Aligns the time step size to the episode boundary if the current time step crosses the boundary of th...
Definition: simulator.hh:504
void deserializeEnd()
Stop reading the restart file.
Definition: restart.hh:265
void setEndTime(Scalar t)
Set the time of simulated seconds at which the simulation runs.
Definition: simulator.hh:262
void start()
Start counting the time resources used by the simulation.
Definition: timer.hh:62
Scalar episodeLength() const
Returns the length of the current episode in simulated time .
Definition: simulator.hh:474
void setTime(Scalar t)
Set the current simulated time, don&#39;t change the current time step index.
Definition: simulator.hh:232
Definition: baseauxiliarymodule.hh:37
Model & model()
Return the physical model used in the simulation.
Definition: simulator.hh:189
Scalar episodeStartTime() const
Returns the absolute time when the current episode started .
Definition: simulator.hh:459
static void registerParameters()
Registers all runtime parameters used by the simulation.
Definition: simulator.hh:151
int timeStepIndex() const
Returns number of time steps which have been executed since the beginning of the simulation.
Definition: simulator.hh:360
Scalar startTime() const
Return the time of the start of the simulation.
Definition: simulator.hh:223
Problem & problem()
Return the object which specifies the pysical setup of the simulation.
Definition: simulator.hh:202
void startNextEpisode(Scalar len=std::numeric_limits< Scalar >::max())
Start the next episode, but don&#39;t change the episode identifier.
Definition: simulator.hh:432
bool finished() const
Returns true if the simulation is finished.
Definition: simulator.hh:379
bool episodeIsOver() const
Returns true if the current episode is finished at the current time.
Definition: simulator.hh:481
void serialize(Restarter &restarter)
Write the time manager&#39;s state to a restart file.
Definition: simulator.hh:815
Load or save a state of a problem to/from the harddisk.
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
const Ewoms::Timer & solveTimer() const
Returns a reference to the timer object which measures the time needed by the solver.
Definition: simulator.hh:304
GridManager & gridManager()
Return a reference to the grid manager of simulation.
Definition: simulator.hh:171
This file provides the infrastructure to retrieve run-time parameters.
const std::string & fileName() const
Returns the name of the file which is (de-)serialized.
Definition: restart.hh:90
void setEpisodeIndex(int episodeIdx)
Sets the index of the current episode.
Definition: simulator.hh:444
void serialize()
This method writes the complete state of the simulation to the harddisk.
Definition: simulator.hh:791
Provides an encapsulation to measure the system time.
Definition: timer.hh:48
const GridView & gridView() const
Return the grid view for which the simulation is done.
Definition: simulator.hh:183
double realTimeElapsed() const
Return the real time [s] elapsed during the periods the timer was active since the last reset...
Definition: timer.hh:121
const Ewoms::Timer & prePostProcessTimer() const
Returns a reference to the timer object which measures the time needed for pre- and postprocessing of...
Definition: simulator.hh:290
const Problem & problem() const
Return the object which specifies the pysical setup of the simulation.
Definition: simulator.hh:209
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
void setTimeStepSize(Scalar value)
Set the current time step size to a given value.
Definition: simulator.hh:331
void setTimeStepIndex(unsigned value)
Set the current time step index to a given value.
Definition: simulator.hh:339
const Ewoms::Timer & writeTimer() const
Returns a reference to the timer object which measures the time needed to write the visualization out...
Definition: simulator.hh:318
void setTime(Scalar t, unsigned stepIdx)
Set the current simulated time and the time step index.
Definition: simulator.hh:241
Provides an encapsulation to measure the system time.
Load or save a state of a problem to/from the harddisk.
Definition: restart.hh:43
Provides the magic behind the eWoms property system.
const Ewoms::Timer & updateTimer() const
Returns a reference to the timer object which measures the time needed to the solutions of the non-li...
Definition: simulator.hh:311
void setStartTime(Scalar t)
Set the time of the start of the simulation.
Definition: simulator.hh:217
int episodeIndex() const
Returns the index of the current episode.
Definition: simulator.hh:452
const Ewoms::Timer & linearizeTimer() const
Returns a reference to the timer object which measures the time needed for linarizing the solutions...
Definition: simulator.hh:297
A simple class which makes sure that a timer gets stopped if an exception is thrown.
Scalar timeStepSize() const
Returns the time step length so that we don&#39;t miss the beginning of the next episode or cross the en...
Definition: simulator.hh:347
void deserialize(Restarter &restarter)
Read the time manager&#39;s state from a restart file.
Definition: simulator.hh:836
static std::string humanReadableTime(Scalar timeInSeconds, bool isAmendment=true)
Given a time step size in seconds, return it in a format which is more easily parsable by humans...
Definition: simulator.hh:707
const Ewoms::Timer & executionTimer() const
Returns a reference to the timer object which measures the time needed to run the simulation...
Definition: simulator.hh:283
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
void deserializeBegin(Simulator &simulator, Scalar t)
Start reading a restart file at a certain simulated time.
Definition: restart.hh:167
const Ewoms::Timer & setupTimer() const
Returns a reference to the timer object which measures the time needed to set up and initialize the s...
Definition: simulator.hh:276
void startNextEpisode(Scalar episodeStartTime, Scalar episodeLength)
Change the current episode of the simulation.
Definition: simulator.hh:418
bool episodeWillBeOver() const
Returns true if the current episode will be finished after the current time step. ...
Definition: simulator.hh:492
void setFinished(bool yesno=true)
Specify whether the simulation is finished.
Definition: simulator.hh:370
const GridManager & gridManager() const
Return a reference to the grid manager of simulation.
Definition: simulator.hh:177
Scalar time() const
Return the number of seconds of simulated time which have elapsed since the start time...
Definition: simulator.hh:254
double stop()
Stop counting the time resources.
Definition: timer.hh:73
const Model & model() const
Return the physical model used in the simulation.
Definition: simulator.hh:195
Scalar endTime() const
Returns the number of (simulated) seconds which the simulation runs.
Definition: simulator.hh:269