From 1c8724b60103128aa4a7e8ad8fb816fbe91a5e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 11 Dec 2024 15:12:48 +0100 Subject: [PATCH] Do not serialize time_point via time_t. Avoids losing resolution (ms to s). --- opm/simulators/utils/MPIPacker.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/opm/simulators/utils/MPIPacker.cpp b/opm/simulators/utils/MPIPacker.cpp index bb91d664a..581e58968 100644 --- a/opm/simulators/utils/MPIPacker.cpp +++ b/opm/simulators/utils/MPIPacker.cpp @@ -118,7 +118,7 @@ unpack(std::string& data, std::size_t Packing:: packSize(const time_point&, Opm::Parallel::MPIComm comm) { - return Packing::packSize(std::time_t(), comm); + return Packing::packSize(time_point::duration::rep(), comm); } void Packing:: @@ -127,8 +127,7 @@ pack(const time_point& data, std::size_t& position, Parallel::MPIComm comm) { - Packing::pack(TimeService::to_time_t(data), - buffer, position, comm); + Packing::pack(data.time_since_epoch().count(), buffer, position, comm); } void Packing:: @@ -137,9 +136,9 @@ unpack(time_point& data, std::size_t& position, Parallel::MPIComm comm) { - std::time_t res; - Packing::unpack(res, buffer, position, comm); - data = TimeService::from_time_t(res); + time_point::duration::rep res; + Packing::unpack(res, buffer, position, comm); + data = time_point(time_point::duration(res)); } template struct Packing>;