Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion opm/simulators/timestepping/SimulatorTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ namespace Opm

boost::posix_time::ptime SimulatorTimer::currentDateTime() const
{
return startDateTime() + boost::posix_time::seconds( (int) simulationTimeElapsed());
// boost uses only 32 bit long for seconds. But 64 bit for milliseconds
// as a work around for very large timess we just use milliseconds
return startDateTime() + boost::posix_time::milliseconds( simulationTimeElapsed() / Opm::prefix::milli);
}

/// Total time.
Expand Down
3 changes: 3 additions & 0 deletions tests/TESTTIMER.DATA
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ TSTEP
TSTEP
21*5.0 /

TSTEP
5*365000 /

END ==
12 changes: 9 additions & 3 deletions tests/test_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ BOOST_AUTO_TEST_CASE(CreateTimer)

BOOST_CHECK_EQUAL( 0, simtimer.currentStepNum() );
BOOST_CHECK_EQUAL( 0., simtimer.simulationTimeElapsed() );
BOOST_CHECK_EQUAL( 120, simtimer.numSteps() );
BOOST_CHECK_EQUAL( 1200., Opm::unit::convert::to(simtimer.totalTime(), Opm::unit::day) );
BOOST_CHECK_EQUAL( 125, simtimer.numSteps() );
// 1200 + 1000 * 365 * 5
BOOST_CHECK_EQUAL( 1826200, Opm::unit::convert::to(simtimer.totalTime(), Opm::unit::day) );
BOOST_CHECK_EQUAL( 0., Opm::unit::convert::to(simtimer.simulationTimeElapsed(), Opm::unit::day) );

double testCurrentTime = 0.;
Expand All @@ -85,9 +86,12 @@ BOOST_AUTO_TEST_CASE(CreateTimer)
BOOST_CHECK_EQUAL( false, simtimer.done() );
BOOST_CHECK_EQUAL( 0., Opm::unit::convert::to(simtimer.simulationTimeElapsed(), Opm::unit::day) );

simtimer.setCurrentStepNum(120);
simtimer.setCurrentStepNum(125);
BOOST_CHECK_EQUAL( Opm::unit::convert::to(simtimer.simulationTimeElapsed(), Opm::unit::day),
Opm::unit::convert::to(simtimer.totalTime(), Opm::unit::day) );

boost::gregorian::date endDate( 7014, 3, 14);
BOOST_CHECK_EQUAL ( simtimer.currentDateTime(), boost::posix_time::ptime(endDate));

int i = 0;
double testCurrentTime1 = 0.;
Expand All @@ -111,5 +115,7 @@ BOOST_AUTO_TEST_CASE(CreateTimer)
Opm::unit::convert::to(simtimer.totalTime(), Opm::unit::minute) );
BOOST_CHECK_EQUAL( Opm::unit::convert::to(testCurrentTime2, Opm::unit::minute),
Opm::unit::convert::to(simtimer.totalTime(), Opm::unit::minute) );



}