Merge pull request #2412 from akva2/serialize_polymerconfig

add mpi serialization for PolymerConfig
This commit is contained in:
Arne Morten Kvarving 2020-03-05 13:03:08 +01:00 committed by GitHub
commit 27f52d5aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 3 deletions

View File

@ -31,6 +31,7 @@
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/PolymerConfig.hpp>
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
#include <opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp>
@ -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<char>& buffer, int& position,
pack(data.getMobilityModel(), buffer, position, comm);
}
void pack(const PolymerConfig& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.shrate(), buffer, position, comm);
}
void pack(const InitConfig& data, std::vector<char>& 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<char>& buffer, int& position,
data = FoamConfig(records, transport_phase, mobility_model);
}
void unpack(PolymerConfig& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
bool shrate;
unpack(shrate, buffer, position, comm);
data = PolymerConfig(shrate);
}
void unpack(InitConfig& data, std::vector<char>& 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);
}

View File

@ -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)

View File

@ -38,6 +38,7 @@
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/PolymerConfig.hpp>
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
#include <opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.hpp>
@ -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};