diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index b212d5c52..7843f4d93 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -570,6 +570,23 @@ std::size_t packSize(const SolventPvt& data, template std::size_t packSize(const SolventPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const IntervalTabulated2DFunction& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.xPos(), comm) + + packSize(data.yPos(), comm) + + packSize(data.samples(), comm) + + packSize(data.xExtrapolate(), comm) + + packSize(data.yExtrapolate(), comm); +} + +template std::size_t packSize(const IntervalTabulated2DFunction& data, + Dune::MPIHelper::MPICommunicator comm); + +template std::size_t packSize(const std::map>& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -1108,6 +1125,21 @@ void pack(const Tabulated1DFunction& data, std::vector& buffer, template void pack(const Tabulated1DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const IntervalTabulated2DFunction& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.xPos(), buffer, position, comm); + pack(data.yPos(), buffer, position, comm); + pack(data.samples(), buffer, position, comm); + pack(data.xExtrapolate(), buffer, position, comm); + pack(data.yExtrapolate(), buffer, position, comm); +} + +template void pack(const IntervalTabulated2DFunction& data, + std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + template void pack(const SolventPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -1822,6 +1854,26 @@ void unpack(Tabulated1DFunction& data, std::vector& buffer, template void unpack(Tabulated1DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(IntervalTabulated2DFunction& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm) +{ + std::vector xPos, yPos; + std::vector> samples; + bool xExtrapolate, yExtrapolate; + unpack(xPos, buffer, position, comm); + unpack(yPos, buffer, position, comm); + unpack(samples, buffer, position, comm); + unpack(xExtrapolate, buffer, position, comm); + unpack(yExtrapolate, buffer, position, comm); + data = IntervalTabulated2DFunction(xPos, yPos, samples, + xExtrapolate, yExtrapolate); +} + +template void unpack(IntervalTabulated2DFunction& data, + std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + template void unpack(SolventPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index b3f18e201..8cf068c9c 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -24,6 +24,7 @@ #endif #include +#include #include #include #include @@ -145,6 +146,9 @@ std::size_t packSize(const DynamicState& data, Dune::MPIHelper::MPICommunicat template std::size_t packSize(const Tabulated1DFunction& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const IntervalTabulated2DFunction& data, Dune::MPIHelper::MPICommunicator comm); + template std::size_t packSize(const SolventPvt& data, Dune::MPIHelper::MPICommunicator comm); @@ -207,6 +211,10 @@ template void pack(const Tabulated1DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const IntervalTabulated2DFunction& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + template void pack(const SolventPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -273,6 +281,10 @@ template void unpack(Tabulated1DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(IntervalTabulated2DFunction& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + template void unpack(SolventPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index cad90dd78..7409c5e08 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -981,6 +981,20 @@ BOOST_AUTO_TEST_CASE(TabulatedOneDFunction) } +BOOST_AUTO_TEST_CASE(IntervalTabulatedTwoDFunction) +{ +#ifdef HAVE_MPI + std::vector xPos{1.0, 2.0}; + std::vector yPos{3.0, 4.0}; + std::vector> samples{{1.0, 2.0}, {3.0, 4.0}}; + Opm::IntervalTabulated2DFunction val1(xPos, yPos, samples, true, true); + 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(SolventPvt) { #ifdef HAVE_MPI