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/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
24 #include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
25 
26 #include <iosfwd>
27 #include <vector>
28 
29 namespace Opm
30 {
31 
32  class ParameterGroup;
33 
35  {
36  public:
37  // use default implementation of these methods
40 
43 
47  void init(const ParameterGroup& param);
48 
50  void init(const TimeMap& timeMap, size_t report_step = 0);
51 
53  bool initialStep() const;
54 
56  int numSteps() const;
57 
62  int currentStepNum() const;
63 
65  void setCurrentStepNum(int step);
66 
71  double currentStepLength() const;
72 
79  double stepLengthTaken () const;
80 
83  double simulationTimeElapsed() const;
84 
86  double totalTime() const;
87 
89  boost::posix_time::ptime startDateTime() const;
90 
92  boost::posix_time::ptime currentDateTime() const;
93 
98  void setTotalTime(double time);
99 
102  void report(std::ostream& os) const;
103 
106 
108  void advance() { this->operator++(); }
109 
111  bool done() const;
112 
115  bool lastStepFailed() const {return false;}
116 
118  virtual std::unique_ptr< SimulatorTimerInterface > clone() const;
119 
120  private:
121  std::vector<double> timesteps_;
122  int current_step_;
123  double current_time_;
124  double total_time_;
125  boost::gregorian::date start_date_;
126  };
127 
128 
129 } // namespace Opm
130 
131 #endif // OPM_SIMULATORTIMER_HEADER_INCLUDED
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.hpp:101
int currentStepNum() const
Current step number.
Definition: SimulatorTimer.cpp:77
virtual boost::posix_time::ptime currentDateTime() const
Return the current time as a posix time object.
Definition: SimulatorTimerInterface.hpp:93
bool lastStepFailed() const
Always return false.
Definition: SimulatorTimer.hpp:115
double currentStepLength() const
Current step length.
Definition: SimulatorTimer.cpp:91
int numSteps() const
Total number of steps.
Definition: SimulatorTimer.cpp:71
double totalTime() const
Total time.
Definition: SimulatorTimer.cpp:121
void report(std::ostream &os) const
Print a report with current and total time etc.
Definition: SimulatorTimer.cpp:136
boost::posix_time::ptime currentDateTime() const
Return current date.
Definition: SimulatorTimer.cpp:115
SimulatorTimer & operator++()
advance time by currentStepLength
Definition: SimulatorTimer.cpp:146
double simulationTimeElapsed() const
Time elapsed since the start of the simulation until the beginning of the current time step [s]...
Definition: SimulatorTimer.cpp:104
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: AdditionalObjectDeleter.hpp:22
void init(const ParameterGroup &param)
Initialize from parameters.
Definition: SimulatorTimer.cpp:41
void setTotalTime(double time)
Set total time.
Definition: SimulatorTimer.cpp:130
void setCurrentStepNum(int step)
Set current step number.
Definition: SimulatorTimer.cpp:83
void advance()
advance time by currentStepLength
Definition: SimulatorTimer.hpp:108
double stepLengthTaken() const
Previous step length.
Definition: SimulatorTimer.cpp:97
virtual std::unique_ptr< SimulatorTimerInterface > clone() const
return copy of object
Definition: SimulatorTimer.cpp:162
bool done() const
Return true if op++() has been called numSteps() times.
Definition: SimulatorTimer.cpp:155
Interface class for SimulatorTimer objects, to be improved.
Definition: SimulatorTimerInterface.hpp:35
bool initialStep() const
Whether the current step is the first step.
Definition: SimulatorTimer.cpp:65
boost::posix_time::ptime startDateTime() const
Return start date of simulation.
Definition: SimulatorTimer.cpp:109
Definition: SimulatorTimer.hpp:34
SimulatorTimer()
Default constructor.
Definition: SimulatorTimer.cpp:31