From 252f323fb6686f502623f72f75b9bc6092a57778 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 14 Jan 2020 12:29:23 +0100 Subject: [PATCH 1/7] add mpi serialization for MULTREGTRecord --- opm/simulators/utils/ParallelRestart.cpp | 35 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 11 ++++++++ 3 files changed, 48 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 274ae764c..6f3728858 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1952,6 +1952,17 @@ std::size_t packSize(const GuideRateConfig::GroupTarget& data, packSize(data.target, comm); } +std::size_t packSize(const MULTREGTRecord& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.src_value, comm) + + packSize(data.target_value, comm) + + packSize(data.trans_mult, comm) + + packSize(data.directions, comm) + + packSize(data.nnc_behaviour, comm) + + packSize(data.region_name, comm); +} + ////// pack routines template @@ -3807,6 +3818,18 @@ void pack(const GuideRateConfig::GroupTarget& data, pack(data.target, buffer, position, comm); } +void pack(const MULTREGTRecord& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.src_value, buffer, position, comm); + pack(data.target_value, buffer, position, comm); + pack(data.trans_mult, buffer, position, comm); + pack(data.directions, buffer, position, comm); + pack(data.nnc_behaviour, buffer, position, comm); + pack(data.region_name, buffer, position, comm); +} + /// unpack routines template @@ -6460,6 +6483,18 @@ void unpack(GuideRateConfig::GroupTarget& data, unpack(data.target, buffer, position, comm); } +void unpack(MULTREGTRecord& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + unpack(data.src_value, buffer, position, comm); + unpack(data.target_value, buffer, position, comm); + unpack(data.trans_mult, buffer, position, comm); + unpack(data.directions, buffer, position, comm); + unpack(data.nnc_behaviour, buffer, position, comm); + unpack(data.region_name, buffer, position, comm); +} + #define INSTANTIATE_PACK_VECTOR(...) \ template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 0c05f4850..8188e9209 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -99,6 +99,7 @@ class JFunc; class Location; class MessageLimits; class MLimits; +class MULTREGTRecord; class NNC; struct NNCdata; class OilVaporizationProperties; @@ -679,6 +680,7 @@ ADD_PACK_PROTOTYPES(JFunc) ADD_PACK_PROTOTYPES(Location) ADD_PACK_PROTOTYPES(MessageLimits) ADD_PACK_PROTOTYPES(MLimits) +ADD_PACK_PROTOTYPES(MULTREGTRecord) ADD_PACK_PROTOTYPES(NNC) ADD_PACK_PROTOTYPES(NNCdata) ADD_PACK_PROTOTYPES(OilVaporizationProperties) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 79d28be64..8c66c46ad 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2415,6 +2415,17 @@ BOOST_AUTO_TEST_CASE(WellBrineProperties) } +BOOST_AUTO_TEST_CASE(MULTREGTRecord) +{ +#ifdef HAVE_MPI + Opm::MULTREGTRecord val1{1, 2, 3.0, 4, Opm::MULTREGT::ALL, "test"}; + 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 ff8fac563f853390a9f1f4d9c2b3690199598b84 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 14 Jan 2020 14:19:32 +0100 Subject: [PATCH 2/7] add mpi serialization for MULTREGTScanner --- opm/simulators/utils/ParallelRestart.cpp | 40 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 20 ++++++++++++ 3 files changed, 62 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 6f3728858..7011fb2fd 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1963,6 +1963,16 @@ std::size_t packSize(const MULTREGTRecord& data, packSize(data.region_name, comm); } +std::size_t packSize(const MULTREGTScanner& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.getSize(), comm) + + packSize(data.getRecords(), comm) + + packSize(data.getSearchMap(), comm) + + packSize(data.getRegions(), comm) + + packSize(data.getDefaultRegion(), comm); +} + ////// pack routines template @@ -3830,6 +3840,17 @@ void pack(const MULTREGTRecord& data, pack(data.region_name, buffer, position, comm); } +void pack(const MULTREGTScanner& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.getSize(), buffer, position, comm); + pack(data.getRecords(), buffer, position, comm); + pack(data.getSearchMap(), buffer, position, comm); + pack(data.getRegions(), buffer, position, comm); + pack(data.getDefaultRegion(), buffer, position, comm); +} + /// unpack routines template @@ -6495,6 +6516,25 @@ void unpack(MULTREGTRecord& data, unpack(data.region_name, buffer, position, comm); } +void unpack(MULTREGTScanner& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::array size; + std::vector records; + MULTREGTScanner::ExternalSearchMap searchMap; + std::map> regions; + std::string defaultRegion; + + unpack(size, buffer, position, comm); + unpack(records, buffer, position, comm); + unpack(searchMap, buffer, position, comm); + unpack(regions, buffer, position, comm); + unpack(defaultRegion, buffer, position, comm); + + data = MULTREGTScanner(size, records, searchMap, regions, defaultRegion); +} + #define INSTANTIATE_PACK_VECTOR(...) \ template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 8188e9209..5c816a310 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -100,6 +100,7 @@ class Location; class MessageLimits; class MLimits; class MULTREGTRecord; +class MULTREGTScanner; class NNC; struct NNCdata; class OilVaporizationProperties; @@ -681,6 +682,7 @@ ADD_PACK_PROTOTYPES(Location) ADD_PACK_PROTOTYPES(MessageLimits) ADD_PACK_PROTOTYPES(MLimits) ADD_PACK_PROTOTYPES(MULTREGTRecord) +ADD_PACK_PROTOTYPES(MULTREGTScanner) ADD_PACK_PROTOTYPES(NNC) ADD_PACK_PROTOTYPES(NNCdata) ADD_PACK_PROTOTYPES(OilVaporizationProperties) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 8c66c46ad..66a3193aa 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2426,6 +2426,26 @@ BOOST_AUTO_TEST_CASE(MULTREGTRecord) } +BOOST_AUTO_TEST_CASE(MULTREGTScanner) +{ +#ifdef HAVE_MPI + std::vector records{{1, 2, 3.0, 4, Opm::MULTREGT::ALL, "test1"}}; + std::map, int> searchRecord{{{5,6},0}}; + Opm::MULTREGTScanner::ExternalSearchMap searchMap; + searchMap.insert({"test2", searchRecord}); + Opm::MULTREGTScanner val1({1, 2, 3}, + records, + searchMap, + {{"test3", {7,8}}}, + "test4"); + + 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 b93efe29f887005074c91706daab6660f54fee00 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 14 Jan 2020 14:47:44 +0100 Subject: [PATCH 3/7] add mpi serialization for EclipseConfig --- opm/simulators/utils/ParallelRestart.cpp | 31 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 20 +++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 7011fb2fd..a5a15d682 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1973,6 +1973,14 @@ std::size_t packSize(const MULTREGTScanner& data, packSize(data.getDefaultRegion(), comm); } +std::size_t packSize(const EclipseConfig& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.init(), comm) + + packSize(data.io(), comm) + + packSize(data.restart(), comm); +} + ////// pack routines template @@ -3851,6 +3859,15 @@ void pack(const MULTREGTScanner& data, pack(data.getDefaultRegion(), buffer, position, comm); } +void pack(const EclipseConfig& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.init(), buffer, position, comm); + pack(data.io(), buffer, position, comm); + pack(data.restart(), buffer, position, comm); +} + /// unpack routines template @@ -6535,6 +6552,20 @@ void unpack(MULTREGTScanner& data, data = MULTREGTScanner(size, records, searchMap, regions, defaultRegion); } +void unpack(EclipseConfig& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + InitConfig init; + IOConfig io; + RestartConfig restart; + + unpack(init, buffer, position, comm); + unpack(io, buffer, position, comm); + unpack(restart, buffer, position, comm); + data = EclipseConfig(io, init, restart); +} + #define INSTANTIATE_PACK_VECTOR(...) \ template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 5c816a310..4f1584464 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -84,6 +84,7 @@ class DENSITYRecord; class DensityTable; class Dimension; class EclHysterConfig; +class EclipseConfig; class Eqldims; class EDITNNC; class EndpointScaling; @@ -656,6 +657,7 @@ ADD_PACK_PROTOTYPES(DENSITYRecord) ADD_PACK_PROTOTYPES(DensityTable) ADD_PACK_PROTOTYPES(Dimension) ADD_PACK_PROTOTYPES(EclHysterConfig) +ADD_PACK_PROTOTYPES(EclipseConfig) ADD_PACK_PROTOTYPES(EDITNNC) ADD_PACK_PROTOTYPES(EndpointScaling) ADD_PACK_PROTOTYPES(Equil) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 66a3193aa..feefe75f1 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2446,6 +2446,26 @@ BOOST_AUTO_TEST_CASE(MULTREGTScanner) } +BOOST_AUTO_TEST_CASE(EclipseConfig) +{ +#ifdef HAVE_MPI + Opm::IOConfig io(true, false, true, false, false, true, 1, "test1", true, + "test2", true, "test3", false); + Opm::InitConfig init(Opm::Equil({getEquilRecord(), getEquilRecord()}), + Opm::FoamConfig({getFoamData(), getFoamData()}), + true, true, 20, "test1"); + Opm::DynamicState rsched({Opm::RestartSchedule(1, 2, 3)}, 2); + Opm::DynamicState> rkw({{{"test",3}}}, 3); + Opm::RestartConfig restart(getTimeMap(), 1, true, rsched, rkw, {false, true}); + Opm::EclipseConfig val1{io, init, restart}; + + 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 a9bc24618fc75906594ff7a134930808e126d2f7 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 14 Jan 2020 14:48:11 +0100 Subject: [PATCH 4/7] add mpi serialization for TransMult --- opm/simulators/utils/ParallelRestart.cpp | 35 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 24 ++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index a5a15d682..b90bfe998 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1981,6 +1981,15 @@ std::size_t packSize(const EclipseConfig& data, packSize(data.restart(), comm); } +std::size_t packSize(const TransMult& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.getSize(), comm) + + packSize(data.getTrans(), comm) + + packSize(data.getNames(), comm) + + packSize(data.getScanner(), comm); +} + ////// pack routines template @@ -3868,6 +3877,16 @@ void pack(const EclipseConfig& data, pack(data.restart(), buffer, position, comm); } +void pack(const TransMult& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.getSize(), buffer, position, comm); + pack(data.getTrans(), buffer, position, comm); + pack(data.getNames(), buffer, position, comm); + pack(data.getScanner(), buffer, position, comm); +} + /// unpack routines template @@ -6566,6 +6585,22 @@ void unpack(EclipseConfig& data, data = EclipseConfig(io, init, restart); } +void unpack(TransMult& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::array size; + std::map> trans; + std::map names; + MULTREGTScanner scanner; + + unpack(size, buffer, position, comm); + unpack(trans, buffer, position, comm); + unpack(names, buffer, position, comm); + unpack(scanner, buffer, position, comm); + data = TransMult(size, trans, names, scanner); +} + #define INSTANTIATE_PACK_VECTOR(...) \ template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 4f1584464..ca5e37c7b 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -140,6 +140,7 @@ class TableManager; class TableSchema; class ThresholdPressure; class TimeStampUTC; +class TransMult; class Tuning; class UDAValue; class UDQASTNode; @@ -728,6 +729,7 @@ 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) ADD_PACK_PROTOTYPES(UDAValue) ADD_PACK_PROTOTYPES(UDQActive) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index feefe75f1..960fcb854 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2466,6 +2466,30 @@ BOOST_AUTO_TEST_CASE(EclipseConfig) } +BOOST_AUTO_TEST_CASE(TransMult) +{ +#ifdef HAVE_MPI + std::vector records{{1, 2, 3.0, 4, Opm::MULTREGT::ALL, "test1"}}; + std::map, int> searchRecord{{{5,6},0}}; + Opm::MULTREGTScanner::ExternalSearchMap searchMap; + searchMap.insert({"test2", searchRecord}); + Opm::MULTREGTScanner scanner({1, 2, 3}, + records, + searchMap, + {{"test3", {7,8}}}, + "test4"); + + Opm::TransMult val1({1, 2, 3}, + {{Opm::FaceDir::YPlus, {4.0, 5.0}}}, + {{Opm::FaceDir::ZPlus, "test1"}}, + scanner); + 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 1c311743eb20c575da4a3f430a996cc3fbbb180d Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 14 Jan 2020 15:00:42 +0100 Subject: [PATCH 5/7] add mpi serialization for FaultFace --- opm/simulators/utils/ParallelRestart.cpp | 27 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 11 ++++++++++ 3 files changed, 40 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index b90bfe998..4a6d95fbc 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1990,6 +1990,13 @@ std::size_t packSize(const TransMult& data, packSize(data.getScanner(), comm); } +std::size_t packSize(const FaultFace& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.getIndices(), comm) + + packSize(data.getDir(), comm); +} + ////// pack routines template @@ -3887,6 +3894,14 @@ void pack(const TransMult& data, pack(data.getScanner(), buffer, position, comm); } +void pack(const FaultFace& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.getIndices(), buffer, position, comm); + pack(data.getDir(), buffer, position, comm); +} + /// unpack routines template @@ -6601,6 +6616,18 @@ void unpack(TransMult& data, data = TransMult(size, trans, names, scanner); } +void unpack(FaultFace& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector indices; + FaceDir::DirEnum dir; + + unpack(indices, buffer, position, comm); + unpack(dir, buffer, position, comm); + data = FaultFace(indices, dir); +} + #define INSTANTIATE_PACK_VECTOR(...) \ template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index ca5e37c7b..108a82963 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -91,6 +91,7 @@ class EndpointScaling; class Equil; class EquilRecord; class Events; +class FaultFace; class FoamConfig; class FoamData; class InitConfig; @@ -665,6 +666,7 @@ ADD_PACK_PROTOTYPES(Equil) ADD_PACK_PROTOTYPES(Eqldims) ADD_PACK_PROTOTYPES(EquilRecord) ADD_PACK_PROTOTYPES(Events) +ADD_PACK_PROTOTYPES(FaultFace) ADD_PACK_PROTOTYPES(FoamConfig) ADD_PACK_PROTOTYPES(FoamData) ADD_PACK_PROTOTYPES(GConSale) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 960fcb854..2e30a0edd 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2490,6 +2490,17 @@ BOOST_AUTO_TEST_CASE(TransMult) } +BOOST_AUTO_TEST_CASE(FaultFace) +{ +#ifdef HAVE_MPI + Opm::FaultFace val1({1,2,3,4,5,6}, Opm::FaceDir::YPlus); + 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 d00ee945618cddda3a75a9acec00fd161194e966 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 14 Jan 2020 15:00:42 +0100 Subject: [PATCH 6/7] add mpi serialization for Fault --- opm/simulators/utils/ParallelRestart.cpp | 31 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 11 +++++++++ 3 files changed, 44 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 4a6d95fbc..221587f3d 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1997,6 +1997,14 @@ std::size_t packSize(const FaultFace& data, packSize(data.getDir(), comm); } +std::size_t packSize(const Fault& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.getName(), comm) + + packSize(data.getTransMult(), comm) + + packSize(data.getFaceList(), comm); +} + ////// pack routines template @@ -3902,6 +3910,15 @@ void pack(const FaultFace& data, pack(data.getDir(), buffer, position, comm); } +void pack(const Fault& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.getName(), buffer, position, comm); + pack(data.getTransMult(), buffer, position, comm); + pack(data.getFaceList(), buffer, position, comm); +} + /// unpack routines template @@ -6628,6 +6645,20 @@ void unpack(FaultFace& data, data = FaultFace(indices, dir); } +void unpack(Fault& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::string name; + double transMult; + std::vector faceList; + + unpack(name, buffer, position, comm); + unpack(transMult, buffer, position, comm); + unpack(faceList, buffer, position, comm); + data = Fault(name, transMult, faceList); +} + #define INSTANTIATE_PACK_VECTOR(...) \ template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 108a82963..d5c4a6f67 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -91,6 +91,7 @@ class EndpointScaling; class Equil; class EquilRecord; class Events; +class Fault; class FaultFace; class FoamConfig; class FoamData; @@ -666,6 +667,7 @@ ADD_PACK_PROTOTYPES(Equil) ADD_PACK_PROTOTYPES(Eqldims) ADD_PACK_PROTOTYPES(EquilRecord) ADD_PACK_PROTOTYPES(Events) +ADD_PACK_PROTOTYPES(Fault) ADD_PACK_PROTOTYPES(FaultFace) ADD_PACK_PROTOTYPES(FoamConfig) ADD_PACK_PROTOTYPES(FoamData) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 2e30a0edd..cb0f7273a 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2501,6 +2501,17 @@ BOOST_AUTO_TEST_CASE(FaultFace) } +BOOST_AUTO_TEST_CASE(Fault) +{ +#ifdef HAVE_MPI + Opm::Fault val1("test", 1.0, {{{1,2,3,4,5,6}, Opm::FaceDir::YPlus}}); + 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 468c220bca385f23cb990824db4e82b7674f04b1 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 14 Jan 2020 15:00:42 +0100 Subject: [PATCH 7/7] add mpi serialization for FaultCollection --- opm/simulators/utils/ParallelRestart.cpp | 23 +++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 14 ++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 221587f3d..a3598e370 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -2005,6 +2005,12 @@ std::size_t packSize(const Fault& data, packSize(data.getFaceList(), comm); } +std::size_t packSize(const FaultCollection& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.getFaults(), comm); +} + ////// pack routines template @@ -3919,6 +3925,13 @@ void pack(const Fault& data, pack(data.getFaceList(), buffer, position, comm); } +void pack(const FaultCollection& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.getFaults(), buffer, position, comm); +} + /// unpack routines template @@ -6659,6 +6672,16 @@ void unpack(Fault& data, data = Fault(name, transMult, faceList); } +void unpack(FaultCollection& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + OrderedMap faults; + + unpack(faults, buffer, position, comm); + data = FaultCollection(faults); +} + #define INSTANTIATE_PACK_VECTOR(...) \ template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index d5c4a6f67..7d6865a4e 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -92,6 +92,7 @@ class Equil; class EquilRecord; class Events; class Fault; +class FaultCollection; class FaultFace; class FoamConfig; class FoamData; @@ -668,6 +669,7 @@ ADD_PACK_PROTOTYPES(Eqldims) ADD_PACK_PROTOTYPES(EquilRecord) ADD_PACK_PROTOTYPES(Events) ADD_PACK_PROTOTYPES(Fault) +ADD_PACK_PROTOTYPES(FaultCollection) ADD_PACK_PROTOTYPES(FaultFace) ADD_PACK_PROTOTYPES(FoamConfig) ADD_PACK_PROTOTYPES(FoamData) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index cb0f7273a..04e58f085 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2512,6 +2512,20 @@ BOOST_AUTO_TEST_CASE(Fault) } +BOOST_AUTO_TEST_CASE(FaultCollection) +{ +#ifdef HAVE_MPI + Opm::Fault fault("test", 1.0, {{{1,2,3,4,5,6}, Opm::FaceDir::YPlus}}); + Opm::OrderedMap faults; + faults.insert({"test2", fault}); + Opm::FaultCollection val1(faults); + 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;