From f9fc843ce2e9d3a938ba6a74a7f4db6f3b65989b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 3 Dec 2019 11:49:27 +0100 Subject: [PATCH] add mpi serialization for RockTable --- opm/simulators/utils/ParallelRestart.cpp | 19 +++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 11 +++++++++++ 3 files changed, 32 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 756c47e25..f335997a7 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -512,6 +512,11 @@ std::size_t packSize(const SkprwatTable& data, Dune::MPIHelper::MPICommunicator return packSize(static_cast(data), comm); } +std::size_t packSize(const RockTable& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(static_cast&>(data), comm); +} + ////// pack routines template @@ -1003,6 +1008,12 @@ void pack(const SkprwatTable& data, std::vector& buffer, int& position, pack(static_cast(data), buffer, position, comm); } +void pack(const RockTable& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(static_cast&>(data), buffer, position, comm); +} + /// unpack routines template @@ -1621,6 +1632,14 @@ void unpack(SkprwatTable& data, std::vector& buffer, int& position, unpack(static_cast(data), buffer, position, comm); } +void unpack(RockTable& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector pdata; + unpack(pdata, buffer, position, comm); + data = RockTable(pdata); +} + } // 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 0f26a06b8..d37a1e935 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -70,6 +70,7 @@ class Regdims; class RestartConfig; class RestartSchedule; class ROCKRecord; +class RockTable; class Rock2dTable; class Rock2dtrTable; class Runspec; @@ -304,6 +305,7 @@ ADD_PACK_PROTOTYPES(RestartKey) ADD_PACK_PROTOTYPES(RestartSchedule) ADD_PACK_PROTOTYPES(RestartValue) ADD_PACK_PROTOTYPES(ROCKRecord) +ADD_PACK_PROTOTYPES(RockTable) ADD_PACK_PROTOTYPES(Rock2dTable) ADD_PACK_PROTOTYPES(Rock2dtrTable) ADD_PACK_PROTOTYPES(Runspec) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 22e41a54f..c35061cef 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -910,6 +910,17 @@ BOOST_AUTO_TEST_CASE(ROCKRecord) } +BOOST_AUTO_TEST_CASE(RockTable) +{ +#if HAVE_MPI + Opm::RockTable val1({Opm::ROCKRecord{1.0,2.0}}); + 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;