My Project
Loading...
Searching...
No Matches
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 <dune/common/parallel/mpihelper.hh>
32
34
36
38
42#include <opm/models/utils/simulatorutils.hpp>
45
46#include <iostream>
47#include <memory>
48#include <string>
49#include <vector>
50
51#define EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(code) \
52 { \
53 const auto& comm = Dune::MPIHelper::getCommunication(); \
54 bool exceptionThrown = false; \
55 try { code; } \
56 catch (const Dune::Exception& e) { \
57 exceptionThrown = true; \
58 std::cerr << "Process " << comm.rank() << " threw a fatal exception: " \
59 << e.what() << ". Abort!" << std::endl; \
60 } \
61 catch (const std::exception& e) { \
62 exceptionThrown = true; \
63 std::cerr << "Process " << comm.rank() << " threw a fatal exception: " \
64 << e.what() << ". Abort!" << std::endl; \
65 } \
66 catch (...) { \
67 exceptionThrown = true; \
68 std::cerr << "Process " << comm.rank() << " threw a fatal exception. " \
69 <<" Abort!" << std::endl; \
70 } \
71 \
72 if (comm.max(exceptionThrown)) \
73 std::abort(); \
74 }
75
76namespace Opm {
77
90template <class TypeTag>
92{
98
99 using MPIComm = typename Dune::MPIHelper::MPICommunicator;
100 using Communication = Dune::Communication<MPIComm>;
101
102public:
103 // do not allow to copy simulators around
104 Simulator(const Simulator& ) = delete;
105
106 explicit Simulator(bool verbose = true)
107 :Simulator(Communication(), verbose)
108 {
109 }
110
111 explicit Simulator(Communication comm, bool verbose = true)
112 {
113 TimerGuard setupTimerGuard(setupTimer_);
114
115 setupTimer_.start();
116
117 verbose_ = verbose && comm.rank() == 0;
118
119 timeStepIdx_ = 0;
120 startTime_ = 0.0;
121 time_ = 0.0;
122 endTime_ = Parameters::Get<Parameters::EndTime<Scalar>>();
123 timeStepSize_ = Parameters::Get<Parameters::InitialTimeStepSize<Scalar>>();
124 assert(timeStepSize_ > 0);
125 const std::string& predetTimeStepFile =
126 Parameters::Get<Parameters::PredeterminedTimeStepsFile>();
127 if (!predetTimeStepFile.empty()) {
129 }
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 int exceptionThrown = 0;
141 std::string what;
142
143 auto catchAction =
144 [&exceptionThrown, &what, comm](const std::exception& e,
145 bool doPrint) {
146 exceptionThrown = 1;
147 what = e.what();
148 if (comm.size() > 1) {
149 what += " (on rank " + std::to_string(comm.rank()) + ")";
150 }
151 if (doPrint)
152 std::cerr << "Rank " << comm.rank() << " threw an exception: " << e.what() << std::endl;
153 };
154
156 [comm](const std::string& prefix,
158 const std::string& what_)
159 {
160 if (comm.max(exceptionThrown_)) {
162 assert(!all_what.empty());
163 throw std::runtime_error(prefix + all_what.front());
164 }
165 };
166
167 try
168 { vanguard_.reset(new Vanguard(*this)); }
169 catch (const std::exception& e) {
170 catchAction(e, verbose_);
171 }
172 checkParallelException("Allocating the simulation vanguard failed: ",
174
175 // Only relevant for CpGrid
176 if (verbose_)
177 std::cout << "Adding LGRs, if any\n" << std::flush;
178
179 try
180 { vanguard_->addLgrs(); }
181 catch (const std::exception& e) {
182 catchAction(e, verbose_);
183 }
184 checkParallelException("Adding LGRs to the simulation vanguard failed: ",
186
187 if (verbose_)
188 std::cout << "Distributing the vanguard's data\n" << std::flush;
189
190 try
191 { vanguard_->loadBalance(); }
192 catch (const std::exception& e) {
193 catchAction(e, verbose_);
194 }
195 checkParallelException("Could not distribute the vanguard data: ",
197
198
199 if (verbose_)
200 std::cout << "Allocating the model\n" << std::flush;
201 try {
202 model_.reset(new Model(*this));
203 }
204 catch (const std::exception& e) {
205 catchAction(e, verbose_);
206 }
207 checkParallelException("Could not allocate model: ",
209
210 if (verbose_)
211 std::cout << "Allocating the problem\n" << std::flush;
212
213 try {
214 problem_.reset(new Problem(*this));
215 }
216 catch (const std::exception& e) {
217 catchAction(e, verbose_);
218 }
219 checkParallelException("Could not allocate the problem: ",
221
222 if (verbose_)
223 std::cout << "Initializing the model\n" << std::flush;
224
225 try
226 { model_->finishInit(); }
227 catch (const std::exception& e) {
228 catchAction(e, verbose_);
229 }
230 checkParallelException("Could not initialize the model: ",
232
233 if (verbose_)
234 std::cout << "Initializing the problem\n" << std::flush;
235
236 try
237 { problem_->finishInit(); }
238 catch (const std::exception& e) {
239 catchAction(e, verbose_);
240 }
241 checkParallelException("Could not initialize the problem: ",
243
244 setupTimer_.stop();
245
246 if (verbose_)
247 std::cout << "Simulator successfully set up\n" << std::flush;
248 }
249
253 static void registerParameters()
254 {
255 Parameters::Register<Parameters::EndTime<Scalar>>
256 ("The simulation time at which the simulation is finished [s]");
257 Parameters::Register<Parameters::InitialTimeStepSize<Scalar>>
258 ("The size of the initial time step [s]");
259 Parameters::Register<Parameters::RestartTime<Scalar>>
260 ("The simulation time at which a restart should be attempted [s]");
261 Parameters::Register<Parameters::PredeterminedTimeStepsFile>
262 ("A file with a list of predetermined time step sizes (one "
263 "time step per line)");
264
265 Vanguard::registerParameters();
266 Model::registerParameters();
267 Problem::registerParameters();
268 }
269
273 Vanguard& vanguard()
274 { return *vanguard_; }
275
279 const Vanguard& vanguard() const
280 { return *vanguard_; }
281
285 const GridView& gridView() const
286 { return vanguard_->gridView(); }
287
291 Model& model()
292 { return *model_; }
293
297 const Model& model() const
298 { return *model_; }
299
304 Problem& problem()
305 { return *problem_; }
306
311 const Problem& problem() const
312 { return *problem_; }
313
319 void setStartTime(Scalar t)
320 { startTime_ = t; }
321
325 Scalar startTime() const
326 { return startTime_; }
327
334 void setTime(Scalar t)
335 { time_ = t; }
336
343 void setTime(Scalar t, unsigned stepIdx)
344 {
345 time_ = t;
346 timeStepIdx_ = stepIdx;
347 }
348
356 Scalar time() const
357 { return time_; }
358
364 void setEndTime(Scalar t)
365 { endTime_ = t; }
366
371 Scalar endTime() const
372 { return endTime_; }
373
378 const Timer& setupTimer() const
379 { return setupTimer_; }
380
385 const Timer& executionTimer() const
386 { return executionTimer_; }
388 { return executionTimer_; }
389
395 { return prePostProcessTimer_; }
396
401 const Timer& linearizeTimer() const
402 { return linearizeTimer_; }
403
408 const Timer& solveTimer() const
409 { return solveTimer_; }
410
415 const Timer& updateTimer() const
416 { return updateTimer_; }
417
422 const Timer& writeTimer() const
423 { return writeTimer_; }
424
435 void setTimeStepSize(Scalar value)
436 {
437 timeStepSize_ = value;
438 }
439
445 void setTimeStepIndex(unsigned value)
446 { timeStepIdx_ = value; }
447
453 Scalar timeStepSize() const
454 { return timeStepSize_; }
455
460 int timeStepIndex() const
461 { return timeStepIdx_; }
462
470 void setFinished(bool yesno = true)
471 { finished_ = yesno; }
472
479 bool finished() const
480 {
481 assert(timeStepSize_ >= 0.0);
482 Scalar eps =
483 std::max(Scalar(std::abs(this->time())), timeStepSize())
484 *std::numeric_limits<Scalar>::epsilon()*1e3;
485 return finished_ || (this->time()*(1.0 + eps) >= endTime());
486 }
487
492 bool willBeFinished() const
493 {
494 static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
495
496 return finished_ || (this->time() + timeStepSize_)*(1.0 + eps) >= endTime();
497 }
498
503 Scalar maxTimeStepSize() const
504 {
505 if (finished())
506 return 0.0;
507
508 return std::min(episodeMaxTimeStepSize(),
509 std::max<Scalar>(0.0, endTime() - this->time()));
510 }
511
519 {
520 ++episodeIdx_;
521 episodeStartTime_ = episodeStartTime;
522 episodeLength_ = episodeLength;
523 }
524
532 void startNextEpisode(Scalar len = std::numeric_limits<Scalar>::max())
533 {
534 ++episodeIdx_;
535 episodeStartTime_ = startTime_ + time_;
536 episodeLength_ = len;
537 }
538
545 { episodeIdx_ = episodeIdx; }
546
552 int episodeIndex() const
553 { return episodeIdx_; }
554
559 Scalar episodeStartTime() const
560 { return episodeStartTime_; }
561
567 void setEpisodeLength(Scalar dt)
568 { episodeLength_ = dt; }
569
574 Scalar episodeLength() const
575 { return episodeLength_; }
576
581 bool episodeStarts() const
582 {
583 static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
584
585 return this->time() <= (episodeStartTime_ - startTime())*(1 + eps);
586 }
587
592 bool episodeIsOver() const
593 {
594 static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
595
596 return this->time() >= (episodeStartTime_ - startTime() + episodeLength())*(1 - eps);
597 }
598
603 bool episodeWillBeOver() const
604 {
605 static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
606
607 return this->time() + timeStepSize()
608 >= (episodeStartTime_ - startTime() + episodeLength())*(1 - eps);
609 }
610
616 {
617 // if the current episode is over and the simulation
618 // wants to give it some extra time, we will return
619 // the time step size it suggested instead of trying
620 // to align it to the end of the episode.
621 if (episodeIsOver())
622 return 0.0;
623
624 // make sure that we don't exceed the end of the
625 // current episode.
626 return std::max<Scalar>(0.0,
628 - (this->time() + this->startTime()));
629 }
630
631 /*
632 * \}
633 */
634
641 void run()
642 {
643 // create TimerGuard objects to hedge for exceptions
644 TimerGuard setupTimerGuard(setupTimer_);
645 TimerGuard executionTimerGuard(executionTimer_);
646 TimerGuard prePostProcessTimerGuard(prePostProcessTimer_);
647 TimerGuard writeTimerGuard(writeTimer_);
648
649 setupTimer_.start();
650 Scalar restartTime = Parameters::Get<Parameters::RestartTime<Scalar>>();
651 if (restartTime > -1e30) {
652 // try to restart a previous simulation
653 time_ = restartTime;
654
655 Restart res;
656 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(res.deserializeBegin(*this, time_));
657 if (verbose_)
658 std::cout << "Deserialize from file '" << res.fileName() << "'\n" << std::flush;
659 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(this->deserialize(res));
660 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->deserialize(res));
661 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(model_->deserialize(res));
662 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(res.deserializeEnd());
663 if (verbose_)
664 std::cout << "Deserialization done."
665 << " Simulator time: " << time() << humanReadableTime(time())
666 << " Time step index: " << timeStepIndex()
667 << " Episode index: " << episodeIndex()
668 << "\n" << std::flush;
669 }
670 else {
671 // if no restart is done, apply the initial solution
672 if (verbose_)
673 std::cout << "Applying the initial solution of the \"" << problem_->name()
674 << "\" problem\n" << std::flush;
675
676 Scalar oldTimeStepSize = timeStepSize_;
677 int oldTimeStepIdx = timeStepIdx_;
678 timeStepSize_ = 0.0;
679 timeStepIdx_ = -1;
680
681 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(model_->applyInitialSolution());
682
683 // write initial condition
684 if (problem_->shouldWriteOutput())
685 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->writeOutput(true));
686
687 timeStepSize_ = oldTimeStepSize;
688 timeStepIdx_ = oldTimeStepIdx;
689 }
690 setupTimer_.stop();
691
692 executionTimer_.start();
693 bool episodeBegins = episodeIsOver() || (timeStepIdx_ == 0);
694 // do the time steps
695 while (!finished()) {
696 prePostProcessTimer_.start();
697 if (episodeBegins) {
698 // notify the problem that a new episode has just been
699 // started.
700 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->beginEpisode());
701
702 if (finished()) {
703 // the problem can chose to terminate the simulation in
704 // beginEpisode(), so we have handle this case.
705 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endEpisode());
706 prePostProcessTimer_.stop();
707
708 break;
709 }
710 }
711 episodeBegins = false;
712
713 if (verbose_) {
714 std::cout << "Begin time step " << timeStepIndex() + 1 << ". "
715 << "Start time: " << this->time() << " seconds" << humanReadableTime(this->time())
716 << ", step size: " << timeStepSize() << " seconds" << humanReadableTime(timeStepSize())
717 << "\n";
718 }
719
720 // pre-process the current solution
721 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->beginTimeStep());
722
723 if (finished()) {
724 // the problem can chose to terminate the simulation in
725 // beginTimeStep(), so we have handle this case.
726 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endTimeStep());
727 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endEpisode());
728 prePostProcessTimer_.stop();
729
730 break;
731 }
732 prePostProcessTimer_.stop();
733
734 try {
735 // execute the time integration scheme
736 problem_->timeIntegration();
737 }
738 catch (...) {
739 // exceptions in the time integration might be recoverable. clean up in
740 // case they are
741 const auto& model = problem_->model();
742 prePostProcessTimer_ += model.prePostProcessTimer();
743 linearizeTimer_ += model.linearizeTimer();
744 solveTimer_ += model.solveTimer();
745 updateTimer_ += model.updateTimer();
746
747 throw;
748 }
749
750 const auto& model = problem_->model();
751 prePostProcessTimer_ += model.prePostProcessTimer();
752 linearizeTimer_ += model.linearizeTimer();
753 solveTimer_ += model.solveTimer();
754 updateTimer_ += model.updateTimer();
755
756 // post-process the current solution
757 prePostProcessTimer_.start();
758 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endTimeStep());
759 prePostProcessTimer_.stop();
760
761 // write the result to disk
762 writeTimer_.start();
763 if (problem_->shouldWriteOutput())
764 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->writeOutput(true));
765 writeTimer_.stop();
766
767 // do the next time integration
768 Scalar oldDt = timeStepSize();
769 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->advanceTimeLevel());
770
771 if (verbose_) {
772 std::cout << "Time step " << timeStepIndex() + 1 << " done. "
773 << "CPU time: " << executionTimer_.realTimeElapsed() << " seconds" << humanReadableTime(executionTimer_.realTimeElapsed())
774 << ", end time: " << this->time() + oldDt << " seconds" << humanReadableTime(this->time() + oldDt)
775 << ", step size: " << oldDt << " seconds" << humanReadableTime(oldDt)
776 << "\n" << std::flush;
777 }
778
779 // advance the simulated time by the current time step size
780 time_ += oldDt;
781 ++timeStepIdx_;
782
783 prePostProcessTimer_.start();
784 // notify the problem if an episode is finished
785 if (episodeIsOver()) {
786 // Notify the problem about the end of the current episode...
787 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endEpisode());
788 episodeBegins = true;
789 }
790 else {
791 Scalar dt;
792 if (timeStepIdx_ < static_cast<int>(forcedTimeSteps_.size()))
793 // use the next time step size from the input file
794 dt = forcedTimeSteps_[timeStepIdx_];
795 else
796 // ask the problem to provide the next time step size
797 dt = std::min(maxTimeStepSize(), problem_->nextTimeStepSize());
798 assert(finished() || dt > 0);
800 }
801 prePostProcessTimer_.stop();
802
803 // write restart file if mandated by the problem
804 writeTimer_.start();
805 if (problem_->shouldWriteRestartFile())
806 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(serialize());
807 writeTimer_.stop();
808 }
809 executionTimer_.stop();
810
811 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->finalize());
812 }
813
829 {
830 using Restarter = Restart;
832 res.serializeBegin(*this);
833 if (gridView().comm().rank() == 0)
834 std::cout << "Serialize to file '" << res.fileName() << "'"
835 << ", next time step size: " << timeStepSize()
836 << "\n" << std::flush;
837
838 this->serialize(res);
839 problem_->serialize(res);
840 model_->serialize(res);
841 res.serializeEnd();
842 }
843
851 template <class Restarter>
853 {
854 restarter.serializeSectionBegin("Simulator");
855 restarter.serializeStream()
856 << episodeIdx_ << " "
857 << episodeStartTime_ << " "
858 << episodeLength_ << " "
859 << startTime_ << " "
860 << time_ << " "
861 << timeStepIdx_ << " ";
862 restarter.serializeSectionEnd();
863 }
864
872 template <class Restarter>
874 {
875 restarter.deserializeSectionBegin("Simulator");
876 restarter.deserializeStream()
877 >> episodeIdx_
878 >> episodeStartTime_
879 >> episodeLength_
880 >> startTime_
881 >> time_
882 >> timeStepIdx_;
883 restarter.deserializeSectionEnd();
884 }
885
886 template<class Serializer>
887 void serializeOp(Serializer& serializer)
888 {
889 serializer(*vanguard_);
890 serializer(*model_);
891 serializer(*problem_);
892 serializer(episodeIdx_);
893 serializer(episodeStartTime_);
894 serializer(episodeLength_);
895 serializer(startTime_);
896 serializer(time_);
897 serializer(timeStepIdx_);
898 }
899
900private:
901 std::unique_ptr<Vanguard> vanguard_;
902 std::unique_ptr<Model> model_;
903 std::unique_ptr<Problem> problem_;
904
905 int episodeIdx_;
906 Scalar episodeStartTime_;
907 Scalar episodeLength_;
908
909 Timer setupTimer_;
910 Timer executionTimer_;
911 Timer prePostProcessTimer_;
912 Timer linearizeTimer_;
913 Timer solveTimer_;
914 Timer updateTimer_;
915 Timer writeTimer_;
916
917 std::vector<Scalar> forcedTimeSteps_;
918 Scalar startTime_;
919 Scalar time_;
920 Scalar endTime_;
921
922 Scalar timeStepSize_;
923 int timeStepIdx_;
924
925 bool finished_;
926 bool verbose_;
927};
928
929namespace Properties {
930template<class TypeTag>
931struct Simulator<TypeTag, TTag::NumericModel> { using type = ::Opm::Simulator<TypeTag>; };
932}
933
934} // namespace Opm
935
936#endif
Defines a type tags and some fundamental properties all models.
Load or save a state of a problem to/from the harddisk.
Definition restart.hpp:41
void serializeBegin(Simulator &simulator)
Write the current state of the model to disk.
Definition restart.hpp:88
Manages the initializing and running of time dependent problems.
Definition simulator.hh:92
const Timer & writeTimer() const
Returns a reference to the timer object which measures the time needed to write the visualization out...
Definition simulator.hh:422
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:453
Scalar startTime() const
Return the time of the start of the simulation.
Definition simulator.hh:325
int timeStepIndex() const
Returns number of time steps which have been executed since the beginning of the simulation.
Definition simulator.hh:460
void serialize()
This method writes the complete state of the simulation to the harddisk.
Definition simulator.hh:828
Scalar episodeLength() const
Returns the length of the current episode in simulated time .
Definition simulator.hh:574
const Timer & prePostProcessTimer() const
Returns a reference to the timer object which measures the time needed for pre- and postprocessing of...
Definition simulator.hh:394
const Timer & solveTimer() const
Returns a reference to the timer object which measures the time needed by the solver.
Definition simulator.hh:408
void startNextEpisode(Scalar len=std::numeric_limits< Scalar >::max())
Start the next episode, but don't change the episode identifier.
Definition simulator.hh:532
const Vanguard & vanguard() const
Return a reference to the grid manager of simulation.
Definition simulator.hh:279
void serialize(Restarter &restarter)
Write the time manager's state to a restart file.
Definition simulator.hh:852
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:415
const Timer & executionTimer() const
Returns a reference to the timer object which measures the time needed to run the simulation.
Definition simulator.hh:385
void startNextEpisode(Scalar episodeStartTime, Scalar episodeLength)
Change the current episode of the simulation.
Definition simulator.hh:518
void setEndTime(Scalar t)
Set the time of simulated seconds at which the simulation runs.
Definition simulator.hh:364
const Timer & linearizeTimer() const
Returns a reference to the timer object which measures the time needed for linarizing the solutions.
Definition simulator.hh:401
void setStartTime(Scalar t)
Set the time of the start of the simulation.
Definition simulator.hh:319
void deserialize(Restarter &restarter)
Read the time manager's state from a restart file.
Definition simulator.hh:873
void setTimeStepSize(Scalar value)
Set the current time step size to a given value.
Definition simulator.hh:435
bool episodeStarts() const
Returns true if the current episode has just been started at the current time.
Definition simulator.hh:581
void run()
Runs the simulation using a given problem class.
Definition simulator.hh:641
Vanguard & vanguard()
Return a reference to the grid manager of simulation.
Definition simulator.hh:273
int episodeIndex() const
Returns the index of the current episode.
Definition simulator.hh:552
void setTimeStepIndex(unsigned value)
Set the current time step index to a given value.
Definition simulator.hh:445
void setFinished(bool yesno=true)
Specify whether the simulation is finished.
Definition simulator.hh:470
Problem & problem()
Return the object which specifies the pysical setup of the simulation.
Definition simulator.hh:304
static void registerParameters()
Registers all runtime parameters used by the simulation.
Definition simulator.hh:253
void setTime(Scalar t)
Set the current simulated time, don't change the current time step index.
Definition simulator.hh:334
bool willBeFinished() const
Returns true if the simulation is finished after the time level is incremented by the current time st...
Definition simulator.hh:492
bool finished() const
Returns true if the simulation is finished.
Definition simulator.hh:479
Scalar maxTimeStepSize() const
Aligns the time step size to the episode boundary and to the end time of the simulation.
Definition simulator.hh:503
const Model & model() const
Return the physical model used in the simulation.
Definition simulator.hh:297
void setTime(Scalar t, unsigned stepIdx)
Set the current simulated time and the time step index.
Definition simulator.hh:343
bool episodeIsOver() const
Returns true if the current episode is finished at the current time.
Definition simulator.hh:592
Scalar endTime() const
Returns the number of (simulated) seconds which the simulation runs.
Definition simulator.hh:371
bool episodeWillBeOver() const
Returns true if the current episode will be finished after the current time step.
Definition simulator.hh:603
const GridView & gridView() const
Return the grid view for which the simulation is done.
Definition simulator.hh:285
void setEpisodeIndex(int episodeIdx)
Sets the index of the current episode.
Definition simulator.hh:544
Scalar time() const
Return the number of seconds of simulated time which have elapsed since the start time.
Definition simulator.hh:356
void setEpisodeLength(Scalar dt)
Sets the length in seconds of the current episode.
Definition simulator.hh:567
const Problem & problem() const
Return the object which specifies the pysical setup of the simulation.
Definition simulator.hh:311
Model & model()
Return the physical model used in the simulation.
Definition simulator.hh:291
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:615
Scalar episodeStartTime() const
Returns the absolute time when the current episode started .
Definition simulator.hh:559
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:378
A simple class which makes sure that a timer gets stopped if an exception is thrown.
Definition timerguard.hh:41
Provides an encapsulation to measure the system time.
Definition timer.hpp:46
void start()
Start counting the time resources used by the simulation.
Definition timer.cpp:46
double realTimeElapsed() const
Return the real time [s] elapsed during the periods the timer was active since the last reset.
Definition timer.cpp:90
double stop()
Stop counting the time resources.
Definition timer.cpp:52
Declare the properties used by the infrastructure code of the finite volume discretizations.
Simplifies handling of buffers to be used in conjunction with MPI.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
std::vector< std::string > gatherStrings(const std::string &local_string)
From each rank, gather its string (if not empty) into a vector.
Definition mpiutil.cpp:141
std::string humanReadableTime(double timeInSeconds, bool isAmendment)
Given a time step size in seconds, return it in a format which is more easily parsable by humans.
Definition simulatorutils.cpp:45
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
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:235
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
Load or save a state of a problem to/from the harddisk.
Provides an encapsulation to measure the system time.
A simple class which makes sure that a timer gets stopped if an exception is thrown.