Use std::chrono::system_clock with 1/1000 second resolution

This commit is contained in:
Joakim Hove 2021-02-25 20:46:51 +01:00
parent 6f15765f53
commit 74ca0d12e0
7 changed files with 17 additions and 11 deletions

View File

@ -49,6 +49,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp>
#include <opm/common/utility/TimeService.hpp>
#include <opm/simulators/utils/readDeck.hpp>
@ -448,7 +449,7 @@ public:
std::move(parseContext_), /* initFromRestart = */ false,
/* checkDeck = */ enableExperiments);
this->summaryState_ = std::make_unique<Opm::SummaryState>( std::chrono::system_clock::from_time_t(this->eclSchedule_->getStartTime() ));
this->summaryState_ = std::make_unique<Opm::SummaryState>( Opm::TimeService::from_time_t(this->eclSchedule_->getStartTime() ));
this->udqState_ = std::make_unique<Opm::UDQState>( this->eclSchedule_->getUDQConfig(0).params().undefinedValue() );
this->actionState_ = std::make_unique<Opm::Action::State>() ;

View File

@ -99,6 +99,7 @@
#include <opm/parser/eclipse/EclipseState/Tables/RockwnodTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/OverburdTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/RocktabTable.hpp>
#include <opm/common/utility/TimeService.hpp>
#include <opm/material/common/ConditionalStorage.hpp>
#include <dune/common/version.hh>
@ -1378,7 +1379,7 @@ public:
const auto& wellpi = this->fetchWellPI(reportStep, *action, schedule, matching_wells);
schedule.applyAction(reportStep, std::chrono::system_clock::from_time_t(simTime), *action, actionResult, wellpi);
schedule.applyAction(reportStep, Opm::TimeService::from_time_t(simTime), *action, actionResult, wellpi);
actionState.add_run(*action, simTime);
for ( const auto& [wname, _] : wellpi) {

View File

@ -28,6 +28,7 @@
#include <opm/simulators/wells/VFPProperties.hpp>
#include <opm/simulators/wells/VFPInjProperties.hpp>
#include <opm/simulators/wells/VFPProdProperties.hpp>
#include <opm/common/utility/TimeService.hpp>
#include <iostream>
#include <iomanip>
@ -52,7 +53,7 @@ struct Setup
const Runspec runspec(deck);
python = std::make_shared<Python>();
schedule.reset( new Schedule(deck, *ecl_state, python));
summary_state.reset( new SummaryState(std::chrono::system_clock::from_time_t(schedule->getStartTime())));
summary_state.reset( new SummaryState(TimeService::from_time_t(schedule->getStartTime())));
}
const int step = 0;
const auto& sched_state = schedule->operator[](step);

View File

@ -283,7 +283,7 @@ std::size_t packSize(const RestartValue& data, Dune::MPIHelper::MPICommunicator
+ packSize(data.extra, comm);
}
std::size_t packSize(const std::chrono::system_clock::time_point&, Dune::MPIHelper::MPICommunicator comm)
std::size_t packSize(const Opm::time_point&, Dune::MPIHelper::MPICommunicator comm)
{
std::time_t tp;
return packSize(tp, comm);
@ -576,10 +576,10 @@ void pack(const RestartValue& data, std::vector<char>& buffer, int& position,
pack(data.extra, buffer, position, comm);
}
void pack(const std::chrono::system_clock::time_point& data, std::vector<char>& buffer, int& position,
void pack(const Opm::time_point& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(std::chrono::system_clock::to_time_t(data), buffer, position, comm);
pack(Opm::TimeService::to_time_t(data), buffer, position, comm);
}
@ -887,12 +887,12 @@ void unpack(RestartValue& data, std::vector<char>& buffer, int& position,
unpack(data.extra, buffer, position, comm);
}
void unpack(std::chrono::system_clock::time_point& data, std::vector<char>& buffer, int& position,
void unpack(Opm::time_point& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
std::time_t tp;
unpack(tp, buffer, position, comm);
data = std::chrono::system_clock::from_time_t(tp);
data = Opm::TimeService::from_time_t(tp);
}

View File

@ -27,6 +27,7 @@
#include <opm/output/eclipse/EclipseIO.hpp>
#include <opm/output/eclipse/Summary.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/common/utility/TimeService.hpp>
#include <dune/common/parallel/mpihelper.hh>
@ -321,7 +322,7 @@ ADD_PACK_PROTOTYPES(data::WellRates)
ADD_PACK_PROTOTYPES(RestartKey)
ADD_PACK_PROTOTYPES(RestartValue)
ADD_PACK_PROTOTYPES(std::string)
ADD_PACK_PROTOTYPES(std::chrono::system_clock::time_point)
ADD_PACK_PROTOTYPES(Opm::time_point)
} // end namespace Mpi

View File

@ -37,6 +37,7 @@
#include <opm/grid/GridManager.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/common/utility/TimeService.hpp>
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
#include <opm/grid/GridHelpers.hpp>
@ -73,7 +74,7 @@ struct SetupTest {
const Opm::Runspec runspec (deck);
python = std::make_shared<Opm::Python>();
schedule.reset( new Opm::Schedule(deck, *ecl_state, python));
summaryState.reset( new Opm::SummaryState(std::chrono::system_clock::from_time_t(schedule->getStartTime())));
summaryState.reset( new Opm::SummaryState(Opm::TimeService::from_time_t(schedule->getStartTime())));
}
current_timestep = 0;
};

View File

@ -31,6 +31,7 @@
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/common/utility/TimeService.hpp>
#include <opm/grid/GridHelpers.hpp>
@ -57,7 +58,7 @@ struct Setup
, grid (es.getInputGrid())
, python( std::make_shared<Opm::Python>() )
, sched(deck, es, python)
, st(std::chrono::system_clock::from_time_t(sched.getStartTime()))
, st(Opm::TimeService::from_time_t(sched.getStartTime()))
{
initWellPerfData();
}