From b2d454eaf2c6306b17136b3d087e88300099031c Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 11 Dec 2019 14:17:10 +0100 Subject: [PATCH] add mpi serialization for WListManager --- opm/simulators/utils/ParallelRestart.cpp | 23 +++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 3 +++ tests/test_ParallelRestart.cpp | 14 ++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 2b67e366e..6c5ec9d99 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -1270,6 +1271,12 @@ std::size_t packSize(const WList& data, return packSize(data.wellList(), comm); } +std::size_t packSize(const WListManager& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.lists(), comm); +} + ////// pack routines template @@ -2556,6 +2563,13 @@ void pack(const WList& data, pack(data.wellList(), buffer, position, comm); } +void pack(const WListManager& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.lists(), buffer, position, comm); +} + /// unpack routines template @@ -4371,6 +4385,15 @@ void unpack(WList& data, data = WList(ddata); } +void unpack(WListManager& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::map lists; + unpack(lists, buffer, position, comm); + data = WListManager(lists); +} + #define INSTANTIATE_PACK_VECTOR(T) \ template std::size_t packSize(const std::vector& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 608e28033..6fcb8767d 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -130,6 +130,7 @@ class WellSegmentDims; class WellSegments; class WellTracerProperties; class WList; +class WListManager; namespace Mpi { @@ -650,8 +651,10 @@ ADD_PACK_PROTOTYPES(WellTestConfig) ADD_PACK_PROTOTYPES(WellTestConfig::WTESTWell) ADD_PACK_PROTOTYPES(WellTracerProperties) ADD_PACK_PROTOTYPES(WList) +ADD_PACK_PROTOTYPES(WListManager) } // end namespace Mpi + RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState, const std::vector& solutionKeys, const std::vector& extraKeys, diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index edccd4c92..091987510 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -1650,6 +1651,19 @@ BOOST_AUTO_TEST_CASE(WList) } +BOOST_AUTO_TEST_CASE(WListManager) +{ +#ifdef HAVE_MPI + Opm::WList wl({"test1", "test2", "test3"}); + std::map data{{"test", wl}, {"test2", wl}}; + Opm::WListManager val1(data); + 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;