My Project
SimulatorTimer.hpp
1 /*
2  Copyright 2012 SINTEF ICT, Applied Mathematics.
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 3 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 
20 #ifndef OPM_SIMULATORTIMER_HEADER_INCLUDED
21 #define OPM_SIMULATORTIMER_HEADER_INCLUDED
22 
23 #include <opm/input/eclipse/Schedule/Schedule.hpp>
24 #include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
25 
26 #include <iosfwd>
27 #include <vector>
28 
29 namespace boost { namespace gregorian { class date; } }
30 
31 namespace Opm
32 {
33 
34  class ParameterGroup;
35 
37  {
38  public:
39  // use default implementation of these methods
42 
45 
49  void init(const ParameterGroup& param);
50 
52  void init(const Schedule& schedule, size_t report_step = 0);
53 
55  bool initialStep() const override;
56 
58  int numSteps() const;
59 
64  int currentStepNum() const override;
65 
67  void setCurrentStepNum(int step);
68 
73  double currentStepLength() const override;
74 
81  double stepLengthTaken () const override;
82 
85  double simulationTimeElapsed() const override;
86 
88  double totalTime() const;
89 
91  boost::posix_time::ptime startDateTime() const override;
92 
97  void setTotalTime(double time);
98 
101  void report(std::ostream& os) const;
102 
105 
107  void advance() override { this->operator++(); }
108 
110  bool done() const override;
111 
114  bool lastStepFailed() const override { return false; }
115 
117  std::unique_ptr< SimulatorTimerInterface > clone() const override;
118 
119  private:
120  std::vector<double> timesteps_;
121  int current_step_;
122  double current_time_;
123  double total_time_;
124  std::shared_ptr<boost::gregorian::date> start_date_;
125  };
126 
127 
128 } // namespace Opm
129 
130 #endif // OPM_SIMULATORTIMER_HEADER_INCLUDED
Interface class for SimulatorTimer objects, to be improved.
Definition: SimulatorTimerInterface.hpp:34
virtual time_t currentPosixTime() const
Time elapsed since the start of the POSIX epoch (Jan 1st, 1970) until the current time step begins [s...
Definition: SimulatorTimerInterface.cpp:37
virtual boost::posix_time::ptime currentDateTime() const
Return the current time as a posix time object.
Definition: SimulatorTimerInterface.cpp:28
Definition: SimulatorTimer.hpp:37
void setTotalTime(double time)
Set total time.
Definition: SimulatorTimer.cpp:128
double totalTime() const
Total time.
Definition: SimulatorTimer.cpp:119
bool lastStepFailed() const override
Always return false.
Definition: SimulatorTimer.hpp:114
boost::posix_time::ptime startDateTime() const override
Return start date of simulation.
Definition: SimulatorTimer.cpp:112
int numSteps() const
Total number of steps.
Definition: SimulatorTimer.cpp:74
double currentStepLength() const override
Current step length.
Definition: SimulatorTimer.cpp:94
bool initialStep() const override
Whether the current step is the first step.
Definition: SimulatorTimer.cpp:68
void advance() override
advance time by currentStepLength
Definition: SimulatorTimer.hpp:107
std::unique_ptr< SimulatorTimerInterface > clone() const override
return copy of object
Definition: SimulatorTimer.cpp:160
void setCurrentStepNum(int step)
Set current step number.
Definition: SimulatorTimer.cpp:86
void report(std::ostream &os) const
Print a report with current and total time etc.
Definition: SimulatorTimer.cpp:134
double simulationTimeElapsed() const override
Time elapsed since the start of the simulation until the beginning of the current time step [s].
Definition: SimulatorTimer.cpp:107
int currentStepNum() const override
Current step number.
Definition: SimulatorTimer.cpp:80
double stepLengthTaken() const override
Previous step length.
Definition: SimulatorTimer.cpp:100
SimulatorTimer()
Default constructor.
Definition: SimulatorTimer.cpp:34
SimulatorTimer & operator++()
advance time by currentStepLength
Definition: SimulatorTimer.cpp:144
bool done() const override
Return true if op++() has been called numSteps() times.
Definition: SimulatorTimer.cpp:153
void init(const ParameterGroup &param)
Initialize from parameters.
Definition: SimulatorTimer.cpp:44
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27