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 Simulator(bool verbose = true)
107 :Simulator(Communication(), verbose)
108 {
109 }
110
111 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()) {
128 forcedTimeSteps_ = readTimeStepFile<Scalar>(predetTimeStepFile);
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
155 auto checkParallelException =
156 [comm](const std::string& prefix,
157 int exceptionThrown_,
158 const std::string& what_)
159 {
160 if (comm.max(exceptionThrown_)) {
161 auto all_what = gatherStrings(what_);
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: ",
173 exceptionThrown, what);
174
175 if (verbose_)
176 std::cout << "Distributing the vanguard's data\n" << std::flush;
177
178 try
179 { vanguard_->loadBalance(); }
180 catch (const std::exception& e) {
181 catchAction(e, verbose_);
182 }
183 checkParallelException("Could not distribute the vanguard data: ",
184 exceptionThrown, what);
185
186 if (verbose_)
187 std::cout << "Allocating the model\n" << std::flush;
188 try {
189 model_.reset(new Model(*this));
190 }
191 catch (const std::exception& e) {
192 catchAction(e, verbose_);
193 }
194 checkParallelException("Could not allocate model: ",
195 exceptionThrown, what);
196
197 if (verbose_)
198 std::cout << "Allocating the problem\n" << std::flush;
199
200 try {
201 problem_.reset(new Problem(*this));
202 }
203 catch (const std::exception& e) {
204 catchAction(e, verbose_);
205 }
206 checkParallelException("Could not allocate the problem: ",
207 exceptionThrown, what);
208
209 if (verbose_)
210 std::cout << "Initializing the model\n" << std::flush;
211
212 try
213 { model_->finishInit(); }
214 catch (const std::exception& e) {
215 catchAction(e, verbose_);
216 }
217 checkParallelException("Could not initialize the model: ",
218 exceptionThrown, what);
219
220 if (verbose_)
221 std::cout << "Initializing the problem\n" << std::flush;
222
223 try
224 { problem_->finishInit(); }
225 catch (const std::exception& e) {
226 catchAction(e, verbose_);
227 }
228 checkParallelException("Could not initialize the problem: ",
229 exceptionThrown, what);
230
231 setupTimer_.stop();
232
233 if (verbose_)
234 std::cout << "Simulator successfully set up\n" << std::flush;
235 }
236
240 static void registerParameters()
241 {
242 Parameters::Register<Parameters::EndTime<Scalar>>
243 ("The simulation time at which the simulation is finished [s]");
244 Parameters::Register<Parameters::InitialTimeStepSize<Scalar>>
245 ("The size of the initial time step [s]");
246 Parameters::Register<Parameters::RestartTime<Scalar>>
247 ("The simulation time at which a restart should be attempted [s]");
248 Parameters::Register<Parameters::PredeterminedTimeStepsFile>
249 ("A file with a list of predetermined time step sizes (one "
250 "time step per line)");
251
252 Vanguard::registerParameters();
253 Model::registerParameters();
254 Problem::registerParameters();
255 }
256
260 Vanguard& vanguard()
261 { return *vanguard_; }
262
266 const Vanguard& vanguard() const
267 { return *vanguard_; }
268
272 const GridView& gridView() const
273 { return vanguard_->gridView(); }
274
278 Model& model()
279 { return *model_; }
280
284 const Model& model() const
285 { return *model_; }
286
291 Problem& problem()
292 { return *problem_; }
293
298 const Problem& problem() const
299 { return *problem_; }
300
306 void setStartTime(Scalar t)
307 { startTime_ = t; }
308
312 Scalar startTime() const
313 { return startTime_; }
314
321 void setTime(Scalar t)
322 { time_ = t; }
323
330 void setTime(Scalar t, unsigned stepIdx)
331 {
332 time_ = t;
333 timeStepIdx_ = stepIdx;
334 }
335
343 Scalar time() const
344 { return time_; }
345
351 void setEndTime(Scalar t)
352 { endTime_ = t; }
353
358 Scalar endTime() const
359 { return endTime_; }
360
365 const Timer& setupTimer() const
366 { return setupTimer_; }
367
372 const Timer& executionTimer() const
373 { return executionTimer_; }
375 { return executionTimer_; }
376
382 { return prePostProcessTimer_; }
383
388 const Timer& linearizeTimer() const
389 { return linearizeTimer_; }
390
395 const Timer& solveTimer() const
396 { return solveTimer_; }
397
402 const Timer& updateTimer() const
403 { return updateTimer_; }
404
409 const Timer& writeTimer() const
410 { return writeTimer_; }
411
422 void setTimeStepSize(Scalar value)
423 {
424 timeStepSize_ = value;
425 }
426
432 void setTimeStepIndex(unsigned value)
433 { timeStepIdx_ = value; }
434
440 Scalar timeStepSize() const
441 { return timeStepSize_; }
442
447 int timeStepIndex() const
448 { return timeStepIdx_; }
449
457 void setFinished(bool yesno = true)
458 { finished_ = yesno; }
459
466 bool finished() const
467 {
468 assert(timeStepSize_ >= 0.0);
469 Scalar eps =
470 std::max(Scalar(std::abs(this->time())), timeStepSize())
471 *std::numeric_limits<Scalar>::epsilon()*1e3;
472 return finished_ || (this->time()*(1.0 + eps) >= endTime());
473 }
474
479 bool willBeFinished() const
480 {
481 static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
482
483 return finished_ || (this->time() + timeStepSize_)*(1.0 + eps) >= endTime();
484 }
485
490 Scalar maxTimeStepSize() const
491 {
492 if (finished())
493 return 0.0;
494
495 return std::min(episodeMaxTimeStepSize(),
496 std::max<Scalar>(0.0, endTime() - this->time()));
497 }
498
506 {
507 ++episodeIdx_;
508 episodeStartTime_ = episodeStartTime;
509 episodeLength_ = episodeLength;
510 }
511
519 void startNextEpisode(Scalar len = std::numeric_limits<Scalar>::max())
520 {
521 ++episodeIdx_;
522 episodeStartTime_ = startTime_ + time_;
523 episodeLength_ = len;
524 }
525
531 void setEpisodeIndex(int episodeIdx)
532 { episodeIdx_ = episodeIdx; }
533
539 int episodeIndex() const
540 { return episodeIdx_; }
541
546 Scalar episodeStartTime() const
547 { return episodeStartTime_; }
548
554 void setEpisodeLength(Scalar dt)
555 { episodeLength_ = dt; }
556
561 Scalar episodeLength() const
562 { return episodeLength_; }
563
568 bool episodeStarts() const
569 {
570 static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
571
572 return this->time() <= (episodeStartTime_ - startTime())*(1 + eps);
573 }
574
579 bool episodeIsOver() const
580 {
581 static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
582
583 return this->time() >= (episodeStartTime_ - startTime() + episodeLength())*(1 - eps);
584 }
585
590 bool episodeWillBeOver() const
591 {
592 static const Scalar eps = std::numeric_limits<Scalar>::epsilon()*1e3;
593
594 return this->time() + timeStepSize()
595 >= (episodeStartTime_ - startTime() + episodeLength())*(1 - eps);
596 }
597
603 {
604 // if the current episode is over and the simulation
605 // wants to give it some extra time, we will return
606 // the time step size it suggested instead of trying
607 // to align it to the end of the episode.
608 if (episodeIsOver())
609 return 0.0;
610
611 // make sure that we don't exceed the end of the
612 // current episode.
613 return std::max<Scalar>(0.0,
615 - (this->time() + this->startTime()));
616 }
617
618 /*
619 * \}
620 */
621
628 void run()
629 {
630 // create TimerGuard objects to hedge for exceptions
631 TimerGuard setupTimerGuard(setupTimer_);
632 TimerGuard executionTimerGuard(executionTimer_);
633 TimerGuard prePostProcessTimerGuard(prePostProcessTimer_);
634 TimerGuard writeTimerGuard(writeTimer_);
635
636 setupTimer_.start();
637 Scalar restartTime = Parameters::Get<Parameters::RestartTime<Scalar>>();
638 if (restartTime > -1e30) {
639 // try to restart a previous simulation
640 time_ = restartTime;
641
642 Restart res;
643 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(res.deserializeBegin(*this, time_));
644 if (verbose_)
645 std::cout << "Deserialize from file '" << res.fileName() << "'\n" << std::flush;
646 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(this->deserialize(res));
647 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->deserialize(res));
648 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(model_->deserialize(res));
649 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(res.deserializeEnd());
650 if (verbose_)
651 std::cout << "Deserialization done."
652 << " Simulator time: " << time() << humanReadableTime(time())
653 << " Time step index: " << timeStepIndex()
654 << " Episode index: " << episodeIndex()
655 << "\n" << std::flush;
656 }
657 else {
658 // if no restart is done, apply the initial solution
659 if (verbose_)
660 std::cout << "Applying the initial solution of the \"" << problem_->name()
661 << "\" problem\n" << std::flush;
662
663 Scalar oldTimeStepSize = timeStepSize_;
664 int oldTimeStepIdx = timeStepIdx_;
665 timeStepSize_ = 0.0;
666 timeStepIdx_ = -1;
667
668 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(model_->applyInitialSolution());
669
670 // write initial condition
671 if (problem_->shouldWriteOutput())
672 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->writeOutput());
673
674 timeStepSize_ = oldTimeStepSize;
675 timeStepIdx_ = oldTimeStepIdx;
676 }
677 setupTimer_.stop();
678
679 executionTimer_.start();
680 bool episodeBegins = episodeIsOver() || (timeStepIdx_ == 0);
681 // do the time steps
682 while (!finished()) {
683 prePostProcessTimer_.start();
684 if (episodeBegins) {
685 // notify the problem that a new episode has just been
686 // started.
687 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->beginEpisode());
688
689 if (finished()) {
690 // the problem can chose to terminate the simulation in
691 // beginEpisode(), so we have handle this case.
692 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endEpisode());
693 prePostProcessTimer_.stop();
694
695 break;
696 }
697 }
698 episodeBegins = false;
699
700 if (verbose_) {
701 std::cout << "Begin time step " << timeStepIndex() + 1 << ". "
702 << "Start time: " << this->time() << " seconds" << humanReadableTime(this->time())
703 << ", step size: " << timeStepSize() << " seconds" << humanReadableTime(timeStepSize())
704 << "\n";
705 }
706
707 // pre-process the current solution
708 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->beginTimeStep());
709
710 if (finished()) {
711 // the problem can chose to terminate the simulation in
712 // beginTimeStep(), so we have handle this case.
713 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endTimeStep());
714 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endEpisode());
715 prePostProcessTimer_.stop();
716
717 break;
718 }
719 prePostProcessTimer_.stop();
720
721 try {
722 // execute the time integration scheme
723 problem_->timeIntegration();
724 }
725 catch (...) {
726 // exceptions in the time integration might be recoverable. clean up in
727 // case they are
728 const auto& model = problem_->model();
729 prePostProcessTimer_ += model.prePostProcessTimer();
730 linearizeTimer_ += model.linearizeTimer();
731 solveTimer_ += model.solveTimer();
732 updateTimer_ += model.updateTimer();
733
734 throw;
735 }
736
737 const auto& model = problem_->model();
738 prePostProcessTimer_ += model.prePostProcessTimer();
739 linearizeTimer_ += model.linearizeTimer();
740 solveTimer_ += model.solveTimer();
741 updateTimer_ += model.updateTimer();
742
743 // post-process the current solution
744 prePostProcessTimer_.start();
745 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endTimeStep());
746 prePostProcessTimer_.stop();
747
748 // write the result to disk
749 writeTimer_.start();
750 if (problem_->shouldWriteOutput())
751 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->writeOutput());
752 writeTimer_.stop();
753
754 // do the next time integration
755 Scalar oldDt = timeStepSize();
756 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->advanceTimeLevel());
757
758 if (verbose_) {
759 std::cout << "Time step " << timeStepIndex() + 1 << " done. "
760 << "CPU time: " << executionTimer_.realTimeElapsed() << " seconds" << humanReadableTime(executionTimer_.realTimeElapsed())
761 << ", end time: " << this->time() + oldDt << " seconds" << humanReadableTime(this->time() + oldDt)
762 << ", step size: " << oldDt << " seconds" << humanReadableTime(oldDt)
763 << "\n" << std::flush;
764 }
765
766 // advance the simulated time by the current time step size
767 time_ += oldDt;
768 ++timeStepIdx_;
769
770 prePostProcessTimer_.start();
771 // notify the problem if an episode is finished
772 if (episodeIsOver()) {
773 // Notify the problem about the end of the current episode...
774 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->endEpisode());
775 episodeBegins = true;
776 }
777 else {
778 Scalar dt;
779 if (timeStepIdx_ < static_cast<int>(forcedTimeSteps_.size()))
780 // use the next time step size from the input file
781 dt = forcedTimeSteps_[timeStepIdx_];
782 else
783 // ask the problem to provide the next time step size
784 dt = std::min(maxTimeStepSize(), problem_->nextTimeStepSize());
785 assert(finished() || dt > 0);
786 setTimeStepSize(dt);
787 }
788 prePostProcessTimer_.stop();
789
790 // write restart file if mandated by the problem
791 writeTimer_.start();
792 if (problem_->shouldWriteRestartFile())
793 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(serialize());
794 writeTimer_.stop();
795 }
796 executionTimer_.stop();
797
798 EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(problem_->finalize());
799 }
800
816 {
817 using Restarter = Restart;
818 Restarter res;
819 res.serializeBegin(*this);
820 if (gridView().comm().rank() == 0)
821 std::cout << "Serialize to file '" << res.fileName() << "'"
822 << ", next time step size: " << timeStepSize()
823 << "\n" << std::flush;
824
825 this->serialize(res);
826 problem_->serialize(res);
827 model_->serialize(res);
828 res.serializeEnd();
829 }
830
838 template <class Restarter>
839 void serialize(Restarter& restarter)
840 {
841 restarter.serializeSectionBegin("Simulator");
842 restarter.serializeStream()
843 << episodeIdx_ << " "
844 << episodeStartTime_ << " "
845 << episodeLength_ << " "
846 << startTime_ << " "
847 << time_ << " "
848 << timeStepIdx_ << " ";
849 restarter.serializeSectionEnd();
850 }
851
859 template <class Restarter>
860 void deserialize(Restarter& restarter)
861 {
862 restarter.deserializeSectionBegin("Simulator");
863 restarter.deserializeStream()
864 >> episodeIdx_
865 >> episodeStartTime_
866 >> episodeLength_
867 >> startTime_
868 >> time_
869 >> timeStepIdx_;
870 restarter.deserializeSectionEnd();
871 }
872
873 template<class Serializer>
874 void serializeOp(Serializer& serializer)
875 {
876 serializer(*vanguard_);
877 serializer(*model_);
878 serializer(*problem_);
879 serializer(episodeIdx_);
880 serializer(episodeStartTime_);
881 serializer(episodeLength_);
882 serializer(startTime_);
883 serializer(time_);
884 serializer(timeStepIdx_);
885 }
886
887private:
888 std::unique_ptr<Vanguard> vanguard_;
889 std::unique_ptr<Model> model_;
890 std::unique_ptr<Problem> problem_;
891
892 int episodeIdx_;
893 Scalar episodeStartTime_;
894 Scalar episodeLength_;
895
896 Timer setupTimer_;
897 Timer executionTimer_;
898 Timer prePostProcessTimer_;
899 Timer linearizeTimer_;
900 Timer solveTimer_;
901 Timer updateTimer_;
902 Timer writeTimer_;
903
904 std::vector<Scalar> forcedTimeSteps_;
905 Scalar startTime_;
906 Scalar time_;
907 Scalar endTime_;
908
909 Scalar timeStepSize_;
910 int timeStepIdx_;
911
912 bool finished_;
913 bool verbose_;
914};
915
916namespace Properties {
917template<class TypeTag>
918struct Simulator<TypeTag, TTag::NumericModel> { using type = ::Opm::Simulator<TypeTag>; };
919}
920
921} // namespace Opm
922
923#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
const std::string & fileName() const
Returns the name of the file which is (de-)serialized.
Definition restart.hpp:81
void deserializeBegin(Simulator &simulator, Scalar t)
Start reading a restart file at a certain simulated time.
Definition restart.hpp:151
void deserializeEnd()
Stop reading the restart file.
Definition restart.cpp:80
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:409
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:440
Scalar startTime() const
Return the time of the start of the simulation.
Definition simulator.hh:312
int timeStepIndex() const
Returns number of time steps which have been executed since the beginning of the simulation.
Definition simulator.hh:447
void serialize()
This method writes the complete state of the simulation to the harddisk.
Definition simulator.hh:815
Scalar episodeLength() const
Returns the length of the current episode in simulated time .
Definition simulator.hh:561
const Timer & prePostProcessTimer() const
Returns a reference to the timer object which measures the time needed for pre- and postprocessing of...
Definition simulator.hh:381
const Timer & solveTimer() const
Returns a reference to the timer object which measures the time needed by the solver.
Definition simulator.hh:395
void startNextEpisode(Scalar len=std::numeric_limits< Scalar >::max())
Start the next episode, but don't change the episode identifier.
Definition simulator.hh:519
const Vanguard & vanguard() const
Return a reference to the grid manager of simulation.
Definition simulator.hh:266
void serialize(Restarter &restarter)
Write the time manager's state to a restart file.
Definition simulator.hh:839
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:402
const Timer & executionTimer() const
Returns a reference to the timer object which measures the time needed to run the simulation.
Definition simulator.hh:372
void startNextEpisode(Scalar episodeStartTime, Scalar episodeLength)
Change the current episode of the simulation.
Definition simulator.hh:505
void setEndTime(Scalar t)
Set the time of simulated seconds at which the simulation runs.
Definition simulator.hh:351
const Timer & linearizeTimer() const
Returns a reference to the timer object which measures the time needed for linarizing the solutions.
Definition simulator.hh:388
void setStartTime(Scalar t)
Set the time of the start of the simulation.
Definition simulator.hh:306
void deserialize(Restarter &restarter)
Read the time manager's state from a restart file.
Definition simulator.hh:860
void setTimeStepSize(Scalar value)
Set the current time step size to a given value.
Definition simulator.hh:422
bool episodeStarts() const
Returns true if the current episode has just been started at the current time.
Definition simulator.hh:568
void run()
Runs the simulation using a given problem class.
Definition simulator.hh:628
Vanguard & vanguard()
Return a reference to the grid manager of simulation.
Definition simulator.hh:260
int episodeIndex() const
Returns the index of the current episode.
Definition simulator.hh:539
void setTimeStepIndex(unsigned value)
Set the current time step index to a given value.
Definition simulator.hh:432
void setFinished(bool yesno=true)
Specify whether the simulation is finished.
Definition simulator.hh:457
Problem & problem()
Return the object which specifies the pysical setup of the simulation.
Definition simulator.hh:291
static void registerParameters()
Registers all runtime parameters used by the simulation.
Definition simulator.hh:240
void setTime(Scalar t)
Set the current simulated time, don't change the current time step index.
Definition simulator.hh:321
bool willBeFinished() const
Returns true if the simulation is finished after the time level is incremented by the current time st...
Definition simulator.hh:479
bool finished() const
Returns true if the simulation is finished.
Definition simulator.hh:466
Scalar maxTimeStepSize() const
Aligns the time step size to the episode boundary and to the end time of the simulation.
Definition simulator.hh:490
const Model & model() const
Return the physical model used in the simulation.
Definition simulator.hh:284
void setTime(Scalar t, unsigned stepIdx)
Set the current simulated time and the time step index.
Definition simulator.hh:330
bool episodeIsOver() const
Returns true if the current episode is finished at the current time.
Definition simulator.hh:579
Scalar endTime() const
Returns the number of (simulated) seconds which the simulation runs.
Definition simulator.hh:358
bool episodeWillBeOver() const
Returns true if the current episode will be finished after the current time step.
Definition simulator.hh:590
const GridView & gridView() const
Return the grid view for which the simulation is done.
Definition simulator.hh:272
void setEpisodeIndex(int episodeIdx)
Sets the index of the current episode.
Definition simulator.hh:531
Scalar time() const
Return the number of seconds of simulated time which have elapsed since the start time.
Definition simulator.hh:343
void setEpisodeLength(Scalar dt)
Sets the length in seconds of the current episode.
Definition simulator.hh:554
const Problem & problem() const
Return the object which specifies the pysical setup of the simulation.
Definition simulator.hh:298
Model & model()
Return the physical model used in the simulation.
Definition simulator.hh:278
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:602
Scalar episodeStartTime() const
Returns the absolute time when the current episode started .
Definition simulator.hh:546
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:365
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
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
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
std::vector< Scalar > readTimeStepFile(const std::string &file)
Read explicitly defined time steps from file.
Definition simulatorutils.cpp:146
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.
Manages the simulation time.
Definition basicproperties.hh:116
Provides an encapsulation to measure the system time.
A simple class which makes sure that a timer gets stopped if an exception is thrown.