Part 2: Use Opm::time_point
This commit is contained in:
@@ -291,12 +291,12 @@ npArray get_rft_vector_Index(Opm::EclIO::ERft * file_ptr,const std::string& name
|
||||
the pybind11 conversion.
|
||||
*/
|
||||
|
||||
std::chrono::system_clock::time_point esmry_start_date(const Opm::EclIO::ESmry * esmry) {
|
||||
time_point esmry_start_date(const Opm::EclIO::ESmry * esmry) {
|
||||
auto utc_chrono = esmry->startdate();
|
||||
auto utc_time_t = std::chrono::system_clock::to_time_t( utc_chrono );
|
||||
auto utc_ts = Opm::TimeStampUTC( utc_time_t );
|
||||
auto local_time_t = Opm::asLocalTimeT( utc_ts );
|
||||
return std::chrono::system_clock::from_time_t( local_time_t );
|
||||
return TimeService::from_time_t( local_time_t );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <chrono>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/chrono.h>
|
||||
@@ -42,7 +43,7 @@ std::vector<std::string> wells(const SummaryState * st) {
|
||||
void python::common::export_SummaryState(py::module& module) {
|
||||
|
||||
py::class_<SummaryState>(module, "SummaryState")
|
||||
.def(py::init<std::chrono::system_clock::time_point>())
|
||||
.def(py::init<std::time_t>())
|
||||
.def("update", &SummaryState::update)
|
||||
.def("update_well_var", &SummaryState::update_well_var)
|
||||
.def("update_group_var", &SummaryState::update_group_var)
|
||||
|
||||
@@ -9,7 +9,7 @@ class TestSummaryState(unittest.TestCase):
|
||||
pass
|
||||
|
||||
def test_create(self):
|
||||
st = opm.io.sim.SummaryState(datetime.datetime.now())
|
||||
st = opm.io.sim.SummaryState(int(datetime.datetime.now().timestamp()))
|
||||
st.update("FOPT", 100)
|
||||
self.assertEqual(st["FOPT"], 100)
|
||||
self.assertTrue("FOPT" in st)
|
||||
|
||||
Reference in New Issue
Block a user