From 64c7ead11c6d653b8778aa2d953e7595b5953a3d Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 2 Dec 2019 11:10:47 +0100 Subject: [PATCH] add mpi serialization for EndpointScaling --- 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 c7c352bf7..fdfc26dca 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -392,6 +392,11 @@ std::size_t packSize(const Phases& data, Dune::MPIHelper::MPICommunicator comm) return packSize(data.getBits(), comm); } +std::size_t packSize(const EndpointScaling& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.getBits(), comm); +} + ////// pack routines template @@ -773,6 +778,12 @@ void pack(const Phases& data, std::vector& buffer, int& position, pack(data.getBits(), buffer, position, comm); } +void pack(const EndpointScaling& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.getBits(), buffer, position, comm); +} + /// unpack routines template @@ -1240,6 +1251,14 @@ void unpack(Phases& data, std::vector& buffer, int& position, data = Phases(std::bitset(bits)); } +void unpack(EndpointScaling& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + unsigned long bits; + unpack(bits, buffer, position, comm); + data = EndpointScaling(std::bitset<4>(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 997cd3ad3..7ca5604ce 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -41,6 +41,7 @@ namespace Opm class ColumnSchema; class EDITNNC; +class EndpointScaling; class Equil; class EquilRecord; class FoamConfig; @@ -245,6 +246,7 @@ ADD_PACK_PROTOTYPES(data::Solution) ADD_PACK_PROTOTYPES(data::Well) ADD_PACK_PROTOTYPES(data::WellRates) ADD_PACK_PROTOTYPES(EDITNNC) +ADD_PACK_PROTOTYPES(EndpointScaling) ADD_PACK_PROTOTYPES(Equil) ADD_PACK_PROTOTYPES(EquilRecord) ADD_PACK_PROTOTYPES(FoamConfig) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 7d599d841..72d10a727 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -571,6 +571,17 @@ BOOST_AUTO_TEST_CASE(Tabdims) } +BOOST_AUTO_TEST_CASE(EndpointScaling) +{ +#if HAVE_MPI + Opm::EndpointScaling val1(std::bitset<4>(13)); + 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;