From e6a608ccc946130442cdd7a6a9e66dc162dc6434 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 5 Dec 2019 12:25:02 +0100 Subject: [PATCH 1/6] add mpi serialization for ConstantCompressibilityOilPvt --- opm/simulators/utils/ParallelRestart.cpp | 59 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 14 ++++++ tests/test_ParallelRestart.cpp | 12 +++++ 3 files changed, 85 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 0781c58cc..ee6414c22 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -697,6 +697,21 @@ std::size_t packSize(const WetGasPvt& data, template std::size_t packSize(const WetGasPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const ConstantCompressibilityOilPvt& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.oilReferenceDensity(), comm) + + packSize(data.oilReferencePressure(), comm) + + packSize(data.oilReferenceFormationVolumeFactor(), comm) + + packSize(data.oilCompressibility(), comm) + + packSize(data.oilViscosity(), comm) + + packSize(data.oilViscosibility(), comm); +} + +template std::size_t packSize(const ConstantCompressibilityOilPvt& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -1394,6 +1409,23 @@ template void pack(const WetGasPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const ConstantCompressibilityOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.oilReferenceDensity(), buffer, position, comm); + pack(data.oilReferencePressure(), buffer, position, comm); + pack(data.oilReferenceFormationVolumeFactor(), buffer, position, comm); + pack(data.oilCompressibility(), buffer, position, comm); + pack(data.oilViscosity(), buffer, position, comm); + pack(data.oilViscosibility(), buffer, position, comm); +} + +template void pack(const ConstantCompressibilityOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + /// unpack routines template @@ -2297,6 +2329,33 @@ template void unpack(WetGasPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(ConstantCompressibilityOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector oilReferenceDensity, oilReferencePressure, + oilReferenceFormationVolumeFactor, + oilCompressibility, oilViscosity, oilViscosibility; + + unpack(oilReferenceDensity, buffer, position, comm); + unpack(oilReferencePressure, buffer, position, comm); + unpack(oilReferenceFormationVolumeFactor, buffer, position, comm); + unpack(oilCompressibility, buffer, position, comm); + unpack(oilViscosity, buffer, position, comm); + unpack(oilViscosibility, buffer, position, comm); + data = ConstantCompressibilityOilPvt(oilReferenceDensity, + oilReferencePressure, + oilReferenceFormationVolumeFactor, + oilCompressibility, + oilViscosity, + oilViscosibility); +} + +template void unpack(ConstantCompressibilityOilPvt& 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 1be5fe1d8..4881af6b1 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -177,6 +178,10 @@ std::size_t packSize(const GasPvtThermal& data, Dune::MPIHelper::MPIComm template std::size_t packSize(const WetGasPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const ConstantCompressibilityOilPvt& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -269,6 +274,11 @@ template void pack(const WetGasPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const ConstantCompressibilityOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -364,6 +374,10 @@ template void unpack(WetGasPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(ConstantCompressibilityOilPvt& 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 0009619cf..d39c449d8 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -1074,6 +1074,18 @@ BOOST_AUTO_TEST_CASE(WetGasPvt) } +BOOST_AUTO_TEST_CASE(ConstantCompressibilityOilPvt) +{ +#ifdef HAVE_MPI + Opm::ConstantCompressibilityOilPvt val1({1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}, + {7.0, 8.0}, {9.0, 10.0}, {11.0, 12.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; From 1a3f00f3009de3c7ea87c7165fba7ffe704d8235 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 5 Dec 2019 12:36:29 +0100 Subject: [PATCH 2/6] add mpi serialization for DeadOilPvt --- opm/simulators/utils/ParallelRestart.cpp | 49 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 14 +++++++ tests/test_ParallelRestart.cpp | 13 +++++++ 3 files changed, 76 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index ee6414c22..bceae4af6 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -712,6 +712,19 @@ std::size_t packSize(const ConstantCompressibilityOilPvt& data, template std::size_t packSize(const ConstantCompressibilityOilPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const DeadOilPvt& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.oilReferenceDensity(), comm) + + packSize(data.inverseOilB(), comm) + + packSize(data.oilMu(), comm) + + packSize(data.inverseOilBMu(), comm); +} + +template std::size_t packSize(const DeadOilPvt& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -1426,6 +1439,21 @@ template void pack(const ConstantCompressibilityOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const DeadOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.oilReferenceDensity(), buffer, position, comm); + pack(data.inverseOilB(), buffer, position, comm); + pack(data.oilMu(), buffer, position, comm); + pack(data.inverseOilBMu(), buffer, position, comm); +} + +template void pack(const DeadOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + /// unpack routines template @@ -2356,6 +2384,27 @@ template void unpack(ConstantCompressibilityOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(DeadOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector oilReferenceDensity; + using FuncVec = std::vector::TabulatedOneDFunction>; + FuncVec inverseOilB, oilMu, inverseOilBMu; + + unpack(oilReferenceDensity, buffer, position, comm); + unpack(inverseOilB, buffer, position, comm); + unpack(oilMu, buffer, position, comm); + unpack(inverseOilBMu, buffer, position, comm); + data = DeadOilPvt(oilReferenceDensity, inverseOilB, + oilMu, inverseOilBMu); +} + +template void unpack(DeadOilPvt& 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 4881af6b1..b6fd30c45 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -182,6 +183,10 @@ template std::size_t packSize(const ConstantCompressibilityOilPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const DeadOilPvt& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -279,6 +284,11 @@ void pack(const ConstantCompressibilityOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const DeadOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -378,6 +388,10 @@ template void unpack(ConstantCompressibilityOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(DeadOilPvt& 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 d39c449d8..05008fd9a 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -1086,6 +1086,19 @@ BOOST_AUTO_TEST_CASE(ConstantCompressibilityOilPvt) } +BOOST_AUTO_TEST_CASE(DeadOilPvt) +{ +#ifdef HAVE_MPI + Opm::Tabulated1DFunction func(2, std::vector{1.0, 2.0}, + std::vector{3.0, 4.0}); + Opm::DeadOilPvt 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; From 30dde6f4100521195f73a51573bdf4c9ca3d0e54 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 5 Dec 2019 14:06:59 +0100 Subject: [PATCH 3/6] add mpi serialization for LiveOilPvt --- opm/simulators/utils/ParallelRestart.cpp | 84 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 14 ++++ tests/test_ParallelRestart.cpp | 21 ++++++ 3 files changed, 119 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index bceae4af6..d0bc260ff 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -725,6 +725,26 @@ std::size_t packSize(const DeadOilPvt& data, template std::size_t packSize(const DeadOilPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const LiveOilPvt& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.gasReferenceDensity(), comm) + + packSize(data.oilReferenceDensity(), comm) + + packSize(data.inverseOilBTable(), comm) + + packSize(data.oilMuTable(), comm) + + packSize(data.inverseOilBMuTable(), comm) + + packSize(data.saturatedOilMuTable(), comm) + + packSize(data.inverseSaturatedOilBTable(), comm) + + packSize(data.inverseSaturatedOilBMuTable(), comm) + + packSize(data.saturatedGasDissolutionFactorTable(), comm) + + packSize(data.saturationPressure(), comm) + + packSize(data.vapPar2(), comm); +} + +template std::size_t packSize(const LiveOilPvt& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -1454,6 +1474,28 @@ template void pack(const DeadOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const LiveOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.gasReferenceDensity(), buffer, position, comm); + pack(data.oilReferenceDensity(), buffer, position, comm); + pack(data.inverseOilBTable(), buffer, position, comm); + pack(data.oilMuTable(), buffer, position, comm); + pack(data.inverseOilBMuTable(), buffer, position, comm); + pack(data.saturatedOilMuTable(), buffer, position, comm); + pack(data.inverseSaturatedOilBTable(), buffer, position, comm); + pack(data.inverseSaturatedOilBMuTable(), buffer, position, comm); + pack(data.saturatedGasDissolutionFactorTable(), buffer, position, comm); + pack(data.saturationPressure(), buffer, position, comm); + pack(data.vapPar2(), buffer, position, comm); +} + +template void pack(const LiveOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + /// unpack routines template @@ -2405,6 +2447,48 @@ template void unpack(DeadOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(LiveOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector gasReferenceDensity, oilReferenceDensity; + using FuncVec = std::vector::TabulatedOneDFunction>; + using FuncVec2 = std::vector::TabulatedTwoDFunction>; + FuncVec2 inverseOilBTable, oilMuTable, inverseOilBMuTable; + FuncVec saturatedOilMuTable, inverseSaturatedOilBTable, + inverseSaturatedOilBMuTable, + saturatedGasDissolutionFactorTable, saturationPressure; + Scalar vapPar2; + + unpack(gasReferenceDensity, buffer, position, comm); + unpack(oilReferenceDensity, buffer, position, comm); + unpack(inverseOilBTable, buffer, position, comm); + unpack(oilMuTable, buffer, position, comm); + unpack(inverseOilBMuTable, buffer, position, comm); + unpack(saturatedOilMuTable, buffer, position, comm); + unpack(inverseSaturatedOilBTable, buffer, position, comm); + unpack(inverseSaturatedOilBMuTable, buffer, position, comm); + unpack(saturatedGasDissolutionFactorTable, buffer, position, comm); + unpack(saturationPressure, buffer, position, comm); + unpack(vapPar2, buffer, position, comm); + data = LiveOilPvt(gasReferenceDensity, + oilReferenceDensity, + inverseOilBTable, + oilMuTable, + inverseOilBMuTable, + saturatedOilMuTable, + inverseSaturatedOilBTable, + inverseSaturatedOilBMuTable, + saturatedGasDissolutionFactorTable, + saturationPressure, + vapPar2); +} + +template void unpack(LiveOilPvt& 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 b6fd30c45..3a7ca37be 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -187,6 +188,10 @@ template std::size_t packSize(const DeadOilPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const LiveOilPvt& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -289,6 +294,11 @@ void pack(const DeadOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const LiveOilPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -392,6 +402,10 @@ template void unpack(DeadOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(LiveOilPvt& 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 05008fd9a..b1abfa09a 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -1099,6 +1099,27 @@ BOOST_AUTO_TEST_CASE(DeadOilPvt) } +BOOST_AUTO_TEST_CASE(LiveOilPvt) +{ +#ifdef HAVE_MPI + Opm::Tabulated1DFunction func(2, std::vector{1.0, 2.0}, + std::vector{3.0, 4.0}); + std::vector xPos{1.0, 2.0}; + std::vector yPos{3.0, 4.0}; + using FFuncType = Opm::UniformXTabulated2DFunction; + using Samples = std::vector>; + Samples samples({{{1.0, 2.0, 3.0}, {3.0, 4.0, 5.0}}}); + FFuncType func2(xPos, yPos, samples, FFuncType::Vertical); + Opm::LiveOilPvt val1({1.0, 2.0}, {3.0, 4.0}, + {func2}, {func2}, {func2}, + {func}, {func}, {func}, {func}, {func}, 5.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; From fe4ed0466a6076347bd04396066123d7ebc61e0b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 5 Dec 2019 14:29:42 +0100 Subject: [PATCH 4/6] add mpi serialization for OilPvtMultiplexer and OilPvtThermal these are intermixed so kept in one commit --- opm/simulators/utils/ParallelRestart.cpp | 186 +++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 26 ++++ tests/test_ParallelRestart.cpp | 16 ++ 3 files changed, 228 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index d0bc260ff..64f29f1ec 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -697,6 +697,35 @@ std::size_t packSize(const WetGasPvt& data, template std::size_t packSize(const WetGasPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const OilPvtMultiplexer& data, + Dune::MPIHelper::MPICommunicator comm) +{ + std::size_t size = packSize(data.approach(), comm); + const void* realOilPvt = data.realOilPvt(); + using PvtApproach = OilPvtMultiplexer; + if (data.approach() == PvtApproach::ConstantCompressibilityOilPvt) { + const auto& pvt = *static_cast*>(realOilPvt); + size += packSize(pvt, comm); + } else if (data.approach() == PvtApproach::DeadOilPvt) { + const auto& pvt = *static_cast*>(realOilPvt); + size += packSize(pvt, comm); + } else if (data.approach() == PvtApproach::LiveOilPvt) { + const auto& pvt = *static_cast*>(realOilPvt); + size += packSize(pvt, comm); + } else if (data.approach() == PvtApproach::ThermalOilPvt) { + const auto& pvt = *static_cast*>(realOilPvt); + size += packSize(pvt, comm); + } + + return size; +} + +template std::size_t packSize(const OilPvtMultiplexer& data, + Dune::MPIHelper::MPICommunicator comm); +template std::size_t packSize(const OilPvtMultiplexer& data, + Dune::MPIHelper::MPICommunicator comm); + template std::size_t packSize(const ConstantCompressibilityOilPvt& data, Dune::MPIHelper::MPICommunicator comm) @@ -745,6 +774,31 @@ std::size_t packSize(const LiveOilPvt& data, template std::size_t packSize(const LiveOilPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const OilPvtThermal& data, + Dune::MPIHelper::MPICommunicator comm) +{ + std::size_t size = packSize(data.oilvisctCurves(), comm) + + packSize(data.viscrefPress(), comm) + + packSize(data.viscrefRs(), comm) + + packSize(data.viscRef(), comm) + + packSize(data.oildentRefTemp(), comm) + + packSize(data.oildentCT1(), comm) + + packSize(data.oildentCT2(), comm) + + packSize(data.internalEnergyCurves(), comm) + + packSize(data.enableThermalDensity(), comm) + + packSize(data.enableThermalViscosity(), comm) + + packSize(data.enableInternalEnergy(), comm); + size += packSize(bool(), comm); + if (data.isoThermalPvt()) + size += packSize(*data.isoThermalPvt(), comm); + + return size; +} + +template std::size_t packSize(const OilPvtThermal& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -1442,6 +1496,36 @@ template void pack(const WetGasPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const OilPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.approach(), buffer, position, comm); + const void* realOilPvt = data.realOilPvt(); + using PvtApproach = OilPvtMultiplexer; + if (data.approach() == PvtApproach::ConstantCompressibilityOilPvt) { + const auto& pvt = *static_cast*>(realOilPvt); + pack(pvt, buffer, position, comm); + } else if (data.approach() == PvtApproach::DeadOilPvt) { + const auto& pvt = *static_cast*>(realOilPvt); + pack(pvt, buffer, position, comm); + } else if (data.approach() == PvtApproach::LiveOilPvt) { + const auto& pvt = *static_cast*>(realOilPvt); + pack(pvt, buffer, position, comm); + } else if (data.approach() == PvtApproach::ThermalOilPvt) { + const auto& pvt = *static_cast*>(realOilPvt); + pack(pvt, buffer, position, comm); + } +} + +template void pack(const OilPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); +template void pack(const OilPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + template void pack(const ConstantCompressibilityOilPvt& data, std::vector& buffer, int& position, @@ -1496,6 +1580,31 @@ template void pack(const LiveOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const OilPvtThermal& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.oilvisctCurves(), buffer, position, comm); + pack(data.viscrefPress(), buffer, position, comm); + pack(data.viscrefRs(), buffer, position, comm); + pack(data.viscRef(), buffer, position, comm); + pack(data.oildentRefTemp(), buffer, position, comm); + pack(data.oildentCT1(), buffer, position, comm); + pack(data.oildentCT2(), buffer, position, comm); + pack(data.internalEnergyCurves(), buffer, position, comm); + pack(data.enableThermalDensity(), buffer, position, comm); + pack(data.enableThermalViscosity(), buffer, position, comm); + pack(data.enableInternalEnergy(), buffer, position, comm); + pack(data.isoThermalPvt() != nullptr, buffer, position, comm); + if (data.isoThermalPvt()) + pack(*data.isoThermalPvt(), buffer, position, comm); +} + +template void pack(const OilPvtThermal& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + /// unpack routines template @@ -2399,6 +2508,42 @@ template void unpack(WetGasPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(OilPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + typename OilPvtMultiplexer::OilPvtApproach approach; + unpack(approach, buffer, position, comm); + using PvtApproach = OilPvtMultiplexer; + void* pvt = nullptr; + if (approach == PvtApproach::ConstantCompressibilityOilPvt) { + auto* realPvt = new ConstantCompressibilityOilPvt; + unpack(*realPvt, buffer, position, comm); + pvt = realPvt; + } else if (approach == PvtApproach::DeadOilPvt) { + auto* realPvt = new DeadOilPvt; + unpack(*realPvt, buffer, position, comm); + pvt = realPvt; + } else if (approach == PvtApproach::LiveOilPvt) { + auto* realPvt = new LiveOilPvt; + unpack(*realPvt, buffer, position, comm); + pvt = realPvt; + } else if (approach == PvtApproach::ThermalOilPvt) { + auto* realPvt = new OilPvtThermal; + unpack(*realPvt, buffer, position, comm); + pvt = realPvt; + } + data = OilPvtMultiplexer(approach, pvt); +} + +template void unpack(OilPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); +template void unpack(OilPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + template void unpack(ConstantCompressibilityOilPvt& data, std::vector& buffer, int& position, @@ -2489,6 +2634,47 @@ template void unpack(LiveOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(OilPvtThermal& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector::TabulatedOneDFunction> oilvisctCurves; + std::vector oildentRefTemp, oildentCT1, oildentCT2, viscrefPress, viscrefRs, viscRef; + std::vector::TabulatedOneDFunction> internalEnergyCurves; + bool enableThermalDensity, enableThermalViscosity, enableInternalEnergy; + unpack(oilvisctCurves, buffer, position, comm); + unpack(viscrefPress, buffer, position, comm); + unpack(viscrefRs, buffer, position, comm); + unpack(viscRef, buffer, position, comm); + unpack(oildentRefTemp, buffer, position, comm); + unpack(oildentCT1, buffer, position, comm); + unpack(oildentCT2, buffer, position, comm); + unpack(internalEnergyCurves, buffer, position, comm); + unpack(enableThermalDensity, buffer, position, comm); + unpack(enableThermalViscosity, buffer, position, comm); + unpack(enableInternalEnergy, buffer, position, comm); + bool isothermal; + unpack(isothermal, buffer, position, comm); + typename OilPvtThermal::IsothermalPvt* pvt = nullptr; + if (isothermal) { + pvt = new typename OilPvtThermal::IsothermalPvt; + unpack(*pvt, buffer, position, comm); + } + data = OilPvtThermal(pvt, oilvisctCurves, + viscrefPress, viscrefRs, viscRef, + oildentRefTemp, + oildentCT1, oildentCT2, + internalEnergyCurves, + enableThermalDensity, + enableThermalViscosity, + enableInternalEnergy); +} + +template void unpack(OilPvtThermal& 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 3a7ca37be..e66d4ede7 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -180,6 +181,10 @@ std::size_t packSize(const GasPvtThermal& data, Dune::MPIHelper::MPIComm template std::size_t packSize(const WetGasPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const OilPvtMultiplexer& data, + Dune::MPIHelper::MPICommunicator comm); + template std::size_t packSize(const ConstantCompressibilityOilPvt& data, Dune::MPIHelper::MPICommunicator comm); @@ -192,6 +197,9 @@ template std::size_t packSize(const LiveOilPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const OilPvtThermal& data, Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -284,6 +292,11 @@ template void pack(const WetGasPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const OilPvtMultiplexer& data, + const std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + template void pack(const ConstantCompressibilityOilPvt& data, std::vector& buffer, int& position, @@ -299,6 +312,10 @@ void pack(const LiveOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const OilPvtThermal& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -394,6 +411,11 @@ template void unpack(WetGasPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(OilPvtMultiplexer& data, + const std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + template void unpack(ConstantCompressibilityOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -406,6 +428,10 @@ template void unpack(LiveOilPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(OilPvtThermal& 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 b1abfa09a..475261e85 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -1120,6 +1120,22 @@ BOOST_AUTO_TEST_CASE(LiveOilPvt) } +BOOST_AUTO_TEST_CASE(OilPvtThermal) +{ +#ifdef HAVE_MPI + Opm::Tabulated1DFunction func(2, std::vector{1.0, 2.0}, + std::vector{3.0, 4.0}); + Opm::OilPvtThermal::IsothermalPvt* pvt = new Opm::OilPvtThermal::IsothermalPvt; + Opm::OilPvtThermal val1(pvt, {func}, {1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}, + {7.0, 8.0}, {9.0, 10.0}, {11.0, 12.0}, + {func}, true, true, false); + 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; From e56bbba99cf7314cc49e0866ee492d1588d78177 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 5 Dec 2019 20:04:01 +0100 Subject: [PATCH 5/6] add mpi serialization for ConstantCompressibilityWaterPvt --- opm/simulators/utils/ParallelRestart.cpp | 59 ++++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 14 ++++++ tests/test_ParallelRestart.cpp | 12 +++++ 3 files changed, 85 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 64f29f1ec..ff0505f3f 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -799,6 +799,21 @@ std::size_t packSize(const OilPvtThermal& data, template std::size_t packSize(const OilPvtThermal& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const ConstantCompressibilityWaterPvt& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.waterReferenceDensity(), comm) + + packSize(data.waterReferencePressure(), comm) + + packSize(data.waterReferenceFormationVolumeFactor(), comm) + + packSize(data.waterCompressibility(), comm) + + packSize(data.waterViscosity(), comm) + + packSize(data.waterViscosibility(), comm); +} + +template std::size_t packSize(const ConstantCompressibilityWaterPvt& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -1605,6 +1620,23 @@ template void pack(const OilPvtThermal& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const ConstantCompressibilityWaterPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.waterReferenceDensity(), buffer, position, comm); + pack(data.waterReferencePressure(), buffer, position, comm); + pack(data.waterReferenceFormationVolumeFactor(), buffer, position, comm); + pack(data.waterCompressibility(), buffer, position, comm); + pack(data.waterViscosity(), buffer, position, comm); + pack(data.waterViscosibility(), buffer, position, comm); +} + +template void pack(const ConstantCompressibilityWaterPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + /// unpack routines template @@ -2675,6 +2707,33 @@ template void unpack(OilPvtThermal& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(ConstantCompressibilityWaterPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector waterReferenceDensity, waterReferencePressure, + waterReferenceFormationVolumeFactor, + waterCompressibility, waterViscosity, waterViscosibility; + + unpack(waterReferenceDensity, buffer, position, comm); + unpack(waterReferencePressure, buffer, position, comm); + unpack(waterReferenceFormationVolumeFactor, buffer, position, comm); + unpack(waterCompressibility, buffer, position, comm); + unpack(waterViscosity, buffer, position, comm); + unpack(waterViscosibility, buffer, position, comm); + data = ConstantCompressibilityWaterPvt(waterReferenceDensity, + waterReferencePressure, + waterReferenceFormationVolumeFactor, + waterCompressibility, + waterViscosity, + waterViscosibility); +} + +template void unpack(ConstantCompressibilityWaterPvt& 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 e66d4ede7..9b73ecb5f 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -200,6 +201,10 @@ std::size_t packSize(const LiveOilPvt& data, template std::size_t packSize(const OilPvtThermal& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const ConstantCompressibilityWaterPvt& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -316,6 +321,11 @@ template void pack(const OilPvtThermal& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const ConstantCompressibilityWaterPvt& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -432,6 +442,10 @@ template void unpack(OilPvtThermal& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(ConstantCompressibilityWaterPvt& 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 475261e85..01dd855bd 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -1136,6 +1136,18 @@ BOOST_AUTO_TEST_CASE(OilPvtThermal) } +BOOST_AUTO_TEST_CASE(ConstantCompressibilityWaterPvt) +{ +#ifdef HAVE_MPI + Opm::ConstantCompressibilityWaterPvt val1({1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}, + {7.0, 8.0}, {9.0, 10.0}, {11.0, 12.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; From 1ab9a66bf4ad5d6bcb13b5ce792682b77f0135bf Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 5 Dec 2019 20:19:16 +0100 Subject: [PATCH 6/6] add mpi serialization for WaterPvtMultiplexer and WaterPvtThermal these are intermixed so kept in one commit --- opm/simulators/utils/ParallelRestart.cpp | 180 +++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 26 ++++ tests/test_ParallelRestart.cpp | 17 +++ 3 files changed, 223 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index ff0505f3f..d4301395a 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -799,6 +799,29 @@ std::size_t packSize(const OilPvtThermal& data, template std::size_t packSize(const OilPvtThermal& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const WaterPvtMultiplexer& data, + Dune::MPIHelper::MPICommunicator comm) +{ + std::size_t size = packSize(data.approach(), comm); + const void* realWaterPvt = data.realWaterPvt(); + using PvtApproach = WaterPvtMultiplexer; + if (data.approach() == PvtApproach::ConstantCompressibilityWaterPvt) { + const auto& pvt = *static_cast*>(realWaterPvt); + size += packSize(pvt, comm); + } else if (data.approach() == PvtApproach::ThermalWaterPvt) { + const auto& pvt = *static_cast*>(realWaterPvt); + size += packSize(pvt, comm); + } + + return size; +} + +template std::size_t packSize(const WaterPvtMultiplexer& data, + Dune::MPIHelper::MPICommunicator comm); +template std::size_t packSize(const WaterPvtMultiplexer& data, + Dune::MPIHelper::MPICommunicator comm); + template std::size_t packSize(const ConstantCompressibilityWaterPvt& data, Dune::MPIHelper::MPICommunicator comm) @@ -814,6 +837,34 @@ std::size_t packSize(const ConstantCompressibilityWaterPvt& data, template std::size_t packSize(const ConstantCompressibilityWaterPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const WaterPvtThermal& data, + Dune::MPIHelper::MPICommunicator comm) +{ + std::size_t size = packSize(data.viscrefPress(), comm) + + packSize(data.watdentRefTemp(), comm) + + packSize(data.watdentCT1(), comm) + + packSize(data.watdentCT2(), comm) + + packSize(data.pvtwRefPress(), comm) + + packSize(data.pvtwRefB(), comm) + + packSize(data.pvtwCompressibility(), comm) + + packSize(data.pvtwViscosity(), comm) + + packSize(data.pvtwViscosibility(), comm) + + packSize(data.watvisctCurves(), comm) + + packSize(data.internalEnergyCurves(), comm) + + packSize(data.enableThermalDensity(), comm) + + packSize(data.enableThermalViscosity(), comm) + + packSize(data.enableInternalEnergy(), comm); + size += packSize(bool(), comm); + if (data.isoThermalPvt()) + size += packSize(*data.isoThermalPvt(), comm); + + return size; +} + +template std::size_t packSize(const WaterPvtThermal& data, + Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -1620,6 +1671,30 @@ template void pack(const OilPvtThermal& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const WaterPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.approach(), buffer, position, comm); + const void* realWaterPvt = data.realWaterPvt(); + using PvtApproach = WaterPvtMultiplexer; + if (data.approach() == PvtApproach::ConstantCompressibilityWaterPvt) { + const auto& pvt = *static_cast*>(realWaterPvt); + pack(pvt, buffer, position, comm); + } else if (data.approach() == PvtApproach::ThermalWaterPvt) { + const auto& pvt = *static_cast*>(realWaterPvt); + pack(pvt, buffer, position, comm); + } +} + +template void pack(const WaterPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); +template void pack(const WaterPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + template void pack(const ConstantCompressibilityWaterPvt& data, std::vector& buffer, int& position, @@ -1637,6 +1712,34 @@ template void pack(const ConstantCompressibilityWaterPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const WaterPvtThermal& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.viscrefPress(), buffer, position, comm); + pack(data.watdentRefTemp(), buffer, position, comm); + pack(data.watdentCT1(), buffer, position, comm); + pack(data.watdentCT2(), buffer, position, comm); + pack(data.pvtwRefPress(), buffer, position, comm); + pack(data.pvtwRefB(), buffer, position, comm); + pack(data.pvtwCompressibility(), buffer, position, comm); + pack(data.pvtwViscosity(), buffer, position, comm); + pack(data.pvtwViscosibility(), buffer, position, comm); + pack(data.watvisctCurves(), buffer, position, comm); + pack(data.internalEnergyCurves(), buffer, position, comm); + pack(data.enableThermalDensity(), buffer, position, comm); + pack(data.enableThermalViscosity(), buffer, position, comm); + pack(data.enableInternalEnergy(), buffer, position, comm); + pack(data.isoThermalPvt() != nullptr, buffer, position, comm); + if (data.isoThermalPvt()) + pack(*data.isoThermalPvt(), buffer, position, comm); +} + +template void pack(const WaterPvtThermal& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + /// unpack routines template @@ -2707,6 +2810,34 @@ template void unpack(OilPvtThermal& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(WaterPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + typename WaterPvtMultiplexer::WaterPvtApproach approach; + unpack(approach, buffer, position, comm); + using PvtApproach = WaterPvtMultiplexer; + void* pvt = nullptr; + if (approach == PvtApproach::ConstantCompressibilityWaterPvt) { + auto* realPvt = new ConstantCompressibilityWaterPvt; + unpack(*realPvt, buffer, position, comm); + pvt = realPvt; + } else if (data.approach() == PvtApproach::ThermalWaterPvt) { + auto* realPvt = new WaterPvtThermal; + unpack(*realPvt, buffer, position, comm); + pvt = realPvt; + } + data = WaterPvtMultiplexer(approach, pvt); +} + +template void unpack(WaterPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); +template void unpack(WaterPvtMultiplexer& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + template void unpack(ConstantCompressibilityWaterPvt& data, std::vector& buffer, int& position, @@ -2734,6 +2865,55 @@ template void unpack(ConstantCompressibilityWaterPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(WaterPvtThermal& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector viscrefPress, watdentRefTemp, watdentCT1, watdentCT2, + pvtwRefPress, pvtwRefB, pvtwCompressibility, + pvtwViscosity, pvtwViscosibility; + std::vector::TabulatedOneDFunction> watvisctCurves; + std::vector::TabulatedOneDFunction> internalEnergyCurves; + bool enableThermalDensity, enableThermalViscosity, enableInternalEnergy; + unpack(viscrefPress, buffer, position, comm); + unpack(watdentRefTemp, buffer, position, comm); + unpack(watdentCT1, buffer, position, comm); + unpack(watdentCT2, buffer, position, comm); + unpack(pvtwRefPress, buffer, position, comm); + unpack(pvtwRefB, buffer, position, comm); + unpack(pvtwCompressibility, buffer, position, comm); + unpack(pvtwViscosity, buffer, position, comm); + unpack(pvtwViscosibility, buffer, position, comm); + unpack(watvisctCurves, buffer, position, comm); + unpack(internalEnergyCurves, buffer, position, comm); + unpack(enableThermalDensity, buffer, position, comm); + unpack(enableThermalViscosity, buffer, position, comm); + unpack(enableInternalEnergy, buffer, position, comm); + bool isothermal; + unpack(isothermal, buffer, position, comm); + typename WaterPvtThermal::IsothermalPvt* pvt = nullptr; + if (isothermal) { + pvt = new typename WaterPvtThermal::IsothermalPvt; + unpack(*pvt, buffer, position, comm); + } + data = WaterPvtThermal(pvt, viscrefPress, watdentRefTemp, + watdentCT1, watdentCT2, + pvtwRefPress, pvtwRefB, + pvtwCompressibility, + pvtwViscosity, + pvtwViscosibility, + watvisctCurves, + internalEnergyCurves, + enableThermalDensity, + enableThermalViscosity, + enableInternalEnergy); +} + +template void unpack(WaterPvtThermal& 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 9b73ecb5f..47e7f77d2 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -201,10 +202,17 @@ std::size_t packSize(const LiveOilPvt& data, template std::size_t packSize(const OilPvtThermal& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const WaterPvtMultiplexer& data, + Dune::MPIHelper::MPICommunicator comm); + template std::size_t packSize(const ConstantCompressibilityWaterPvt& data, Dune::MPIHelper::MPICommunicator comm); +template +std::size_t packSize(const WaterPvtThermal& data, Dune::MPIHelper::MPICommunicator comm); + ////// pack routines template @@ -321,11 +329,20 @@ template void pack(const OilPvtThermal& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const WaterPvtMultiplexer& data, + const std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + template void pack(const ConstantCompressibilityWaterPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void pack(const WaterPvtThermal& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -442,6 +459,15 @@ template void unpack(OilPvtThermal& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); +template +void unpack(WaterPvtMultiplexer& data, + const std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm); + +template +void unpack(WaterPvtThermal& data, std::vector& buffer, + int& position, Dune::MPIHelper::MPICommunicator comm); + template void unpack(ConstantCompressibilityWaterPvt& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 01dd855bd..5275822d9 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -1148,6 +1148,23 @@ BOOST_AUTO_TEST_CASE(ConstantCompressibilityWaterPvt) } +BOOST_AUTO_TEST_CASE(WaterPvtThermal) +{ +#ifdef HAVE_MPI + Opm::Tabulated1DFunction func(2, std::vector{1.0, 2.0}, + std::vector{3.0, 4.0}); + Opm::WaterPvtThermal::IsothermalPvt* pvt = new Opm::WaterPvtThermal::IsothermalPvt; + Opm::WaterPvtThermal val1(pvt, {1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}, + {7.0, 8.0}, {9.0, 10.0}, {11.0, 12.0}, + {13.0, 14.0}, {15.0, 16.0}, {17.0, 18.0}, + {func}, {func}, true, true, false); + 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;