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
78 template <typename T>
79 static constexpr T constexpr_max(T a, T b) {
80 return (a > b) ? a : b;
81 }
82
95template <class TypeTag>
97{
103
104 using MPIComm = typename Dune::MPIHelper::MPICommunicator;
105 using Communication = Dune::Communication<MPIComm>;
106
107 // \Note: too small eps can not rule out confusion from the rounding errors, as we use 1.e-9 as a minimum.
108 static constexpr Scalar eps = constexpr_max(std::numeric_limits<Scalar>::epsilon(), static_cast<Scalar>(1.0e-9));
109
110public:
111 // do not allow to copy simulators around
112 Simulator(const Simulator& ) = delete;
113
114 explicit Simulator(bool verbose = true)
115 :Simulator(Communication(), verbose)
116 {
117 }
118
119 explicit Simulator(Communication comm, bool verbose = true)
120 {
121 TimerGuard setupTimerGuard(setupTimer_);
122
123 setupTimer_.start();
124
125 verbose_ = verbose && comm.rank() == 0;
126
127 timeStepIdx_ = 0;
128 startTime_ = 0.0;
129 time_ = 0.0;
130 endTime_ = Parameters::Get<Parameters::EndTime<Scalar>>();
131 timeStepSize_ = Parameters::Get<Parameters::InitialTimeStepSize<Scalar>>();
132 assert(timeStepSize_ > 0);
133 const std::string& predetTimeStepFile =
134 Parameters::Get<Parameters::PredeterminedTimeStepsFile>();
135 if (!predetTimeStepFile.empty()) {
137 }
138
139 episodeIdx_ = 0;
140 episodeStartTime_ = 0;
141 episodeLength_ = std::numeric_limits<Scalar>::max();
142
143 finished_ = false;
144
145 if (verbose_)
146 std::cout << "Allocating the simulation vanguard\n" << std::flush;
147
148 int exceptionThrown = 0;
149 std::string what;
150
151 auto catchAction =
152 [&exceptionThrown, &what, comm](const std::exception& e,
153 bool doPrint) {
154 exceptionThrown = 1;
155 what = e.what();
156 if (comm.size() > 1) {
157 what += " (on rank " + std::to_string(comm.rank()) + ")";
158 }
159 if (doPrint)
160 std::cerr << "Rank " << comm.rank() << " threw an exception: " << e.what() << std::endl;
161 };
162
164 [comm](const std::string& prefix,
166 const std::string& what_)
167 {
168 if (comm.max(exceptionThrown_)) {
170 assert(!all_what.empty());
171 throw std::runtime_error(prefix + all_what.front());
172 }
173 };
174
175 try
176 { vanguard_.reset(new Vanguard(*this)); }
177 catch (const std::exception& e) {
178 catchAction(e, verbose_);
179 }
180 checkParallelException("Allocating the simulation vanguard failed: ",
182
183 // Only relevant for CpGrid
184 if (verbose_)
185 std::cout << "Adding LGRs, if any\n" << std::flush;
186
187 try
188 { vanguard_->addLgrs(); }
189 catch (const std::exception& e) {
190 catchAction(e, verbose_);
191 }
192 checkParallelException("Adding LGRs to the simulation vanguard failed: ",
194
195 if (verbose_)
196 std::cout << "Distributing the vanguard's data\n" << std::flush;
197
198 try
199 { vanguard_->loadBalance(); }
200 catch (const std::exception& e) {
201 catchAction(e, verbose_);
202 }
203 checkParallelException("Could not distribute the vanguard data: ",
205
206
207 if (verbose_)
208 std::cout << "Allocating the model\n" << std::flush;
209 try {
210 model_.reset(new Model(*this));
211 }
212 catch (const std::exception& e) {
213 catchAction(e, verbose_);
214 }
215 checkParallelException("Could not allocate model: ",
217
218 if (verbose_)
219 std::cout << "Allocating the problem\n" << std::flush;
220
221 try {
222 problem_.reset(new Problem(*this));
223 }
224 catch (const std::exception& e) {
225 catchAction(e, verbose_);
226 }
227 checkParallelException("Could not allocate the problem: ",
229
230 if (verbose_)
231 std::cout << "Initializing the model\n" << std::flush;
232
233 try
234 { model_->finishInit(); }
235 catch (const std::exception& e) {
236 catchAction(e, verbose_);
237 }
238 checkParallelException("Could not initialize the model: ",
240
241 if (verbose_)
242 std::cout << "Initializing the problem\n" << std::flush;
243
244 try
245 { problem_->finishInit(); }
246 catch (const std::exception& e) {
247 catchAction(e, verbose_);
248 }
249 checkParallelException("Could not initialize the problem: ",
251
252 setupTimer_.stop();
253
254 if (verbose_)
255 std::cout << "Simulator successfully set up\n" << std::flush;
256 }
257
261 static void registerParameters()
262 {
263 Parameters::Register<Parameters::EndTime<Scalar>>
264 ("The simulation time at which the simulation is finished [s]");
265 Parameters::Register<Parameters::InitialTimeStepSize<Scalar>>
266 ("The size of the initial time step [s]");
267 Parameters::Register<Parameters::RestartTime<Scalar>>
268 ("The simulation time at which a restart should be attempted [s]");
269 Parameters::Register<Parameters::PredeterminedTimeStepsFile>
270 ("A file with a list of predetermined time step sizes (one "
271 "time step per line)");
272
273 Vanguard::registerParameters();
274 Model::registerParameters();
275 Problem::registerParameters();
276 }
277
281 Vanguard& vanguard()
282 { return *vanguard_; }
283
287 const Vanguard& vanguard() const
288 { return *vanguard_; }
289
293 const GridView& gridView() const
294 { return vanguard_->gridView(); }
295
299 Model& model()
300 { return *model_; }
301
305 const Model& model() const
306 { return *model_; }
307
312 Problem& problem()
313 { return *problem_; }
314
319 const Problem& problem() const
320 { return *problem_; }
321
327 void setStartTime(Scalar t)
328 { startTime_ = t; }
329
333 Scalar startTime() const
334 { return startTime_; }
335
342 void setTime(Scalar t)
343 { time_ = t; }
344
351 void setTime(Scalar t, unsigned stepIdx)
352 {
353 time_ = t;
354 timeStepIdx_ = stepIdx;
355 }
356
364 Scalar time() const
365 { return time_; }
366
372 void setEndTime(Scalar t)
373 { endTime_ = t; }
374
379 Scalar endTime() const
380 { return endTime_; }
381
386 const Timer& setupTimer() const
387 { return setupTimer_; }
388
393 const Timer& executionTimer() const
394 { return executionTimer_; }
396 { return executionTimer_; }
397
403 { return prePostProcessTimer_; }
404
409 const Timer& linearizeTimer() const
410 { return linearizeTimer_; }
411
416 const Timer& solveTimer() const
417 { return solveTimer_; }
418
423 const Timer& updateTimer() const
424 { return updateTimer_; }
425
430 const Timer& writeTimer() const
431 { return writeTimer_; }
432
443 void setTimeStepSize(Scalar value)
444 {
445 timeStepSize_ = value;
446 }
447
453 void setTimeStepIndex(unsigned value)
454 { timeStepIdx_ = value; }
455
461 Scalar timeStepSize() const
462 { return timeStepSize_; }
463
468 int timeStepIndex() const
469 { return timeStepIdx_; }
470
478 void setFinished(bool yesno = true)
479 { finished_ = yesno; }
480
487 bool finished() const
488 {
489 assert(timeStepSize_ >= 0.0);
490 return finished_ || (this->time()*(1.0 + eps) >= endTime());
491 }
492
497 bool willBeFinished() const
498 {
499 return finished_ || (this->time() + timeStepSize_)*(1.0 + eps) >= endTime();
500 }
501
506 Scalar maxTimeStepSize() const
507 {
508 if (finished())
509 return 0.0;
510
511 return std::min(episodeMaxTimeStepSize(),
512 std::max<Scalar>(0.0, endTime() - this->time()));
513 }
514
522 {
523 ++episodeIdx_;
524 episodeStartTime_ = episodeStartTime;
525 episodeLength_ = episodeLength;
526 }
527
535 void startNextEpisode(Scalar len = std::numeric_limits<Scalar>::max())
536 {
537 ++episodeIdx_;
538 episodeStartTime_ = startTime_ + time_;
539 episodeLength_ = len;
540 }
541
548 { episodeIdx_ = episodeIdx; }
549
555 int episodeIndex() const
556 { return episodeIdx_; }
557
562 Scalar episodeStartTime() const
563 { return episodeStartTime_; }
564
570 void setEpisodeLength(Scalar dt)
571 { episodeLength_ = dt; }
572
577 Scalar episodeLength() const
578 { return episodeLength_; }
579
584 bool episodeStarts() const
585 {
586 return this->time() <= (episodeStartTime_ - startTime())*(1 + eps);
587 }
588
593 bool episodeIsOver() const
594 {
595 return this->time() >= (episodeStartTime_ - startTime() + episodeLength())*(1 - eps);
596 }
597
602 bool episodeWillBeOver() const
603 {
604 return this->time() + timeStepSize()
605 >= (episodeStartTime_ - startTime() + episodeLength())*(1 - eps);
606 }
607
613 {
614 // if the current episode is over and the simulation
615 // wants to give it some extra time, we will return
616 // the time step size it suggested instead of trying
617 // to align it to the end of the episode.
618 if (episodeIsOver())
619 return 0.0;
620
621 // make sure that we don't exceed the end of the
622 // current episode.
623 return std::max<Scalar>(0.0,
625 - (this->time() + this->startTime()));
626 }
627
628 /*
629 * \}
630 */
631
638 void run()
639 {
640 // create TimerGuard objects to hedge for exceptions
641 TimerGuard setupTimerGuard(setupTimer_);
642 TimerGuard executionTimerGuard(executionTimer_);
643 TimerGuard prePostProcessTimerGuard(prePostProcessTimer_);
644 TimerGuard writeTimerGuard(writeTimer_);
645
646 setupTimer_.start();
647 Scalar restartTime = Parameters::Get<Parameters::RestartTime<Scalar>>();
648 if (restartTime > -1e30) {
649 // try to restart a previous simulation
650 time_ = restartTime;
651
652 Restart res;
653 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(res.deserializeBegin(*this, time_));
654 if (verbose_)
655 std::cout << "Deserialize from file '" << res.fileName() << "'\n" << std::flush;
656 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(this->deserialize(res));
657 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->deserialize(res));
658 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(model_->deserialize(res));
659 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(res.deserializeEnd());
660 if (verbose_)
661 std::cout << "Deserialization done."
662 << " Simulator time: " << time() << humanReadableTime(time())
663 << " Time step index: " << timeStepIndex()
664 << " Episode index: " << episodeIndex()
665 << "\n" << std::flush;
666 }
667 else {
668 // if no restart is done, apply the initial solution
669 if (verbose_)
670 std::cout << "Applying the initial solution of the \"" << problem_->name()
671 << "\" problem\n" << std::flush;
672
673 Scalar oldTimeStepSize = timeStepSize_;
674 int oldTimeStepIdx = timeStepIdx_;
675 timeStepSize_ = 0.0;
676 timeStepIdx_ = -1;
677
678 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(model_->applyInitialSolution());
679
680 // write initial condition
681 if (problem_->shouldWriteOutput())
682 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->writeOutput(true));
683
684 timeStepSize_ = oldTimeStepSize;
685 timeStepIdx_ = oldTimeStepIdx;
686 }
687 setupTimer_.stop();
688
689 executionTimer_.start();
690 bool episodeBegins = episodeIsOver() || (timeStepIdx_ == 0);
691 // do the time steps
692 while (!finished()) {
693 prePostProcessTimer_.start();
694 if (episodeBegins) {
695 // notify the problem that a new episode has just been
696 // started.
697 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->beginEpisode());
698
699 if (finished()) {
700 // the problem can chose to terminate the simulation in
701 // beginEpisode(), so we have handle this case.
702 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endEpisode());
703 prePostProcessTimer_.stop();
704
705 break;
706 }
707 }
708 episodeBegins = false;
709
710 if (verbose_) {
711 std::cout << "Begin time step " << timeStepIndex() + 1 << ". "
712 << "Start time: " << this->time() << " seconds" << humanReadableTime(this->time())
713 << ", step size: " << timeStepSize() << " seconds" << humanReadableTime(timeStepSize())
714 << "\n";
715 }
716
717 // pre-process the current solution
718 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->beginTimeStep());
719
720 if (finished()) {
721 // the problem can chose to terminate the simulation in
722 // beginTimeStep(), so we have handle this case.
723 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endTimeStep());
724 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endEpisode());
725 prePostProcessTimer_.stop();
726
727 break;
728 }
729 prePostProcessTimer_.stop();
730
731 try {
732 // execute the time integration scheme
733 problem_->timeIntegration();
734 }
735 catch (...) {
736 // exceptions in the time integration might be recoverable. clean up in
737 // case they are
738 const auto& model = problem_->model();
739 prePostProcessTimer_ += model.prePostProcessTimer();
740 linearizeTimer_ += model.linearizeTimer();
741 solveTimer_ += model.solveTimer();
742 updateTimer_ += model.updateTimer();
743
744 throw;
745 }
746
747 const auto& model = problem_->model();
748 prePostProcessTimer_ += model.prePostProcessTimer();
749 linearizeTimer_ += model.linearizeTimer();
750 solveTimer_ += model.solveTimer();
751 updateTimer_ += model.updateTimer();
752
753 // post-process the current solution
754 prePostProcessTimer_.start();
755 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endTimeStep());
756 prePostProcessTimer_.stop();
757
758 // write the result to disk
759 writeTimer_.start();
760 if (problem_->shouldWriteOutput())
761 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->writeOutput(true));
762 writeTimer_.stop();
763
764 // do the next time integration
765 Scalar oldDt = timeStepSize();
766 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->advanceTimeLevel());
767
768 if (verbose_) {
769 std::cout << "Time step " << timeStepIndex() + 1 << " done. "
770 << "CPU time: " << executionTimer_.realTimeElapsed() << " seconds" << humanReadableTime(executionTimer_.realTimeElapsed())
771 << ", end time: " << this->time() + oldDt << " seconds" << humanReadableTime(this->time() + oldDt)
772 << ", step size: " << oldDt << " seconds" << humanReadableTime(oldDt)
773 << "\n" << std::flush;
774 }
775
776 // advance the simulated time by the current time step size
777 time_ += oldDt;
778 ++timeStepIdx_;
779
780 prePostProcessTimer_.start();
781 // notify the problem if an episode is finished
782 if (episodeIsOver()) {
783 // Notify the problem about the end of the current episode...
784 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endEpisode());
785 episodeBegins = true;
786 }
787 else {
788 Scalar dt;
789 if (timeStepIdx_ < static_cast<int>(forcedTimeSteps_.size()))
790 // use the next time step size from the input file
791 dt = forcedTimeSteps_[timeStepIdx_];
792 else
793 // ask the problem to provide the next time step size
794 dt = std::min(maxTimeStepSize(), problem_->nextTimeStepSize());
795 assert(finished() || dt > 0);
797 }
798 prePostProcessTimer_.stop();
799
800 // write restart file if mandated by the problem
801 writeTimer_.start();
802 if (problem_->shouldWriteRestartFile())
803 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(serialize());
804 writeTimer_.stop();
805 }
806 executionTimer_.stop();
807
808 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->finalize());
809 }
810
826 {
827 using Restarter = Restart;
829 res.serializeBegin(*this);
830 if (gridView().comm().rank() == 0)
831 std::cout << "Serialize to file '" << res.fileName() << "'"
832 << ", next time step size: " << timeStepSize()
833 << "\n" << std::flush;
834
835 this->serialize(res);
836 problem_->serialize(res);
837 model_->serialize(res);
838 res.serializeEnd();
839 }
840
848 template <class Restarter>
850 {
851 restarter.serializeSectionBegin("Simulator");
852 restarter.serializeStream()
853 << episodeIdx_ << " "
854 << episodeStartTime_ << " "
855 << episodeLength_ << " "
856 << startTime_ << " "
857 << time_ << " "
858 << timeStepIdx_ << " ";
859 restarter.serializeSectionEnd();
860 }
861
869 template <class Restarter>
871 {
872 restarter.deserializeSectionBegin("Simulator");
873 restarter.deserializeStream()
874 >> episodeIdx_
875 >> episodeStartTime_
876 >> episodeLength_
877 >> startTime_
878 >> time_
879 >> timeStepIdx_;
880 restarter.deserializeSectionEnd();
881 }
882
883 template<class Serializer>
884 void serializeOp(Serializer& serializer)
885 {
886 serializer(*vanguard_);
887 serializer(*model_);
888 serializer(*problem_);
889 serializer(episodeIdx_);
890 serializer(episodeStartTime_);
891 serializer(episodeLength_);
892 serializer(startTime_);
893 serializer(time_);
894 serializer(timeStepIdx_);
895 }
896
897private:
898 std::unique_ptr<Vanguard> vanguard_;
899 std::unique_ptr<Model> model_;
900 std::unique_ptr<Problem> problem_;
901
902 int episodeIdx_;
903 Scalar episodeStartTime_;
904 Scalar episodeLength_;
905
906 Timer setupTimer_;
907 Timer executionTimer_;
908 Timer prePostProcessTimer_;
909 Timer linearizeTimer_;
910 Timer solveTimer_;
911 Timer updateTimer_;
912 Timer writeTimer_;
913
914 std::vector<Scalar> forcedTimeSteps_;
915 Scalar startTime_;
916 Scalar time_;
917 Scalar endTime_;
918
919 Scalar timeStepSize_;
920 int timeStepIdx_;
921
922 bool finished_;
923 bool verbose_;
924};
925
926namespace Properties {
927template<class TypeTag>
928struct Simulator<TypeTag, TTag::NumericModel> { using type = ::Opm::Simulator<TypeTag>; };
929}
930
931} // namespace Opm
932
933#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:97
const Timer & writeTimer() const
Returns a reference to the timer object which measures the time needed to write the visualization out...
Definition simulator.hh:430
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:461
Scalar startTime() const
Return the time of the start of the simulation.
Definition simulator.hh:333
int timeStepIndex() const
Returns number of time steps which have been executed since the beginning of the simulation.
Definition simulator.hh:468
void serialize()
This method writes the complete state of the simulation to the harddisk.
Definition simulator.hh:825
Scalar episodeLength() const
Returns the length of the current episode in simulated time .
Definition simulator.hh:577
const Timer & prePostProcessTimer() const
Returns a reference to the timer object which measures the time needed for pre- and postprocessing of...
Definition simulator.hh:402
const Timer & solveTimer() const
Returns a reference to the timer object which measures the time needed by the solver.
Definition simulator.hh:416
void startNextEpisode(Scalar len=std::numeric_limits< Scalar >::max())
Start the next episode, but don't change the episode identifier.
Definition simulator.hh:535
const Vanguard & vanguard() const
Return a reference to the grid manager of simulation.
Definition simulator.hh:287
void serialize(Restarter &restarter)
Write the time manager's state to a restart file.
Definition simulator.hh:849
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:423
const Timer & executionTimer() const
Returns a reference to the timer object which measures the time needed to run the simulation.
Definition simulator.hh:393
void startNextEpisode(Scalar episodeStartTime, Scalar episodeLength)
Change the current episode of the simulation.
Definition simulator.hh:521
void setEndTime(Scalar t)
Set the time of simulated seconds at which the simulation runs.
Definition simulator.hh:372
const Timer & linearizeTimer() const
Returns a reference to the timer object which measures the time needed for linarizing the solutions.
Definition simulator.hh:409
void setStartTime(Scalar t)
Set the time of the start of the simulation.
Definition simulator.hh:327
void deserialize(Restarter &restarter)
Read the time manager's state from a restart file.
Definition simulator.hh:870
void setTimeStepSize(Scalar value)
Set the current time step size to a given value.
Definition simulator.hh:443
bool episodeStarts() const
Returns true if the current episode has just been started at the current time.
Definition simulator.hh:584
void run()
Runs the simulation using a given problem class.
Definition simulator.hh:638
Vanguard & vanguard()
Return a reference to the grid manager of simulation.
Definition simulator.hh:281
int episodeIndex() const
Returns the index of the current episode.
Definition simulator.hh:555
void setTimeStepIndex(unsigned value)
Set the current time step index to a given value.
Definition simulator.hh:453
void setFinished(bool yesno=true)
Specify whether the simulation is finished.
Definition simulator.hh:478
Problem & problem()
Return the object which specifies the pysical setup of the simulation.
Definition simulator.hh:312
static void registerParameters()
Registers all runtime parameters used by the simulation.
Definition simulator.hh:261
void setTime(Scalar t)
Set the current simulated time, don't change the current time step index.
Definition simulator.hh:342
bool willBeFinished() const
Returns true if the simulation is finished after the time level is incremented by the current time st...
Definition simulator.hh:497
bool finished() const
Returns true if the simulation is finished.
Definition simulator.hh:487
Scalar maxTimeStepSize() const
Aligns the time step size to the episode boundary and to the end time of the simulation.
Definition simulator.hh:506
const Model & model() const
Return the physical model used in the simulation.
Definition simulator.hh:305
void setTime(Scalar t, unsigned stepIdx)
Set the current simulated time and the time step index.
Definition simulator.hh:351
bool episodeIsOver() const
Returns true if the current episode is finished at the current time.
Definition simulator.hh:593
Scalar endTime() const
Returns the number of (simulated) seconds which the simulation runs.
Definition simulator.hh:379
bool episodeWillBeOver() const
Returns true if the current episode will be finished after the current time step.
Definition simulator.hh:602
const GridView & gridView() const
Return the grid view for which the simulation is done.
Definition simulator.hh:293
void setEpisodeIndex(int episodeIdx)
Sets the index of the current episode.
Definition simulator.hh:547
Scalar time() const
Return the number of seconds of simulated time which have elapsed since the start time.
Definition simulator.hh:364
void setEpisodeLength(Scalar dt)
Sets the length in seconds of the current episode.
Definition simulator.hh:570
const Problem & problem() const
Return the object which specifies the pysical setup of the simulation.
Definition simulator.hh:319
Model & model()
Return the physical model used in the simulation.
Definition simulator.hh:299
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:612
Scalar episodeStartTime() const
Returns the absolute time when the current episode started .
Definition simulator.hh:562
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:386
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.