From ce01d780cfbb5464c2e4e9e2e676a07f58fd72b5 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 8 Jun 2021 15:44:56 +0200 Subject: [PATCH] SimulatorTimerInterface: avoid boost includes in header --- CMakeLists_files.cmake | 1 + .../timestepping/SimulatorTimerInterface.cpp | 40 +++++++++++++++++++ .../timestepping/SimulatorTimerInterface.hpp | 16 ++------ 3 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 opm/simulators/timestepping/SimulatorTimerInterface.cpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 53b195596..665d2e2c6 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -51,6 +51,7 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/timestepping/AdaptiveTimeSteppingEbos.cpp opm/simulators/timestepping/TimeStepControl.cpp opm/simulators/timestepping/SimulatorTimer.cpp + opm/simulators/timestepping/SimulatorTimerInterface.cpp opm/simulators/timestepping/gatherConvergenceReport.cpp opm/simulators/utils/DeferredLogger.cpp opm/simulators/utils/gatherDeferredLogger.cpp diff --git a/opm/simulators/timestepping/SimulatorTimerInterface.cpp b/opm/simulators/timestepping/SimulatorTimerInterface.cpp new file mode 100644 index 000000000..ab61a0204 --- /dev/null +++ b/opm/simulators/timestepping/SimulatorTimerInterface.cpp @@ -0,0 +1,40 @@ +/* + Copyright (c) 2014 IRIS AS + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#include +#include + +#include + +namespace Opm +{ + +boost::posix_time::ptime SimulatorTimerInterface::currentDateTime() const +{ + return startDateTime() + boost::posix_time::seconds( (int) simulationTimeElapsed()); + //boost::posix_time::ptime(startDate()) + boost::posix_time::seconds( (int) simulationTimeElapsed()); +} + +time_t SimulatorTimerInterface::currentPosixTime() const +{ + tm t = boost::posix_time::to_tm(currentDateTime()); + return std::mktime(&t); +} + +} // namespace Opm diff --git a/opm/simulators/timestepping/SimulatorTimerInterface.hpp b/opm/simulators/timestepping/SimulatorTimerInterface.hpp index 859db1c9c..6875db871 100644 --- a/opm/simulators/timestepping/SimulatorTimerInterface.hpp +++ b/opm/simulators/timestepping/SimulatorTimerInterface.hpp @@ -22,9 +22,7 @@ #include -#include -#include -#include +namespace boost { namespace posix_time { class ptime; } } namespace Opm { @@ -90,19 +88,11 @@ namespace Opm virtual boost::posix_time::ptime startDateTime() const = 0; /// Return the current time as a posix time object. - virtual boost::posix_time::ptime currentDateTime() const - { - return startDateTime() + boost::posix_time::seconds( (int) simulationTimeElapsed()); - //boost::posix_time::ptime(startDate()) + boost::posix_time::seconds( (int) simulationTimeElapsed()); - } + virtual boost::posix_time::ptime currentDateTime() const; /// Time elapsed since the start of the POSIX epoch (Jan 1st, /// 1970) until the current time step begins [s]. - virtual time_t currentPosixTime() const - { - tm t = boost::posix_time::to_tm(currentDateTime()); - return std::mktime(&t); - } + virtual time_t currentPosixTime() const; /// Return true if last time step failed virtual bool lastStepFailed() const = 0;