fix date for large time steps

This commit is contained in:
Tor Harald Sandve 2021-09-29 15:43:20 +02:00
parent edb2c4abb2
commit 06878a8ca8
3 changed files with 6 additions and 15 deletions

View File

@ -115,15 +115,6 @@ namespace Opm
}
boost::posix_time::ptime SimulatorTimer::currentDateTime() const
{
// Boost uses only 32 bit long for seconds, but 64 bit for milliseconds.
// As a workaround for very large times we just use milliseconds.
// The cast is necessary because boost::posix_time::milliseconds requires
// an integer argument.
return startDateTime() + boost::posix_time::milliseconds(static_cast<long long>(simulationTimeElapsed() / Opm::prefix::milli));
}
/// Total time.
double SimulatorTimer::totalTime() const
{

View File

@ -90,9 +90,6 @@ namespace Opm
/// Return start date of simulation
boost::posix_time::ptime startDateTime() const override;
/// Return current date.
boost::posix_time::ptime currentDateTime() const override;
/// Set total time.
/// This is primarily intended for multi-epoch schedules,
/// where a timer for a given epoch does not have

View File

@ -19,7 +19,7 @@
#include <config.h>
#include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
namespace Opm
@ -27,8 +27,11 @@ 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());
// Boost uses only 32 bit long for seconds, but 64 bit for milliseconds.
// As a workaround for very large times we just use milliseconds.
// The cast is necessary because boost::posix_time::milliseconds requires
// an integer argument.
return startDateTime() + boost::posix_time::milliseconds(static_cast<long long>(simulationTimeElapsed() / Opm::prefix::milli));
}
time_t SimulatorTimerInterface::currentPosixTime() const