SimulatorTimerInterface.hpp
1 /*
2  Copyright (c) 2014 IRIS AS
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_SIMULATORTIMERINTERFACE_HEADER_INCLUDED
21 #define OPM_SIMULATORTIMERINTERFACE_HEADER_INCLUDED
22 
23 #include <memory>
24 
25 #include <boost/date_time/gregorian/gregorian.hpp>
26 #include <boost/date_time/posix_time/posix_time_types.hpp>
27 #include <boost/date_time/posix_time/conversion.hpp>
28 
29 namespace Opm
30 {
31 
32  class ParameterGroup;
33 
36  {
37  protected:
40 
41  public:
44 
49  virtual int currentStepNum() const = 0;
50 
52  virtual int reportStepNum() const { return currentStepNum(); }
53 
58  virtual double currentStepLength() const = 0;
59 
66  virtual double stepLengthTaken () const = 0;
67 
74  virtual double reportStepLengthTaken () const { return stepLengthTaken(); }
75 
78  virtual double simulationTimeElapsed() const = 0;
79 
81  virtual void advance() = 0 ;
82 
84  virtual bool done() const = 0;
85 
87  virtual bool initialStep() const = 0;
88 
90  virtual boost::posix_time::ptime startDateTime() const = 0;
91 
93  virtual boost::posix_time::ptime currentDateTime() const
94  {
95  return startDateTime() + boost::posix_time::seconds( (int) simulationTimeElapsed());
96  //boost::posix_time::ptime(startDate()) + boost::posix_time::seconds( (int) simulationTimeElapsed());
97  }
98 
101  virtual time_t currentPosixTime() const
102  {
103  tm t = boost::posix_time::to_tm(currentDateTime());
104  return std::mktime(&t);
105  }
106 
108  virtual bool lastStepFailed() const = 0;
109 
111  virtual std::unique_ptr< SimulatorTimerInterface > clone () const = 0;
112  };
113 
114 
115 } // namespace Opm
116 
117 #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
virtual bool done() const =0
Return true if timer indicates that simulation of timer interval is finished.
virtual boost::posix_time::ptime currentDateTime() const
Return the current time as a posix time object.
Definition: SimulatorTimerInterface.hpp:93
virtual int reportStepNum() const
Current report step number. This might differ from currentStepNum in case of sub stepping.
Definition: SimulatorTimerInterface.hpp:52
virtual double reportStepLengthTaken() const
Previous report step length.
Definition: SimulatorTimerInterface.hpp:74
virtual std::unique_ptr< SimulatorTimerInterface > clone() const =0
return copy of current timer instance
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: AdditionalObjectDeleter.hpp:22
virtual bool lastStepFailed() const =0
Return true if last time step failed.
virtual ~SimulatorTimerInterface()
destructor
Definition: SimulatorTimerInterface.hpp:43
virtual double stepLengthTaken() const =0
Previous step length.
SimulatorTimerInterface()
Default constructor, protected to not allow explicit instances of this class.
Definition: SimulatorTimerInterface.hpp:39
virtual double currentStepLength() const =0
Current step length.
virtual boost::posix_time::ptime startDateTime() const =0
Return start date of simulation.
virtual void advance()=0
advance time by currentStepLength
Interface class for SimulatorTimer objects, to be improved.
Definition: SimulatorTimerInterface.hpp:35
virtual int currentStepNum() const =0
Current step number.
virtual bool initialStep() const =0
Whether the current step is the first step.
virtual double simulationTimeElapsed() const =0
Time elapsed since the start of the simulation until the beginning of the current time step [s]...