Merge pull request #3560 from totto82/fixTime

fix date for large time steps also for the interface functions
This commit is contained in:
Bård Skaflestad 2021-09-29 22:19:46 +02:00 committed by GitHub
commit e80408d1ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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