SimulatorTimerInterface.hpp
Go to the documentation of this file.
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 <boost/date_time/gregorian/gregorian.hpp>
24 #include <boost/date_time/posix_time/posix_time_types.hpp>
25 #include <boost/date_time/posix_time/conversion.hpp>
26 
27 namespace Opm
28 {
29 
30  namespace parameter { class ParameterGroup; }
31 
34  {
35  protected:
38 
39  public:
42 
47  virtual int currentStepNum() const = 0;
48 
50  virtual int reportStepNum() const { return currentStepNum(); }
51 
56  virtual double currentStepLength() const = 0;
57 
64  virtual double stepLengthTaken () const = 0;
65 
72  virtual double reportStepLengthTaken () const { return stepLengthTaken(); }
73 
76  virtual double simulationTimeElapsed() const = 0;
77 
79  virtual void advance() = 0 ;
80 
82  virtual bool done() const = 0;
83 
85  virtual boost::posix_time::ptime startDateTime() const = 0;
86 
88  virtual boost::posix_time::ptime currentDateTime() const
89  {
90  return startDateTime() + boost::posix_time::seconds( (int) simulationTimeElapsed());
91  //boost::posix_time::ptime(startDate()) + boost::posix_time::seconds( (int) simulationTimeElapsed());
92  }
93 
96  virtual time_t currentPosixTime() const
97  {
98  tm t = boost::posix_time::to_tm(currentDateTime());
99  return std::mktime(&t);
100  }
101  };
102 
103 
104 } // namespace Opm
105 
106 #endif // OPM_SIMULATORTIMER_HEADER_INCLUDED
virtual double currentStepLength() const =0
Definition: AnisotropicEikonal.hpp:43
virtual double reportStepLengthTaken() const
Definition: SimulatorTimerInterface.hpp:72
SimulatorTimerInterface()
Default constructor, protected to not allow explicit instances of this class.
Definition: SimulatorTimerInterface.hpp:37
virtual boost::posix_time::ptime currentDateTime() const
Return the current time as a posix time object.
Definition: SimulatorTimerInterface.hpp:88
virtual boost::posix_time::ptime startDateTime() const =0
Return start date of simulation.
virtual bool done() const =0
Return true if timer indicates that simulation of timer interval is finished.
virtual ~SimulatorTimerInterface()
destructor
Definition: SimulatorTimerInterface.hpp:41
virtual time_t currentPosixTime() const
Definition: SimulatorTimerInterface.hpp:96
virtual int reportStepNum() const
Current report step number. This might differ from currentStepNum in case of sub stepping.
Definition: SimulatorTimerInterface.hpp:50
virtual double stepLengthTaken() const =0
Interface class for SimulatorTimer objects, to be improved.
Definition: SimulatorTimerInterface.hpp:33
virtual void advance()=0
advance time by currentStepLength
virtual int currentStepNum() const =0
virtual double simulationTimeElapsed() const =0