diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 36c710c7a..b212d5c52 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -557,6 +557,19 @@ std::size_t packSize(const Tabulated1DFunction& data, template std::size_t packSize(const Tabulated1DFunction& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const SolventPvt& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.solventReferenceDensity(), comm) + + packSize(data.inverseSolventB(), comm) + + packSize(data.solventMu(), comm) + + packSize(data.inverseSolventBMu(), comm); +} + +template std::size_t packSize(const SolventPvt& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -1095,6 +1108,20 @@ 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 SolventPvt& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.solventReferenceDensity(), buffer, position, comm); + pack(data.inverseSolventB(), buffer, position, comm); + pack(data.solventMu(), buffer, position, comm); + pack(data.inverseSolventBMu(), buffer, position, comm); +} + +template void pack(const SolventPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + /// unpack routines template @@ -1795,6 +1822,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(SolventPvt& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector solventReferenceDensity; + std::vector::TabulatedOneDFunction> inverseSolventB; + std::vector::TabulatedOneDFunction> solventMu; + std::vector::TabulatedOneDFunction> inverseSolventBMu; + unpack(solventReferenceDensity, buffer, position, comm); + unpack(inverseSolventB, buffer, position, comm); + unpack(solventMu, buffer, position, comm); + unpack(inverseSolventBMu, buffer, position, comm); + data = SolventPvt(solventReferenceDensity, inverseSolventB, + solventMu, inverseSolventBMu); +} + +template void unpack(SolventPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + } // 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 c8419fe19..b3f18e201 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -145,6 +145,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 SolventPvt& data, Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -204,6 +207,10 @@ template void pack(const Tabulated1DFunction& 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); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -266,6 +273,10 @@ template void unpack(Tabulated1DFunction& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(SolventPvt& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + void unpack(char* str, std::size_t length, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 9d6c4ec80..cad90dd78 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -981,6 +981,19 @@ BOOST_AUTO_TEST_CASE(TabulatedOneDFunction) } +BOOST_AUTO_TEST_CASE(SolventPvt) +{ +#ifdef HAVE_MPI + Opm::Tabulated1DFunction func(2, std::vector{1.0, 2.0}, + std::vector{3.0, 4.0}); + Opm::SolventPvt val1({1.0, 2.0}, {func}, {func}, {func}); + 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;