From 2ce7b35e694c5d1a6fb5baa4a5436bf58a5b7c61 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 24 Feb 2020 16:50:06 +0100 Subject: [PATCH 1/2] Serialize density-temparture class DenT --- opm/simulators/utils/ParallelRestart.cpp | 34 +++++++++++++++++++++++- opm/simulators/utils/ParallelRestart.hpp | 3 +++ tests/test_ParallelRestart.cpp | 19 +++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 74f4cd604..ad1abf2da 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -454,6 +454,7 @@ HANDLE_AS_POD(data::CurrentControl) HANDLE_AS_POD(data::Rates) HANDLE_AS_POD(data::Segment) HANDLE_AS_POD(DENSITYRecord) +HANDLE_AS_POD(DenT::entry) HANDLE_AS_POD(Eqldims) HANDLE_AS_POD(MLimits) HANDLE_AS_POD(PVTWRecord) @@ -521,6 +522,11 @@ std::size_t packSize(const ThresholdPressure& data, Dune::MPIHelper::MPICommunic packSize(data.pressureTable(), comm); } +std::size_t packSize(const DenT& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.records(), comm); +} + std::size_t packSize(const Aquifetp& data, Dune::MPIHelper::MPICommunicator comm) { return packSize(data.data(), comm); @@ -860,6 +866,9 @@ std::size_t packSize(const TableManager& data, Dune::MPIHelper::MPICommunicator packSize(data.useEnptvd(), comm) + packSize(data.useEqlnum(), comm) + packSize(data.useJFunc(), comm) + + packSize(data.OilDenT(), comm) + + packSize(data.GasDenT(), comm) + + packSize(data.WatDenT(), comm) + (data.useJFunc() ? packSize(data.getJFunc(), comm) : 0) + packSize(data.rtemp(), comm); } @@ -2356,6 +2365,12 @@ void pack(const Aquifetp::AQUFETP_data& data, std::vector& buffer, int& po pack(data.p0, buffer, position, comm); } +void pack(const DenT& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) { + pack(data.records(), buffer, position, comm); +} + + void pack(const Aquifetp& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { pack(data.data(), buffer, position, comm); @@ -2699,6 +2714,9 @@ void pack(const TableManager& data, std::vector& buffer, int& position, pack(data.useEnptvd(), buffer, position, comm); pack(data.useEqlnum(), buffer, position, comm); pack(data.useJFunc(), buffer, position, comm); + pack(data.OilDenT(), buffer, position, comm); + pack(data.GasDenT(), buffer, position, comm); + pack(data.WatDenT(), buffer, position, comm); if (data.useJFunc()) pack(data.getJFunc(), buffer, position, comm); pack(data.rtemp(), buffer, position, comm); @@ -4334,6 +4352,15 @@ void unpack(AquiferCT::AQUCT_data& data, std::vector& buffer, int& positio cell_id); } + +void unpack(DenT& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) +{ + std::vector records; + unpack(records, buffer, position, comm); + data = DenT( records ); +} + + void unpack(AquiferCT& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { std::vector aquiferList; @@ -4817,6 +4844,7 @@ void unpack(TableManager& data, std::vector& buffer, int& position, bool hasImptvd; bool hasEntpvd; bool hasEqlnum; + DenT oilDenT, gasDenT, watDenT; std::shared_ptr jfunc; double rtemp; unpack(simpleTables, buffer, position, comm); @@ -4842,6 +4870,9 @@ void unpack(TableManager& data, std::vector& buffer, int& position, unpack(hasImptvd, buffer, position, comm); unpack(hasEntpvd, buffer, position, comm); unpack(hasEqlnum, buffer, position, comm); + unpack(oilDenT, buffer, position, comm); + unpack(gasDenT, buffer, position, comm); + unpack(watDenT, buffer, position, comm); bool hasJf; unpack(hasJf, buffer, position, comm); if (hasJf) { @@ -4854,7 +4885,8 @@ void unpack(TableManager& data, std::vector& buffer, int& position, rockTable, viscrefTable, watdentTable, pvtwsaltTables, bdensityTables, plymwinjTables, skprwatTables, skprpolyTables, tabdims, regdims, eqldims, - aqudims, hasImptvd, hasEntpvd, hasEqlnum, jfunc, rtemp); + aqudims, hasImptvd, hasEntpvd, hasEqlnum, oilDenT, gasDenT, + watDenT, jfunc, rtemp); } template diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 1247eaa35..adbc73a14 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -86,6 +86,7 @@ class Connection; class DeckItem; class DeckRecord; class DENSITYRecord; +class DenT; class DensityTable; class Dimension; class EclHysterConfig; @@ -699,6 +700,8 @@ ADD_PACK_PROTOTYPES(DeckKeyword) ADD_PACK_PROTOTYPES(DeckRecord) ADD_PACK_PROTOTYPES(DENSITYRecord) ADD_PACK_PROTOTYPES(DensityTable) +ADD_PACK_PROTOTYPES(DenT) +ADD_PACK_PROTOTYPES(DenT::entry) ADD_PACK_PROTOTYPES(Dimension) ADD_PACK_PROTOTYPES(EclHysterConfig) ADD_PACK_PROTOTYPES(EclipseConfig) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index cce48ec9c..de5c8ee1e 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -229,6 +230,13 @@ Opm::TableColumn getTableColumn() } +Opm::DenT getDenT() { + std::vector records; + records.emplace_back(1,2,3); + records.emplace_back(4,5,6); + return Opm::DenT(records); +} + Opm::SimpleTable getSimpleTable() { Opm::OrderedMap data; @@ -1208,6 +1216,9 @@ BOOST_AUTO_TEST_CASE(TableManager) true, true, true, + getDent(), + getDenT(), + getDenT(), jfunc, 1.0); auto val2 = PackUnpack(val1); @@ -2463,6 +2474,14 @@ BOOST_AUTO_TEST_CASE(Fault) #endif } +BOOST_AUTO_TEST_CASE(DenT) +{ +#ifdef HAVE_MPI + Opm::DenT val1 = getDenT(); + auto val2 = PackUnpack(val1); + DO_CHECKS(DenT) +#endif +} BOOST_AUTO_TEST_CASE(FaultCollection) { From d94943a741cf1e779a41e34c7abc36c553db1ca2 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 25 Feb 2020 08:04:28 +0100 Subject: [PATCH 2/2] Serialize new member TableManager::gas_comp_index --- opm/simulators/utils/ParallelRestart.cpp | 21 +++++++++++++-------- tests/test_ParallelRestart.cpp | 7 ++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index ad1abf2da..627bcaafb 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -866,10 +866,11 @@ std::size_t packSize(const TableManager& data, Dune::MPIHelper::MPICommunicator packSize(data.useEnptvd(), comm) + packSize(data.useEqlnum(), comm) + packSize(data.useJFunc(), comm) + + (data.useJFunc() ? packSize(data.getJFunc(), comm) : 0) + packSize(data.OilDenT(), comm) + packSize(data.GasDenT(), comm) + packSize(data.WatDenT(), comm) + - (data.useJFunc() ? packSize(data.getJFunc(), comm) : 0) + + packSize(data.gas_comp_index(), comm) + packSize(data.rtemp(), comm); } @@ -2714,11 +2715,12 @@ void pack(const TableManager& data, std::vector& buffer, int& position, pack(data.useEnptvd(), buffer, position, comm); pack(data.useEqlnum(), buffer, position, comm); pack(data.useJFunc(), buffer, position, comm); + if (data.useJFunc()) + pack(data.getJFunc(), buffer, position, comm); pack(data.OilDenT(), buffer, position, comm); pack(data.GasDenT(), buffer, position, comm); pack(data.WatDenT(), buffer, position, comm); - if (data.useJFunc()) - pack(data.getJFunc(), buffer, position, comm); + pack(data.gas_comp_index(), buffer, position, comm); pack(data.rtemp(), buffer, position, comm); } @@ -4845,6 +4847,7 @@ void unpack(TableManager& data, std::vector& buffer, int& position, bool hasEntpvd; bool hasEqlnum; DenT oilDenT, gasDenT, watDenT; + std::size_t gas_comp_index; std::shared_ptr jfunc; double rtemp; unpack(simpleTables, buffer, position, comm); @@ -4870,23 +4873,25 @@ void unpack(TableManager& data, std::vector& buffer, int& position, unpack(hasImptvd, buffer, position, comm); unpack(hasEntpvd, buffer, position, comm); unpack(hasEqlnum, buffer, position, comm); - unpack(oilDenT, buffer, position, comm); - unpack(gasDenT, buffer, position, comm); - unpack(watDenT, buffer, position, comm); bool hasJf; unpack(hasJf, buffer, position, comm); if (hasJf) { jfunc = std::make_shared(); unpack(*jfunc, buffer, position, comm); } + unpack(oilDenT, buffer, position, comm); + unpack(gasDenT, buffer, position, comm); + unpack(watDenT, buffer, position, comm); + unpack(gas_comp_index, buffer, position, comm); unpack(rtemp, buffer, position, comm); + data = TableManager(simpleTables, pvtgTables, pvtoTables, rock2dTables, rock2dtrTables, pvtwTable, pvcdoTable, densityTable, rockTable, viscrefTable, watdentTable, pvtwsaltTables, bdensityTables, plymwinjTables, skprwatTables, skprpolyTables, tabdims, regdims, eqldims, - aqudims, hasImptvd, hasEntpvd, hasEqlnum, oilDenT, gasDenT, - watDenT, jfunc, rtemp); + aqudims, hasImptvd, hasEntpvd, hasEqlnum, jfunc, oilDenT, gasDenT, + watDenT, gas_comp_index, rtemp); } template diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index de5c8ee1e..41dde03e0 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -1216,10 +1216,11 @@ BOOST_AUTO_TEST_CASE(TableManager) true, true, true, - getDent(), - getDenT(), - getDenT(), jfunc, + getDenT(), + getDenT(), + getDenT(), + 77, 1.0); auto val2 = PackUnpack(val1); DO_CHECKS(TableManager)