From 5d0e9164f3b6e041da0d7e91bd3fbde36159288d Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 5 Mar 2020 11:42:24 +0100 Subject: [PATCH] add mpi serialization for PolymerConfig --- opm/simulators/utils/ParallelRestart.cpp | 26 +++++++++++++++++++++++- opm/simulators/utils/ParallelRestart.hpp | 2 ++ tests/test_ParallelRestart.cpp | 15 ++++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index e68147ef4..e616628e2 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -686,10 +687,16 @@ std::size_t packSize(const FoamConfig& data, Dune::MPIHelper::MPICommunicator co packSize(data.getMobilityModel(), comm); } +std::size_t packSize(const PolymerConfig& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.shrate(), comm); +} + std::size_t packSize(const InitConfig& data, Dune::MPIHelper::MPICommunicator comm) { return packSize(data.getEquil(), comm) + packSize(data.getFoamConfig(), comm) + + packSize(data.getPolymerConfig(), comm) + packSize(data.filleps(), comm) + packSize(data.hasGravity(), comm) + packSize(data.restartRequested(), comm) + @@ -2297,11 +2304,18 @@ void pack(const FoamConfig& data, std::vector& buffer, int& position, pack(data.getMobilityModel(), buffer, position, comm); } +void pack(const PolymerConfig& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.shrate(), buffer, position, comm); +} + void pack(const InitConfig& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { pack(data.getEquil(), buffer, position, comm); pack(data.getFoamConfig(), buffer, position, comm); + pack(data.getPolymerConfig(), buffer, position, comm); pack(data.filleps(), buffer, position, comm); pack(data.hasGravity(), buffer, position, comm); pack(data.restartRequested(), buffer, position, comm); @@ -4145,22 +4159,32 @@ void unpack(FoamConfig& data, std::vector& buffer, int& position, data = FoamConfig(records, transport_phase, mobility_model); } +void unpack(PolymerConfig& data, std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + bool shrate; + unpack(shrate, buffer, position, comm); + data = PolymerConfig(shrate); +} + void unpack(InitConfig& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { Equil equil; FoamConfig foam; + PolymerConfig polymer; bool filleps, hasGravity, restartRequested; int restartStep; std::string restartRootName; unpack(equil, buffer, position, comm); unpack(foam, buffer, position, comm); + unpack(polymer, buffer, position, comm); unpack(filleps, buffer, position, comm); unpack(hasGravity, buffer, position, comm); unpack(restartRequested, buffer, position, comm); unpack(restartStep, buffer, position, comm); unpack(restartRootName, buffer, position, comm); - data = InitConfig(equil, foam, filleps, hasGravity, + data = InitConfig(equil, foam, polymer, filleps, hasGravity, restartRequested, restartStep, restartRootName); } diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 6946ef2e1..76b610b2c 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -112,6 +112,7 @@ class PlymwinjTable; class PolyInjTable; class PVCDORecord; class PvcdoTable; +class PolymerConfig; class PvtgTable; class PvtoTable; class PVTWRecord; @@ -564,6 +565,7 @@ ADD_PACK_PROTOTYPES(OilVaporizationProperties) ADD_PACK_PROTOTYPES(Phases) ADD_PACK_PROTOTYPES(PlymwinjTable) ADD_PACK_PROTOTYPES(PolyInjTable) +ADD_PACK_PROTOTYPES(PolymerConfig) ADD_PACK_PROTOTYPES(PVCDORecord) ADD_PACK_PROTOTYPES(PvcdoTable) ADD_PACK_PROTOTYPES(PvtgTable) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 103bb929b..aeb27b929 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -806,11 +807,21 @@ BOOST_AUTO_TEST_CASE(FoamConfig) } +BOOST_AUTO_TEST_CASE(PolymerConfig) +{ +#if HAVE_MPI + Opm::PolymerConfig val1(true); + auto val2 = PackUnpack(val1); + DO_CHECKS(PolymerConfig) +#endif +} + + BOOST_AUTO_TEST_CASE(InitConfig) { #if HAVE_MPI Opm::InitConfig val1(Opm::Equil({getEquilRecord(), getEquilRecord()}), - getFoamConfig(), + getFoamConfig(), Opm::PolymerConfig(true), true, true, true, 20, "test1"); auto val2 = PackUnpack(val1); DO_CHECKS(InitConfig) @@ -2275,7 +2286,7 @@ BOOST_AUTO_TEST_CASE(EclipseConfig) Opm::IOConfig io(true, false, true, false, false, true, "test1", true, "test2", true, "test3", false); Opm::InitConfig init(Opm::Equil({getEquilRecord(), getEquilRecord()}), - getFoamConfig(), + getFoamConfig(), Opm::PolymerConfig(true), true, true, true, 20, "test1"); Opm::EclipseConfig val1{init, io};