add mpi serialization for EclipseConfig

This commit is contained in:
Arne Morten Kvarving 2020-01-14 14:47:44 +01:00
parent ff8fac563f
commit b93efe29f8
3 changed files with 53 additions and 0 deletions

View File

@ -1973,6 +1973,14 @@ std::size_t packSize(const MULTREGTScanner& data,
packSize(data.getDefaultRegion(), comm);
}
std::size_t packSize(const EclipseConfig& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.init(), comm) +
packSize(data.io(), comm) +
packSize(data.restart(), comm);
}
////// pack routines
template<class T>
@ -3851,6 +3859,15 @@ void pack(const MULTREGTScanner& data,
pack(data.getDefaultRegion(), buffer, position, comm);
}
void pack(const EclipseConfig& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.init(), buffer, position, comm);
pack(data.io(), buffer, position, comm);
pack(data.restart(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -6535,6 +6552,20 @@ void unpack(MULTREGTScanner& data,
data = MULTREGTScanner(size, records, searchMap, regions, defaultRegion);
}
void unpack(EclipseConfig& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
InitConfig init;
IOConfig io;
RestartConfig restart;
unpack(init, buffer, position, comm);
unpack(io, buffer, position, comm);
unpack(restart, buffer, position, comm);
data = EclipseConfig(io, init, restart);
}
#define INSTANTIATE_PACK_VECTOR(...) \
template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -84,6 +84,7 @@ class DENSITYRecord;
class DensityTable;
class Dimension;
class EclHysterConfig;
class EclipseConfig;
class Eqldims;
class EDITNNC;
class EndpointScaling;
@ -656,6 +657,7 @@ ADD_PACK_PROTOTYPES(DENSITYRecord)
ADD_PACK_PROTOTYPES(DensityTable)
ADD_PACK_PROTOTYPES(Dimension)
ADD_PACK_PROTOTYPES(EclHysterConfig)
ADD_PACK_PROTOTYPES(EclipseConfig)
ADD_PACK_PROTOTYPES(EDITNNC)
ADD_PACK_PROTOTYPES(EndpointScaling)
ADD_PACK_PROTOTYPES(Equil)

View File

@ -2446,6 +2446,26 @@ BOOST_AUTO_TEST_CASE(MULTREGTScanner)
}
BOOST_AUTO_TEST_CASE(EclipseConfig)
{
#ifdef HAVE_MPI
Opm::IOConfig io(true, false, true, false, false, true, 1, "test1", true,
"test2", true, "test3", false);
Opm::InitConfig init(Opm::Equil({getEquilRecord(), getEquilRecord()}),
Opm::FoamConfig({getFoamData(), getFoamData()}),
true, true, 20, "test1");
Opm::DynamicState<Opm::RestartSchedule> rsched({Opm::RestartSchedule(1, 2, 3)}, 2);
Opm::DynamicState<std::map<std::string,int>> rkw({{{"test",3}}}, 3);
Opm::RestartConfig restart(getTimeMap(), 1, true, rsched, rkw, {false, true});
Opm::EclipseConfig val1{io, init, restart};
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;