From 54509c7b56d9fb702fe7ca4e20bc6d4bb316ff33 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 22 Jan 2020 16:40:23 +0100 Subject: [PATCH] Use (std::vector&) constructor when serialing TimeMap --- opm/simulators/utils/ParallelRestart.cpp | 34 ++---------------------- opm/simulators/utils/ParallelRestart.hpp | 1 - tests/test_ParallelRestart.cpp | 14 +--------- 3 files changed, 3 insertions(+), 46 deletions(-) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index f79336df7..89553d5a4 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -611,9 +611,7 @@ std::size_t packSize(const SimulationConfig& data, Dune::MPIHelper::MPICommunica std::size_t packSize(const TimeMap& data, Dune::MPIHelper::MPICommunicator comm) { - return packSize(data.timeList(), comm) + - packSize(data.firstTimeStepMonths(), comm) + - packSize(data.firstTimeStepYears(), comm); + return packSize(data.timeList(), comm); } std::size_t packSize(const RestartConfig& data, Dune::MPIHelper::MPICommunicator comm) @@ -1923,13 +1921,6 @@ std::size_t packSize(const TimeStampUTC& data, packSize(data.microseconds(), comm); } -std::size_t packSize(const TimeMap::StepData& data, - Dune::MPIHelper::MPICommunicator comm) -{ - return packSize(data.stepnumber, comm) + - packSize(data.timestamp, comm); -} - std::size_t packSize(const EclHysterConfig& data, Dune::MPIHelper::MPICommunicator comm) { @@ -2449,8 +2440,6 @@ void pack(const TimeMap& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { pack(data.timeList(), buffer, position, comm); - pack(data.firstTimeStepMonths(), buffer, position, comm); - pack(data.firstTimeStepYears(), buffer, position, comm); } void pack(const RestartConfig& data, std::vector& buffer, int& position, @@ -3831,14 +3820,6 @@ void pack(const TimeStampUTC& data, pack(data.microseconds(), buffer, position, comm); } -void pack(const TimeMap::StepData& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - pack(data.stepnumber, buffer, position, comm); - pack(data.timestamp, buffer, position, comm); -} - void pack(const EclHysterConfig& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -4496,13 +4477,9 @@ void unpack(TimeMap& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { std::vector timeList; - std::vector firstStepMonths; - std::vector firstStepYears; unpack(timeList, buffer, position, comm); - unpack(firstStepMonths, buffer, position, comm); - unpack(firstStepYears, buffer, position, comm); - data = TimeMap(timeList, firstStepMonths, firstStepYears); + data = TimeMap(timeList); } void unpack(RestartConfig& data, std::vector& buffer, int& position, @@ -6594,13 +6571,6 @@ void unpack(TimeStampUTC& data, data = TimeStampUTC(ymd, hour, minutes, seconds, usec); } -void unpack(TimeMap::StepData& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - unpack(data.stepnumber, buffer, position, comm); - unpack(data.timestamp, buffer, position, comm); -} void unpack(EclHysterConfig& data, std::vector& buffer, int& position, diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index d32dc237c..d9fc886a1 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -746,7 +746,6 @@ ADD_PACK_PROTOTYPES(TableManager) ADD_PACK_PROTOTYPES(TableSchema) ADD_PACK_PROTOTYPES(ThresholdPressure) ADD_PACK_PROTOTYPES(TimeMap) -ADD_PACK_PROTOTYPES(TimeMap::StepData) ADD_PACK_PROTOTYPES(TimeStampUTC) ADD_PACK_PROTOTYPES(TransMult) ADD_PACK_PROTOTYPES(Tuning) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 8f53de3e8..1823e316e 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -223,9 +223,7 @@ Opm::FoamData getFoamData() Opm::TimeMap getTimeMap() { - return Opm::TimeMap({123}, - {{1, Opm::TimeStampUTC(123)}}, - {{2, Opm::TimeStampUTC(456)}}); + return Opm::TimeMap({123}); } Opm::PvtgTable getPvtgTable() @@ -789,16 +787,6 @@ BOOST_AUTO_TEST_CASE(RestartSchedule) } -BOOST_AUTO_TEST_CASE(StepData) -{ -#if HAVE_MPI - Opm::TimeMap::StepData val1{1, Opm::TimeStampUTC(123456)}; - auto val2 = PackUnpack(val1); - BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2)); - BOOST_CHECK(val1 == std::get<0>(val2)); -#endif -} - BOOST_AUTO_TEST_CASE(TimeMap) {