00001 /* 00002 Copyright (c) 2014 IRIS AS 00003 00004 This file is part of the Open Porous Media project (OPM). 00005 00006 OPM is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 OPM is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with OPM. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef OPM_SIMULATORTIMERINTERFACE_HEADER_INCLUDED 00021 #define OPM_SIMULATORTIMERINTERFACE_HEADER_INCLUDED 00022 00023 #include <memory> 00024 00025 #include <boost/date_time/gregorian/gregorian.hpp> 00026 #include <boost/date_time/posix_time/posix_time_types.hpp> 00027 #include <boost/date_time/posix_time/conversion.hpp> 00028 00029 namespace Opm 00030 { 00031 00032 class ParameterGroup; 00033 00035 class SimulatorTimerInterface 00036 { 00037 protected: 00039 SimulatorTimerInterface() {} 00040 00041 public: 00043 virtual ~SimulatorTimerInterface() {} 00044 00049 virtual int currentStepNum() const = 0; 00050 00052 virtual int reportStepNum() const { return currentStepNum(); } 00053 00058 virtual double currentStepLength() const = 0; 00059 00066 virtual double stepLengthTaken () const = 0; 00067 00074 virtual double reportStepLengthTaken () const { return stepLengthTaken(); } 00075 00078 virtual double simulationTimeElapsed() const = 0; 00079 00081 virtual void advance() = 0 ; 00082 00084 virtual bool done() const = 0; 00085 00087 virtual bool initialStep() const = 0; 00088 00090 virtual boost::posix_time::ptime startDateTime() const = 0; 00091 00093 virtual boost::posix_time::ptime currentDateTime() const 00094 { 00095 return startDateTime() + boost::posix_time::seconds( (int) simulationTimeElapsed()); 00096 //boost::posix_time::ptime(startDate()) + boost::posix_time::seconds( (int) simulationTimeElapsed()); 00097 } 00098 00101 virtual time_t currentPosixTime() const 00102 { 00103 tm t = boost::posix_time::to_tm(currentDateTime()); 00104 return std::mktime(&t); 00105 } 00106 00108 virtual bool lastStepFailed() const = 0; 00109 00111 virtual std::unique_ptr< SimulatorTimerInterface > clone () const = 0; 00112 }; 00113 00114 00115 } // namespace Opm 00116 00117 #endif // OPM_SIMULATORTIMER_HEADER_INCLUDED