diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index b7b7ff06b..b0e2bd179 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -604,6 +604,19 @@ std::size_t packSize(const IntervalTabulated2DFunction& data, template std::size_t packSize(const IntervalTabulated2DFunction& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const UniformXTabulated2DFunction& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.xPos(), comm) + + packSize(data.yPos(), comm) + + packSize(data.samples(), comm) + + packSize(data.interpolationGuide(), comm); +} + +template std::size_t packSize(const UniformXTabulated2DFunction& data, + Dune::MPIHelper::MPICommunicator comm); + template std::size_t packSize(const DryGasPvt& data, Dune::MPIHelper::MPICommunicator comm) @@ -1193,6 +1206,30 @@ template void pack(const IntervalTabulated2DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const std::vector>& data, + std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + +template +void pack(const std::map>& data, + std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + +template +void pack(const UniformXTabulated2DFunction& 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.interpolationGuide(), buffer, position, comm); +} + +template void pack(const UniformXTabulated2DFunction& 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) @@ -1964,6 +2001,25 @@ template void unpack(IntervalTabulated2DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(UniformXTabulated2DFunction& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm) +{ + std::vector xPos, yPos; + std::vector::SamplePoint>> samples; + typename UniformXTabulated2DFunction::InterpolationPolicy interpolationGuide; + unpack(xPos, buffer, position, comm); + unpack(yPos, buffer, position, comm); + unpack(samples, buffer, position, comm); + unpack(interpolationGuide, buffer, position, comm); + data = UniformXTabulated2DFunction(xPos, yPos, samples, + interpolationGuide); +} + +template void unpack(UniformXTabulated2DFunction& 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 0d40d505c..c4aa0a8b0 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -154,6 +155,9 @@ std::size_t packSize(const Tabulated1DFunction& data, Dune::MPIHelper::M template std::size_t packSize(const IntervalTabulated2DFunction& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const UniformXTabulated2DFunction& data, Dune::MPIHelper::MPICommunicator comm); + template std::size_t packSize(const SolventPvt& data, Dune::MPIHelper::MPICommunicator comm); @@ -227,6 +231,10 @@ template void pack(const IntervalTabulated2DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const UniformXTabulated2DFunction& 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); @@ -305,6 +313,10 @@ template void unpack(IntervalTabulated2DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(UniformXTabulated2DFunction& 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 1075f2f9c..0d4269ff1 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -996,6 +996,21 @@ BOOST_AUTO_TEST_CASE(IntervalTabulatedTwoDFunction) } +BOOST_AUTO_TEST_CASE(UniformXTabulatedTwoDFunction) +{ +#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, 5.0, 6.0}}}; + using FFuncType = Opm::UniformXTabulated2DFunction; + FFuncType val1(xPos, yPos, samples, FFuncType::Vertical); + 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