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#if HAVE_MPI
32#define RESERVOIR_COUPLING_ENABLED
33#endif
34
35#include <dune/common/parallel/mpihelper.hh>
36
38
40
47
49
50#include <algorithm>
51#include <cassert>
52#include <iostream>
53#include <limits>
54#include <memory>
55#include <string>
56#include <vector>
57
58#ifdef RESERVOIR_COUPLING_ENABLED
59namespace Opm {
60 template<class Scalar> class ReservoirCouplingMaster;
61 template<class Scalar> class ReservoirCouplingSlave;
62}
63#endif
64
65namespace Opm {
66
67 // required as std::max is not constexpr for float128 / quads.
68 template <typename T>
69 static constexpr T constexpr_max(T a, T b) {
70 return (a > b) ? a : b;
71 }
72
85template <class TypeTag>
87{
93
94 using MPIComm = typename Dune::MPIHelper::MPICommunicator;
95 using Communication = Dune::Communication<MPIComm>;
96
97 // \Note: too small eps can not rule out confusion from the rounding errors, as we use 1.e-9 as a minimum.
98 static constexpr Scalar eps =
99 constexpr_max(std::numeric_limits<Scalar>::epsilon(), static_cast<Scalar>(1.0e-9));
100
101public:
102 // do not allow to copy simulators around
103 Simulator(const Simulator&) = delete;
104
105 explicit Simulator(bool verbose = true)
106 : Simulator(Communication(), verbose)
107 {
108 }
109
110 explicit Simulator(Communication comm, bool verbose = true)
111 {
112 TimerGuard setupTimerGuard(setupTimer_);
113
114 setupTimer_.start();
115
116 verbose_ = verbose && comm.rank() == 0;
117
118 timeStepIdx_ = 0;
119 startTime_ = 0.0;
120 time_ = 0.0;
121 endTime_ = Parameters::Get<Parameters::EndTime<Scalar>>();
122 timeStepSize_ = Parameters::Get<Parameters::InitialTimeStepSize<Scalar>>();
123 assert(timeStepSize_ > 0);
124 const std::string& predetTimeStepFile =
125 Parameters::Get<Parameters::PredeterminedTimeStepsFile>();
126 if (!predetTimeStepFile.empty()) {
127 forcedTimeSteps_ = readTimeStepFile<Scalar>(predetTimeStepFile);
128 }
129 truncateTimeStepToFloat_ = Parameters::Get<Parameters::TruncateTimeStepToFloat>();
130
131 episodeIdx_ = 0;
132 episodeStartTime_ = 0;
133 episodeLength_ = std::numeric_limits<Scalar>::max();
134
135 finished_ = false;
136
137 if (verbose_) {
138 std::cout << "Allocating the simulation vanguard\n" << std::flush;
139 }
140
141 {
143 vanguard_ = std::make_unique<Vanguard>(*this);
144 OPM_END_PARALLEL_TRY_CATCH("Allocating the simulation vanguard failed: ", comm);
145 }
146
147 if (verbose_) {
148 std::cout << "Distributing the vanguard's data\n" << std::flush;
149 }
150
151 {
153 vanguard_->loadBalance();
154 OPM_END_PARALLEL_TRY_CATCH("Could not distribute the vanguard data: ", comm);
155 }
156
157 // Only relevant for CpGrid and serial runs.
158 if (verbose_) {
159 std::cout << "Adding LGRs, if any, in serial run\n" << std::flush;
160 }
161
162 {
164 vanguard_->addLgrs();
165 OPM_END_PARALLEL_TRY_CATCH("Adding LGRs to the simulation vanguard in serial run failed: ", comm);
166 }
167
168 if (verbose_) {
169 std::cout << "Allocating the model\n" << std::flush;
170 }
171
172 {
174 model_ = std::make_unique<Model>(*this);
175 OPM_END_PARALLEL_TRY_CATCH("Could not allocate model: ", comm);
176 }
177
178 if (verbose_) {
179 std::cout << "Allocating the problem\n" << std::flush;
180 }
181
182 {
184 problem_ = std::make_unique<Problem>(*this);
185 OPM_END_PARALLEL_TRY_CATCH("Could not allocate the problem: ", comm);
186 }
187
188 if (verbose_) {
189 std::cout << "Initializing the model\n" << std::flush;
190 }
191
192 {
194 model_->finishInit();
195 OPM_END_PARALLEL_TRY_CATCH("Could not initialize the model: ", comm);
196 }
197
198 if (verbose_) {
199 std::cout << "Initializing the problem\n" << std::flush;
200 }
201
202 {
204 problem_->finishInit();
205 OPM_END_PARALLEL_TRY_CATCH("Could not initialize the problem: ", comm);
206 }
207
208 setupTimer_.stop();
209
210 if (verbose_) {
211 std::cout << "Simulator successfully set up\n" << std::flush;
212 }
213 }
214
218 static void registerParameters()
219 {
220 Parameters::Register<Parameters::EndTime<Scalar>>
221 ("The simulation time at which the simulation is finished [s]");
222 Parameters::Register<Parameters::InitialTimeStepSize<Scalar>>
223 ("The size of the initial time step [s]");
224 Parameters::Register<Parameters::RestartTime<Scalar>>
225 ("The simulation time at which a restart should be attempted [s]");
226 Parameters::Register<Parameters::PredeterminedTimeStepsFile>
227 ("A file with a list of predetermined time step sizes "
228 "(one time step per line)");
229 Parameters::Register<Parameters::TruncateTimeStepToFloat>
230 ("Truncate the time step size to float precision. Only used to make "
231 "time steps reproducible for the timestep-replay regression test; "
232 "do not enable for production runs.");
233
234 Vanguard::registerParameters();
235 Model::registerParameters();
236 Problem::registerParameters();
237 }
238
242 Vanguard& vanguard()
243 { return *vanguard_; }
244
248 const Vanguard& vanguard() const
249 { return *vanguard_; }
250
254 const GridView& gridView() const
255 { return vanguard_->gridView(); }
256
260 Model& model()
261 { return *model_; }
262
266 const Model& model() const
267 { return *model_; }
268
273 Problem& problem()
274 { return *problem_; }
275
280 const Problem& problem() const
281 { return *problem_; }
282
288 void setStartTime(Scalar t)
289 { startTime_ = t; }
290
294 Scalar startTime() const
295 { return startTime_; }
296
303 void setTime(Scalar t)
304 { time_ = t; }
305
312 void setTime(Scalar t, unsigned stepIdx)
313 {
314 time_ = t;
315 timeStepIdx_ = stepIdx;
316 }
317
325 Scalar time() const
326 { return time_; }
327
333 void setEndTime(Scalar t)
334 { endTime_ = t; }
335
340 Scalar endTime() const
341 { return endTime_; }
342
347 const Timer& setupTimer() const
348 { return setupTimer_; }
349
354 const Timer& executionTimer() const
355 { return executionTimer_; }
356
358 { return executionTimer_; }
359
365 { return prePostProcessTimer_; }
366
371 const Timer& linearizeTimer() const
372 { return linearizeTimer_; }
373
378 const Timer& solveTimer() const
379 { return solveTimer_; }
380
385 const Timer& updateTimer() const
386 { return updateTimer_; }
387
392 const Timer& writeTimer() const
393 { return writeTimer_; }
394
405 void setTimeStepSize(Scalar value)
406 { timeStepSize_ = truncateTimeStepToFloat_ ? static_cast<Scalar>(float(value)) : value; }
407
413 void setTimeStepIndex(unsigned value)
414 { timeStepIdx_ = value; }
415
421 Scalar timeStepSize() const
422 { return timeStepSize_; }
423
428 int timeStepIndex() const
429 { return timeStepIdx_; }
430
438 void setFinished(bool yesno = true)
439 { finished_ = yesno; }
440
447 bool finished() const
448 {
449 assert(timeStepSize_ >= 0.0);
450 return finished_ || (this->time() * (1.0 + eps) >= endTime());
451 }
452
457 bool willBeFinished() const
458 {
459 return finished_ || (this->time() + timeStepSize_) * (1.0 + eps) >= endTime();
460 }
461
466 Scalar maxTimeStepSize() const
467 {
468 if (finished()) {
469 return 0.0;
470 }
471
472 return std::min(episodeMaxTimeStepSize(),
473 std::max<Scalar>(0.0, endTime() - this->time()));
474 }
475
483 {
484 ++episodeIdx_;
485 episodeStartTime_ = episodeStartTime;
486 episodeLength_ = episodeLength;
487 }
488
496 void startNextEpisode(Scalar len = std::numeric_limits<Scalar>::max())
497 {
498 ++episodeIdx_;
499 episodeStartTime_ = startTime_ + time_;
500 episodeLength_ = len;
501 }
502
508 void setEpisodeIndex(int episodeIdx)
509 { episodeIdx_ = episodeIdx; }
510
516 int episodeIndex() const
517 { return episodeIdx_; }
518
523 Scalar episodeStartTime() const
524 { return episodeStartTime_; }
525
531 void setEpisodeLength(Scalar dt)
532 { episodeLength_ = dt; }
533
538 Scalar episodeLength() const
539 { return episodeLength_; }
540
545 bool episodeStarts() const
546 {
547 return this->time() <= (episodeStartTime_ - startTime()) * (1 + eps);
548 }
549
554 bool episodeIsOver() const
555 {
556 return this->time() >= (episodeStartTime_ - startTime() + episodeLength()) * (1 - eps);
557 }
558
563 bool episodeWillBeOver() const
564 {
565 return this->time() + timeStepSize()
566 >= (episodeStartTime_ - startTime() + episodeLength()) * (1 - eps);
567 }
568
574 {
575 // if the current episode is over and the simulation
576 // wants to give it some extra time, we will return
577 // the time step size it suggested instead of trying
578 // to align it to the end of the episode.
579 if (episodeIsOver()) {
580 return 0.0;
581 }
582
583 // make sure that we don't exceed the end of the
584 // current episode.
585 return std::max<Scalar>(0.0,
587 (this->time() + this->startTime()));
588 }
589
590 /*
591 * \}
592 */
593
600 void run()
601 {
602 // create TimerGuard objects to hedge for exceptions
603 TimerGuard setupTimerGuard(setupTimer_);
604 TimerGuard executionTimerGuard(executionTimer_);
605 TimerGuard prePostProcessTimerGuard(prePostProcessTimer_);
606 TimerGuard writeTimerGuard(writeTimer_);
607
608 setupTimer_.start();
609 const Scalar restartTime = Parameters::Get<Parameters::RestartTime<Scalar>>();
610 if (restartTime > -1e30) {
611 // try to restart a previous simulation
612 time_ = restartTime;
613
615 Restart res;
616 res.deserializeBegin(*this, time_);
617
618 if (verbose_) {
619 std::cout << "Deserialize from file '" << res.fileName() << "'\n" << std::flush;
620 }
621
622 this->deserialize(res);
623 problem_->deserialize(res);
624 model_->deserialize(res);
625 res.deserializeEnd();
626 OPM_END_PARALLEL_TRY_CATCH("Deserialization failed: ",
627 Dune::MPIHelper::getCommunication());
628 if (verbose_) {
629 std::cout << "Deserialization done."
630 << " Simulator time: " << time() << humanReadableTime(time())
631 << " Time step index: " << timeStepIndex()
632 << " Episode index: " << episodeIndex()
633 << "\n" << std::flush;
634 }
635 }
636 else {
637 // if no restart is done, apply the initial solution
638 if (verbose_) {
639 std::cout << "Applying the initial solution of the \"" << problem_->name()
640 << "\" problem\n" << std::flush;
641 }
642
643 const Scalar oldTimeStepSize = timeStepSize_;
644 const int oldTimeStepIdx = timeStepIdx_;
645 timeStepSize_ = 0.0;
646 timeStepIdx_ = -1;
647
648 {
650 model_->applyInitialSolution();
651 OPM_END_PARALLEL_TRY_CATCH("Apply initial solution failed: ",
652 Dune::MPIHelper::getCommunication());
653 }
654
655 // write initial condition
656 if (problem_->shouldWriteOutput()) {
658 problem_->writeOutput(true);
659 OPM_END_PARALLEL_TRY_CATCH("Write output failed: ",
660 Dune::MPIHelper::getCommunication());
661 }
662
663 timeStepSize_ = oldTimeStepSize;
664 timeStepIdx_ = oldTimeStepIdx;
665 }
666 setupTimer_.stop();
667
668 executionTimer_.start();
669 bool episodeBegins = episodeIsOver() || (timeStepIdx_ == 0);
670 // do the time steps
671 while (!finished()) {
672 prePostProcessTimer_.start();
673 if (episodeBegins) {
674 // notify the problem that a new episode has just been
675 // started.
676 {
678 problem_->beginEpisode();
679 OPM_END_PARALLEL_TRY_CATCH("Begin episode failed: ",
680 Dune::MPIHelper::getCommunication());
681 }
682
683 if (finished()) {
684 // the problem can chose to terminate the simulation in
685 // beginEpisode(), so we have handle this case.
687 problem_->endEpisode();
688 OPM_END_PARALLEL_TRY_CATCH("End episode failed: ",
689 Dune::MPIHelper::getCommunication());
690 prePostProcessTimer_.stop();
691
692 break;
693 }
694 }
695 episodeBegins = false;
696
697 if (verbose_) {
698 std::cout << "Begin time step " << timeStepIndex() + 1 << ". "
699 << "Start time: " << this->time() << " seconds" << humanReadableTime(this->time())
700 << ", step size: " << timeStepSize() << " seconds" << humanReadableTime(timeStepSize())
701 << "\n";
702 }
703
704 // pre-process the current solution
705 {
707 problem_->beginTimeStep();
708 OPM_END_PARALLEL_TRY_CATCH("Begin timestep failed: ",
709 Dune::MPIHelper::getCommunication());
710 }
711
712 if (finished()) {
713 // the problem can choose to terminate the simulation in
714 // beginTimeStep(), so we have handle this case.
716 problem_->endTimeStep();
717 problem_->endEpisode();
718 OPM_END_PARALLEL_TRY_CATCH("Finish failed: ",
719 Dune::MPIHelper::getCommunication());
720 prePostProcessTimer_.stop();
721
722 break;
723 }
724 prePostProcessTimer_.stop();
725
726 try {
727 // execute the time integration scheme
728 problem_->timeIntegration();
729 }
730 catch (...) {
731 // exceptions in the time integration might be recoverable. clean up in
732 // case they are
733 const auto& pmodel = problem_->model();
734 prePostProcessTimer_ += pmodel.prePostProcessTimer();
735 linearizeTimer_ += pmodel.linearizeTimer();
736 solveTimer_ += pmodel.solveTimer();
737 updateTimer_ += pmodel.updateTimer();
738
739 throw;
740 }
741
742 const auto& pmodel = problem_->model();
743 prePostProcessTimer_ += pmodel.prePostProcessTimer();
744 linearizeTimer_ += pmodel.linearizeTimer();
745 solveTimer_ += pmodel.solveTimer();
746 updateTimer_ += pmodel.updateTimer();
747
748 // post-process the current solution
749 prePostProcessTimer_.start();
750 {
752 problem_->endTimeStep();
753 OPM_END_PARALLEL_TRY_CATCH("End timestep failed: ",
754 Dune::MPIHelper::getCommunication());
755 }
756 prePostProcessTimer_.stop();
757
758 // write the result to disk
759 writeTimer_.start();
760 if (problem_->shouldWriteOutput()) {
762 problem_->writeOutput(true);
763 OPM_END_PARALLEL_TRY_CATCH("Write output failed: ",
764 Dune::MPIHelper::getCommunication());
765 }
766 writeTimer_.stop();
767
768 // do the next time integration
769 const Scalar oldDt = timeStepSize();
770 {
772 problem_->advanceTimeLevel();
773 OPM_END_PARALLEL_TRY_CATCH("Advance time level failed: ",
774 Dune::MPIHelper::getCommunication());
775 }
776
777 if (verbose_) {
778 std::cout << "Time step " << timeStepIndex() + 1 << " done. "
779 << "CPU time: " << executionTimer_.realTimeElapsed()
780 << " seconds" << humanReadableTime(executionTimer_.realTimeElapsed())
781 << ", end time: " << this->time() + oldDt << " seconds"
782 << humanReadableTime(this->time() + oldDt)
783 << ", step size: " << oldDt << " seconds" << humanReadableTime(oldDt)
784 << "\n" << std::flush;
785 }
786
787 // advance the simulated time by the current time step size
788 time_ += oldDt;
789 ++timeStepIdx_;
790
791 prePostProcessTimer_.start();
792 // notify the problem if an episode is finished
793 if (episodeIsOver()) {
794 // Notify the problem about the end of the current episode...
796 problem_->endEpisode();
797 OPM_END_PARALLEL_TRY_CATCH("End episode failed: ",
798 Dune::MPIHelper::getCommunication());
799 episodeBegins = true;
800 }
801 else {
802 Scalar dt;
803 if (timeStepIdx_ < static_cast<int>(forcedTimeSteps_.size())) {
804 // use the next time step size from the input file
805 dt = forcedTimeSteps_[timeStepIdx_];
806 }
807 else {
808 // ask the problem to provide the next time step size
809 dt = std::min(maxTimeStepSize(), problem_->nextTimeStepSize());
810 }
811 assert(finished() || dt > 0);
812 setTimeStepSize(dt);
813 }
814 prePostProcessTimer_.stop();
815
816 // write restart file if mandated by the problem
817 writeTimer_.start();
818 if (problem_->shouldWriteRestartFile()) {
820 serialize();
821 OPM_END_PARALLEL_TRY_CATCH("Serialize failed: ",
822 Dune::MPIHelper::getCommunication());
823 }
824 writeTimer_.stop();
825 }
826 executionTimer_.stop();
827
828 {
830 problem_->finalize();
831 OPM_END_PARALLEL_TRY_CATCH("Finalize failed: ",
832 Dune::MPIHelper::getCommunication());
833 }
834 }
835
836#ifdef RESERVOIR_COUPLING_ENABLED
838 {
839 return reservoirCouplingMaster_;
840 }
842 {
843 return reservoirCouplingSlave_;
844 }
846 {
847 this->reservoirCouplingMaster_ = reservoirCouplingMaster;
848 }
850 {
851 this->reservoirCouplingSlave_ = reservoirCouplingSlave;
852 }
853#endif
854
870 {
871 using Restarter = Restart;
872 Restarter res;
873 res.serializeBegin(*this);
874 if (gridView().comm().rank() == 0) {
875 std::cout << "Serialize to file '" << res.fileName() << "'"
876 << ", next time step size: " << timeStepSize()
877 << "\n" << std::flush;
878 }
879
880 this->serialize(res);
881 problem_->serialize(res);
882 model_->serialize(res);
883 res.serializeEnd();
884 }
885
893 template <class Restarter>
894 void serialize(Restarter& restarter)
895 {
896 restarter.serializeSectionBegin("Simulator");
897 restarter.serializeStream()
898 << episodeIdx_ << " "
899 << episodeStartTime_ << " "
900 << episodeLength_ << " "
901 << startTime_ << " "
902 << time_ << " "
903 << timeStepIdx_ << " ";
904 restarter.serializeSectionEnd();
905 }
906
914 template <class Restarter>
915 void deserialize(Restarter& restarter)
916 {
917 restarter.deserializeSectionBegin("Simulator");
918 restarter.deserializeStream()
919 >> episodeIdx_
920 >> episodeStartTime_
921 >> episodeLength_
922 >> startTime_
923 >> time_
924 >> timeStepIdx_;
925 restarter.deserializeSectionEnd();
926 }
927
928 template<class Serializer>
929 void serializeOp(Serializer& serializer)
930 {
931 serializer(*vanguard_);
932 serializer(*model_);
933 serializer(*problem_);
934 serializer(episodeIdx_);
935 serializer(episodeStartTime_);
936 serializer(episodeLength_);
937 serializer(startTime_);
938 serializer(time_);
939 serializer(timeStepIdx_);
940 }
941
942private:
943 std::unique_ptr<Vanguard> vanguard_;
944 std::unique_ptr<Model> model_;
945 std::unique_ptr<Problem> problem_;
946
947 int episodeIdx_;
948 Scalar episodeStartTime_;
949 Scalar episodeLength_;
950
951 Timer setupTimer_;
952 Timer executionTimer_;
953 Timer prePostProcessTimer_;
954 Timer linearizeTimer_;
955 Timer solveTimer_;
956 Timer updateTimer_;
957 Timer writeTimer_;
958
959 std::vector<Scalar> forcedTimeSteps_;
960 Scalar startTime_;
961 Scalar time_;
962 Scalar endTime_;
963
964 Scalar timeStepSize_;
965 int timeStepIdx_;
966
967 bool finished_;
968 bool verbose_;
969 bool truncateTimeStepToFloat_ = false;
970
971#ifdef RESERVOIR_COUPLING_ENABLED
972 ReservoirCouplingMaster<Scalar>* reservoirCouplingMaster_ = nullptr;
973 ReservoirCouplingSlave<Scalar>* reservoirCouplingSlave_ = nullptr;
974#endif
975
976};
977
978namespace Properties {
979template<class TypeTag>
980struct Simulator<TypeTag, TTag::NumericModel>
982}
983
984} // namespace Opm
985
986#endif
#define OPM_END_PARALLEL_TRY_CATCH(prefix, comm)
Catch exception and throw in a parallel try-catch clause.
Definition: DeferredLoggingErrorHelpers.hpp:197
#define OPM_BEGIN_PARALLEL_TRY_CATCH()
Macro to setup the try of a parallel try-catch.
Definition: DeferredLoggingErrorHelpers.hpp:160
Defines a type tags and some fundamental properties all models.
Definition: ReservoirCouplingMaster.hpp:38
Definition: ReservoirCouplingSlave.hpp:40
Load or save a state of a problem to/from the harddisk.
Definition: restart.hpp:45
void serializeBegin(Simulator &simulator)
Write the current state of the model to disk.
Definition: restart.hpp:92
const std::string & fileName() const
Returns the name of the file which is (de-)serialized.
Definition: restart.hpp:85
void deserializeBegin(Simulator &simulator, Scalar t)
Start reading a restart file at a certain simulated time.
Definition: restart.hpp:147
void deserializeEnd()
Stop reading the restart file.
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:87
const Timer & writeTimer() const
Returns a reference to the timer object which measures the time needed to write the visualization out...
Definition: simulator.hh:392
Scalar timeStepSize() const
Returns the time step length so that we don't miss the beginning of the next episode or cross the en...
Definition: simulator.hh:421
Scalar startTime() const
Return the time of the start of the simulation.
Definition: simulator.hh:294
void setReservoirCouplingMaster(ReservoirCouplingMaster< Scalar > *reservoirCouplingMaster)
Definition: simulator.hh:845
int timeStepIndex() const
Returns number of time steps which have been executed since the beginning of the simulation.
Definition: simulator.hh:428
void serialize()
This method writes the complete state of the simulation to the harddisk.
Definition: simulator.hh:869
Timer & executionTimer()
Definition: simulator.hh:357
Scalar episodeLength() const
Returns the length of the current episode in simulated time .
Definition: simulator.hh:538
const Timer & prePostProcessTimer() const
Returns a reference to the timer object which measures the time needed for pre- and postprocessing of...
Definition: simulator.hh:364
const Timer & solveTimer() const
Returns a reference to the timer object which measures the time needed by the solver.
Definition: simulator.hh:378
void startNextEpisode(Scalar len=std::numeric_limits< Scalar >::max())
Start the next episode, but don't change the episode identifier.
Definition: simulator.hh:496
void serializeOp(Serializer &serializer)
Definition: simulator.hh:929
const Vanguard & vanguard() const
Return a reference to the grid manager of simulation.
Definition: simulator.hh:248
void serialize(Restarter &restarter)
Write the time manager's state to a restart file.
Definition: simulator.hh:894
const 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:385
const Timer & executionTimer() const
Returns a reference to the timer object which measures the time needed to run the simulation.
Definition: simulator.hh:354
void startNextEpisode(Scalar episodeStartTime, Scalar episodeLength)
Change the current episode of the simulation.
Definition: simulator.hh:482
void setEndTime(Scalar t)
Set the time of simulated seconds at which the simulation runs.
Definition: simulator.hh:333
const Timer & linearizeTimer() const
Returns a reference to the timer object which measures the time needed for linarizing the solutions.
Definition: simulator.hh:371
void setStartTime(Scalar t)
Set the time of the start of the simulation.
Definition: simulator.hh:288
ReservoirCouplingSlave< Scalar > * reservoirCouplingSlave() const
Definition: simulator.hh:841
void deserialize(Restarter &restarter)
Read the time manager's state from a restart file.
Definition: simulator.hh:915
Simulator(Communication comm, bool verbose=true)
Definition: simulator.hh:110
void setTimeStepSize(Scalar value)
Set the current time step size to a given value.
Definition: simulator.hh:405
bool episodeStarts() const
Returns true if the current episode has just been started at the current time.
Definition: simulator.hh:545
void run()
Runs the simulation using a given problem class.
Definition: simulator.hh:600
Vanguard & vanguard()
Return a reference to the grid manager of simulation.
Definition: simulator.hh:242
int episodeIndex() const
Returns the index of the current episode.
Definition: simulator.hh:516
void setTimeStepIndex(unsigned value)
Set the current time step index to a given value.
Definition: simulator.hh:413
void setFinished(bool yesno=true)
Specify whether the simulation is finished.
Definition: simulator.hh:438
Problem & problem()
Return the object which specifies the pysical setup of the simulation.
Definition: simulator.hh:273
static void registerParameters()
Registers all runtime parameters used by the simulation.
Definition: simulator.hh:218
void setTime(Scalar t)
Set the current simulated time, don't change the current time step index.
Definition: simulator.hh:303
bool willBeFinished() const
Returns true if the simulation is finished after the time level is incremented by the current time st...
Definition: simulator.hh:457
bool finished() const
Returns true if the simulation is finished.
Definition: simulator.hh:447
Scalar maxTimeStepSize() const
Aligns the time step size to the episode boundary and to the end time of the simulation.
Definition: simulator.hh:466
const Model & model() const
Return the physical model used in the simulation.
Definition: simulator.hh:266
Simulator(bool verbose=true)
Definition: simulator.hh:105
void setTime(Scalar t, unsigned stepIdx)
Set the current simulated time and the time step index.
Definition: simulator.hh:312
bool episodeIsOver() const
Returns true if the current episode is finished at the current time.
Definition: simulator.hh:554
Scalar endTime() const
Returns the number of (simulated) seconds which the simulation runs.
Definition: simulator.hh:340
void setReservoirCouplingSlave(ReservoirCouplingSlave< Scalar > *reservoirCouplingSlave)
Definition: simulator.hh:849
Simulator(const Simulator &)=delete
ReservoirCouplingMaster< Scalar > * reservoirCouplingMaster() const
Definition: simulator.hh:837
bool episodeWillBeOver() const
Returns true if the current episode will be finished after the current time step.
Definition: simulator.hh:563
const GridView & gridView() const
Return the grid view for which the simulation is done.
Definition: simulator.hh:254
void setEpisodeIndex(int episodeIdx)
Sets the index of the current episode.
Definition: simulator.hh:508
Scalar time() const
Return the number of seconds of simulated time which have elapsed since the start time.
Definition: simulator.hh:325
void setEpisodeLength(Scalar dt)
Sets the length in seconds of the current episode.
Definition: simulator.hh:531
const Problem & problem() const
Return the object which specifies the pysical setup of the simulation.
Definition: simulator.hh:280
Model & model()
Return the physical model used in the simulation.
Definition: simulator.hh:260
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:573
Scalar episodeStartTime() const
Returns the absolute time when the current episode started .
Definition: simulator.hh:523
const 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:347
A simple class which makes sure that a timer gets stopped if an exception is thrown.
Definition: timerguard.hh:42
Provides an encapsulation to measure the system time.
Definition: timer.hpp:46
void start()
Start counting the time resources used by the simulation.
double realTimeElapsed() const
Return the real time [s] elapsed during the periods the timer was active since the last reset.
double stop()
Stop counting the time resources.
Declare the properties used by the infrastructure code of the finite volume discretizations.
Definition: blackoilbioeffectsmodules.hh:45
static constexpr T constexpr_max(T a, T b)
Definition: simulator.hh:69
std::string humanReadableTime(double timeInSeconds, bool isAmendment=true)
Given a time step size in seconds, return it in a format which is more easily parsable by humans.
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:233
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
Manages the simulation time.
Definition: basicproperties.hh:120