From b9f8429691ecfe6fd0204a8842cbdc884c97fdfb Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 8 Jan 2020 12:38:37 +0100 Subject: [PATCH] add mpi serialization for BrineDensityTable --- opm/simulators/utils/ParallelRestart.cpp | 22 ++++++++++++++++++++++ opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 9 +++++++++ 3 files changed, 33 insertions(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index daa63d6b8..ace67c547 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1676,6 +1676,12 @@ std::size_t packSize(const Schedule& data, packSize(data.getWellGroupEvents(), comm); } +std::size_t packSize(const BrineDensityTable& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.getBrineDensityColumn(), comm); +} + std::size_t packSize(const SummaryNode& data, Dune::MPIHelper::MPICommunicator comm) { @@ -3393,6 +3399,13 @@ void pack(const Schedule& data, pack(data.getWellGroupEvents(), buffer, position, comm); } +void pack(const BrineDensityTable& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.getBrineDensityColumn(), buffer, position, comm); +} + void pack(const SummaryNode& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -5847,6 +5860,15 @@ void unpack(Schedule& data, std::vector& buffer, int& position, rftConfig, nupCol, wellGroupEvents); } +void unpack(BrineDensityTable& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::vector tableValues; + + unpack(tableValues, buffer, position, comm); + data = BrineDensityTable(tableValues); +} + void unpack(SummaryNode& 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 29e496e87..35d1c036b 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -75,6 +75,7 @@ namespace Action { } class Aqudims; +class BrineDensityTable; class ColumnSchema; class Connection; class DeckItem; @@ -633,6 +634,7 @@ ADD_PACK_PROTOTYPES(Action::ASTNode) ADD_PACK_PROTOTYPES(Action::Condition) ADD_PACK_PROTOTYPES(Action::Quantity) ADD_PACK_PROTOTYPES(Aqudims) +ADD_PACK_PROTOTYPES(BrineDensityTable) ADD_PACK_PROTOTYPES(ColumnSchema) ADD_PACK_PROTOTYPES(Connection) ADD_PACK_PROTOTYPES(data::CellData) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index bc56d177f..882d82f59 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2342,6 +2342,15 @@ BOOST_AUTO_TEST_CASE(Schedule) #endif } +BOOST_AUTO_TEST_CASE(BrineDensityTable) +{ +#ifdef HAVE_MPI + Opm::BrineDensityTable val1({1.0, 2.0, 3.0}); + 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(SummaryNode) {