From 7aa73eadd28c93258319ce15c69e30f1006b28e7 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 29 Nov 2019 15:47:45 +0100 Subject: [PATCH 1/7] add mpi serialization for RestartSchedule --- opm/simulators/utils/ParallelRestart.cpp | 2 ++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 435f66758..e5a80d193 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -196,6 +197,7 @@ HANDLE_AS_POD(data::Rates) HANDLE_AS_POD(data::Segment) HANDLE_AS_POD(EquilRecord) HANDLE_AS_POD(FoamData) +HANDLE_AS_POD(RestartSchedule) std::size_t packSize(const data::Well& data, Dune::MPIHelper::MPICommunicator comm) { diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 3516910a4..0a584b412 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -46,6 +46,7 @@ class FoamData; class InitConfig; class NNC; struct NNCdata; +class RestartSchedule; class Rock2dTable; class Rock2dtrTable; class SimulationConfig; @@ -235,6 +236,7 @@ ADD_PACK_PROTOTYPES(InitConfig) ADD_PACK_PROTOTYPES(NNC) ADD_PACK_PROTOTYPES(NNCdata) ADD_PACK_PROTOTYPES(RestartKey) +ADD_PACK_PROTOTYPES(RestartSchedule) ADD_PACK_PROTOTYPES(RestartValue) ADD_PACK_PROTOTYPES(Rock2dTable) ADD_PACK_PROTOTYPES(Rock2dtrTable) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index c76682e17..2a362ddbc 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -478,6 +479,17 @@ BOOST_AUTO_TEST_CASE(SimulationConfig) } +BOOST_AUTO_TEST_CASE(RestartSchedule) +{ +#if HAVE_MPI + Opm::RestartSchedule val1(1, 2, 3); + auto val2 = PackUnpack(val1); + BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2)); + BOOST_CHECK(val1 == std::get<0>(val2)); +#endif +} + + bool init_unit_test_func() { return true; From 3e93b3e04304517acec6034d51ad59f59196716b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 29 Nov 2019 15:47:55 +0100 Subject: [PATCH 2/7] add mpi serialization for TimeMap --- opm/simulators/utils/ParallelRestart.cpp | 30 +++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 3 +++ tests/test_ParallelRestart.cpp | 31 ++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index e5a80d193..e6151205c 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -198,6 +199,7 @@ HANDLE_AS_POD(data::Segment) HANDLE_AS_POD(EquilRecord) HANDLE_AS_POD(FoamData) HANDLE_AS_POD(RestartSchedule) +HANDLE_AS_POD(TimeMap::StepData) std::size_t packSize(const data::Well& data, Dune::MPIHelper::MPICommunicator comm) { @@ -343,6 +345,13 @@ std::size_t packSize(const SimulationConfig& data, Dune::MPIHelper::MPICommunica packSize(data.isThermal(), comm); } +std::size_t packSize(const TimeMap& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.timeList(), comm) + + packSize(data.firstTimeStepMonths(), comm) + + packSize(data.firstTimeStepYears(), comm); +} + ////// pack routines template @@ -673,6 +682,14 @@ void pack(const SimulationConfig& data, std::vector& buffer, int& position pack(data.isThermal(), buffer, position, comm); } +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); +} + /// unpack routines template @@ -1063,6 +1080,19 @@ void unpack(SimulationConfig& data, std::vector& buffer, int& position, data = SimulationConfig(thresholdPressure, useCPR, DISGAS, VAPOIL, isThermal); } +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); +} + } // end namespace Mpi RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState, const std::vector& solutionKeys, diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 0a584b412..a95500eaf 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -247,6 +248,8 @@ ADD_PACK_PROTOTYPES(TableColumn) ADD_PACK_PROTOTYPES(TableContainer) ADD_PACK_PROTOTYPES(TableSchema) ADD_PACK_PROTOTYPES(ThresholdPressure) +ADD_PACK_PROTOTYPES(TimeMap) +ADD_PACK_PROTOTYPES(TimeMap::StepData) } // end namespace Mpi RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState, diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 2a362ddbc..7fe389a0a 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -167,6 +168,14 @@ Opm::FoamData getFoamData() #endif +Opm::TimeMap getTimeMap() +{ + return Opm::TimeMap({123}, + {{1, Opm::TimeStampUTC(123)}}, + {{2, Opm::TimeStampUTC(456)}}); +} + + } @@ -490,6 +499,28 @@ 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) +{ +#if HAVE_MPI + Opm::TimeMap val1 = getTimeMap(); + auto val2 = PackUnpack(val1); + BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2)); + BOOST_CHECK(val1 == std::get<0>(val2)); +#endif +} + + bool init_unit_test_func() { return true; From a869641ee4ea2e041d1175f663163793a6a2c6e9 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 29 Nov 2019 15:58:59 +0100 Subject: [PATCH 3/7] add mpi serialization of DynamicState --- opm/simulators/utils/ParallelRestart.cpp | 24 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 12 ++++++++++++ 2 files changed, 36 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index e6151205c..6c12c25e1 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -150,6 +150,11 @@ std::size_t packSize(const OrderedMap& data, Dune::MPIHelper::MPIComm return packSize(data.getIndex(), comm) + packSize(data.getStorage(), comm); } +template +std::size_t packSize(const DynamicState& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.data(), comm) + packSize(data.initialRange(), comm); +} std::size_t packSize(const char* str, Dune::MPIHelper::MPICommunicator comm) { @@ -460,6 +465,14 @@ void pack(const OrderedMap& data, std::vector& buffer, int& po pack(data.getStorage(), buffer, position, comm); } +template +void pack(const DynamicState& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.data(), buffer, position, comm); + pack(data.initialRange(), buffer, position, comm); +} + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { @@ -804,6 +817,17 @@ void unpack(OrderedMap& data, std::vector& buffer, int& positio data = OrderedMap(index, storage); } +template +void unpack(DynamicState& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector ddata; + size_t initial_range; + unpack(ddata, buffer, position, comm); + unpack(initial_range, buffer, position, comm); + data = DynamicState(ddata, initial_range); +} + void unpack(char* str, std::size_t length, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index a95500eaf..8c2478bd1 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -103,6 +104,9 @@ std::size_t packSize(const std::unordered_map& data, Dune::MPIHelpe template std::size_t packSize(const OrderedMap& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const DynamicState& data, Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -154,6 +158,10 @@ template void pack(const OrderedMap& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const DynamicState& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -208,6 +216,10 @@ template void unpack(OrderedMap& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(DynamicState& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + void unpack(char* str, std::size_t length, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); From 34707603077207a10a5c24cca7e99912bd77a1e8 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 2 Dec 2019 09:38:52 +0100 Subject: [PATCH 4/7] add mpi serialization for RestartConfig --- opm/simulators/utils/ParallelRestart.cpp | 40 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 13 ++++++++ 3 files changed, 55 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 6c12c25e1..8679c8cb7 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -357,6 +357,16 @@ std::size_t packSize(const TimeMap& data, Dune::MPIHelper::MPICommunicator comm) packSize(data.firstTimeStepYears(), comm); } +std::size_t packSize(const RestartConfig& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.timeMap(), comm) + + packSize(data.getFirstRestartStep(), comm) + + packSize(data.writeInitialRst(), comm) + + packSize(data.restartSchedule(), comm) + + packSize(data.restartKeywords(), comm) + + packSize(data.saveKeywords(), comm); +} + ////// pack routines template @@ -703,6 +713,17 @@ void pack(const TimeMap& data, std::vector& buffer, int& position, pack(data.firstTimeStepYears(), buffer, position, comm); } +void pack(const RestartConfig& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.timeMap(), buffer, position, comm); + pack(data.getFirstRestartStep(), buffer, position, comm); + pack(data.writeInitialRst(), buffer, position, comm); + pack(data.restartSchedule(), buffer, position, comm); + pack(data.restartKeywords(), buffer, position, comm); + pack(data.saveKeywords(), buffer, position, comm); +} + /// unpack routines template @@ -1117,6 +1138,25 @@ void unpack(TimeMap& data, std::vector& buffer, int& position, data = TimeMap(timeList, firstStepMonths, firstStepYears); } +void unpack(RestartConfig& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + TimeMap timemap; + int firstRstStep; + bool writeInitialRst; + DynamicState restart_sched; + DynamicState> restart_keyw; + std::vector save_keyw; + unpack(timemap, buffer, position, comm); + unpack(firstRstStep, buffer, position, comm); + unpack(writeInitialRst, buffer, position, comm); + unpack(restart_sched, buffer, position, comm); + unpack(restart_keyw, buffer, position, comm); + unpack(save_keyw, buffer, position, comm); + data = RestartConfig(timemap, firstRstStep, writeInitialRst, restart_sched, + restart_keyw, save_keyw); +} + } // end namespace Mpi RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState, const std::vector& solutionKeys, diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 8c2478bd1..d7a5abe52 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -48,6 +48,7 @@ class FoamData; class InitConfig; class NNC; struct NNCdata; +class RestartConfig; class RestartSchedule; class Rock2dTable; class Rock2dtrTable; @@ -248,6 +249,7 @@ ADD_PACK_PROTOTYPES(FoamData) ADD_PACK_PROTOTYPES(InitConfig) ADD_PACK_PROTOTYPES(NNC) ADD_PACK_PROTOTYPES(NNCdata) +ADD_PACK_PROTOTYPES(RestartConfig) ADD_PACK_PROTOTYPES(RestartKey) ADD_PACK_PROTOTYPES(RestartSchedule) ADD_PACK_PROTOTYPES(RestartValue) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 7fe389a0a..fe7d5524b 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -521,6 +521,19 @@ BOOST_AUTO_TEST_CASE(TimeMap) } +BOOST_AUTO_TEST_CASE(RestartConfig) +{ +#if HAVE_MPI + Opm::DynamicState rsched({Opm::RestartSchedule(1, 2, 3)}, 2); + Opm::DynamicState> rkw({{{"test",3}}}, 3); + Opm::RestartConfig val1(getTimeMap(), 1, true, rsched, rkw, {false, true}); + auto val2 = PackUnpack(val1); + BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2)); + BOOST_CHECK(val1 == std::get<0>(val2)); +#endif +} + + bool init_unit_test_func() { return true; From 2a2effd54bc987e7a841c2750b06c2b0adce2eee Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 2 Dec 2019 10:20:28 +0100 Subject: [PATCH 5/7] add mpi serialization for IOConfig --- opm/simulators/utils/ParallelRestart.cpp | 62 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 + tests/test_ParallelRestart.cpp | 13 +++++ 3 files changed, 77 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 8679c8cb7..18de66ba8 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -367,6 +368,23 @@ std::size_t packSize(const RestartConfig& data, Dune::MPIHelper::MPICommunicator packSize(data.saveKeywords(), comm); } +std::size_t packSize(const IOConfig& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.getWriteINITFile(), comm) + + packSize(data.getWriteEGRIDFile(), comm) + + packSize(data.getUNIFIN(), comm) + + packSize(data.getUNIFOUT(), comm) + + packSize(data.getFMTIN(), comm) + + packSize(data.getFMTOUT(), comm) + + packSize(data.getFirstRestartStep(), comm) + + packSize(data.getDeckFileName(), comm) + + packSize(data.getOutputEnabled(), comm) + + packSize(data.getOutputDir(), comm) + + packSize(data.getNoSim(), comm) + + packSize(data.getBaseName(), comm) + + packSize(data.getEclCompatibleRST(), comm); +} + ////// pack routines template @@ -724,6 +742,24 @@ void pack(const RestartConfig& data, std::vector& buffer, int& position, pack(data.saveKeywords(), buffer, position, comm); } +void pack(const IOConfig& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.getWriteINITFile(), buffer, position, comm); + pack(data.getWriteEGRIDFile(), buffer, position, comm); + pack(data.getUNIFIN(), buffer, position, comm); + pack(data.getUNIFOUT(), buffer, position, comm); + pack(data.getFMTIN(), buffer, position, comm); + pack(data.getFMTOUT(), buffer, position, comm); + pack(data.getFirstRestartStep(), buffer, position, comm); + pack(data.getDeckFileName(), buffer, position, comm); + pack(data.getOutputEnabled(), buffer, position, comm); + pack(data.getOutputDir(), buffer, position, comm); + pack(data.getNoSim(), buffer, position, comm); + pack(data.getBaseName(), buffer, position, comm); + pack(data.getEclCompatibleRST(), buffer, position, comm); +} + /// unpack routines template @@ -1157,6 +1193,32 @@ void unpack(RestartConfig& data, std::vector& buffer, int& position, restart_keyw, save_keyw); } +void unpack(IOConfig& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + bool write_init, write_egrid, unifin, unifout, fmtin, fmtout; + int firstRestartStep; + std::string deck_name, output_dir, base_name; + bool output_enabled, no_sim, ecl_compatible_rst; + + unpack(write_init, buffer, position, comm); + unpack(write_egrid, buffer, position, comm); + unpack(unifin, buffer, position, comm); + unpack(unifout, buffer, position, comm); + unpack(fmtin, buffer, position, comm); + unpack(fmtout, buffer, position, comm); + unpack(firstRestartStep, buffer, position, comm); + unpack(deck_name, buffer, position, comm); + unpack(output_enabled, buffer, position, comm); + unpack(output_dir, buffer, position, comm); + unpack(no_sim, buffer, position, comm); + unpack(base_name, buffer, position, comm); + unpack(ecl_compatible_rst, buffer, position, comm); + data = IOConfig(write_init, write_egrid, unifin, unifout, fmtin, fmtout, + firstRestartStep, deck_name, output_enabled, output_dir, + no_sim, base_name, ecl_compatible_rst); +} + } // end namespace Mpi RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState, const std::vector& solutionKeys, diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index d7a5abe52..a25303c4e 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -46,6 +46,7 @@ class EquilRecord; class FoamConfig; class FoamData; class InitConfig; +class IOConfig; class NNC; struct NNCdata; class RestartConfig; @@ -247,6 +248,7 @@ ADD_PACK_PROTOTYPES(EquilRecord) ADD_PACK_PROTOTYPES(FoamConfig) ADD_PACK_PROTOTYPES(FoamData) ADD_PACK_PROTOTYPES(InitConfig) +ADD_PACK_PROTOTYPES(IOConfig) ADD_PACK_PROTOTYPES(NNC) ADD_PACK_PROTOTYPES(NNCdata) ADD_PACK_PROTOTYPES(RestartConfig) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index fe7d5524b..cbc5055ad 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -534,6 +535,18 @@ BOOST_AUTO_TEST_CASE(RestartConfig) } +BOOST_AUTO_TEST_CASE(IOConfig) +{ +#if HAVE_MPI + Opm::IOConfig val1(true, false, true, false, false, true, 1, "test1", true, + "test2", true, "test3", false); + auto val2 = PackUnpack(val1); + BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2)); + BOOST_CHECK(val1 == std::get<0>(val2)); +#endif +} + + bool init_unit_test_func() { return true; From cdfac8c02b6b66d2e1b5a1db68de948fa6569dcf Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 2 Dec 2019 10:46:58 +0100 Subject: [PATCH 6/7] add mpi serialization for Phases --- opm/simulators/utils/ParallelRestart.cpp | 20 ++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 12 ++++++++++++ 3 files changed, 34 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 18de66ba8..ad25a81f5 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -22,6 +22,7 @@ #endif #include "ParallelRestart.hpp" +#include #include #include #include @@ -385,6 +386,11 @@ std::size_t packSize(const IOConfig& data, Dune::MPIHelper::MPICommunicator comm packSize(data.getEclCompatibleRST(), comm); } +std::size_t packSize(const Phases& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.getBits(), comm); +} + ////// pack routines template @@ -760,6 +766,12 @@ void pack(const IOConfig& data, std::vector& buffer, int& position, pack(data.getEclCompatibleRST(), buffer, position, comm); } +void pack(const Phases& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.getBits(), buffer, position, comm); +} + /// unpack routines template @@ -1219,6 +1231,14 @@ void unpack(IOConfig& data, std::vector& buffer, int& position, no_sim, base_name, ecl_compatible_rst); } +void unpack(Phases& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + unsigned long bits; + unpack(bits, buffer, position, comm); + data = Phases(std::bitset(bits)); +} + } // end namespace Mpi RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState, const std::vector& solutionKeys, diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index a25303c4e..8add981ce 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -49,6 +49,7 @@ class InitConfig; class IOConfig; class NNC; struct NNCdata; +class Phases; class RestartConfig; class RestartSchedule; class Rock2dTable; @@ -251,6 +252,7 @@ ADD_PACK_PROTOTYPES(InitConfig) ADD_PACK_PROTOTYPES(IOConfig) ADD_PACK_PROTOTYPES(NNC) ADD_PACK_PROTOTYPES(NNCdata) +ADD_PACK_PROTOTYPES(Phases) ADD_PACK_PROTOTYPES(RestartConfig) ADD_PACK_PROTOTYPES(RestartKey) ADD_PACK_PROTOTYPES(RestartSchedule) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index cbc5055ad..0cc716832 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -547,6 +548,17 @@ BOOST_AUTO_TEST_CASE(IOConfig) } +BOOST_AUTO_TEST_CASE(Phases) +{ +#if HAVE_MPI + Opm::Phases val1(true, true, true, false, true, false, true, false); + auto val2 = PackUnpack(val1); + BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2)); + BOOST_CHECK(val1 == std::get<0>(val2)); +#endif +} + + bool init_unit_test_func() { return true; From 7c1b5bc25fc4fe6ff7a5d02c4633dcdc3e37f5f6 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 2 Dec 2019 11:10:34 +0100 Subject: [PATCH 7/7] add mpi serialization for Tabdims --- opm/simulators/utils/ParallelRestart.cpp | 1 + opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index ad25a81f5..c7c352bf7 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -206,6 +206,7 @@ HANDLE_AS_POD(data::Segment) HANDLE_AS_POD(EquilRecord) HANDLE_AS_POD(FoamData) HANDLE_AS_POD(RestartSchedule) +HANDLE_AS_POD(Tabdims) HANDLE_AS_POD(TimeMap::StepData) std::size_t packSize(const data::Well& data, Dune::MPIHelper::MPICommunicator comm) diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 8add981ce..997cd3ad3 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -56,6 +56,7 @@ class Rock2dTable; class Rock2dtrTable; class SimulationConfig; class SimpleTable; +class Tabdims; class TableColumn; class TableContainer; class TableSchema; @@ -262,6 +263,7 @@ ADD_PACK_PROTOTYPES(Rock2dtrTable) ADD_PACK_PROTOTYPES(std::string) ADD_PACK_PROTOTYPES(SimulationConfig) ADD_PACK_PROTOTYPES(SimpleTable) +ADD_PACK_PROTOTYPES(Tabdims) ADD_PACK_PROTOTYPES(TableColumn) ADD_PACK_PROTOTYPES(TableContainer) ADD_PACK_PROTOTYPES(TableSchema) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 0cc716832..7d599d841 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -559,6 +560,17 @@ BOOST_AUTO_TEST_CASE(Phases) } +BOOST_AUTO_TEST_CASE(Tabdims) +{ +#if HAVE_MPI + Opm::Tabdims val1(1,2,3,4,5,6); + auto val2 = PackUnpack(val1); + BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2)); + BOOST_CHECK(val1 == std::get<0>(val2)); +#endif +} + + bool init_unit_test_func() { return true;