add mpi serialization for GConSump

This commit is contained in:
Arne Morten Kvarving 2019-12-12 14:12:29 +01:00
parent e7f0a00b00
commit b925d75def
3 changed files with 86 additions and 0 deletions

View File

@ -1431,6 +1431,22 @@ std::size_t packSize(const GConSale& data,
return packSize(data.getGroups(), comm);
}
std::size_t packSize(const GConSump::GCONSUMPGroup& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.consumption_rate, comm) +
packSize(data.import_rate, comm) +
packSize(data.network_node, comm) +
packSize(data.udq_undefined, comm) +
packSize(data.unit_system, comm);
}
std::size_t packSize(const GConSump& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getGroups(), comm);
}
////// pack routines
template<class T>
@ -2886,6 +2902,24 @@ void pack(const GConSale& data,
pack(data.getGroups(), buffer, position, comm);
}
void pack(const GConSump::GCONSUMPGroup& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.consumption_rate, buffer, position, comm);
pack(data.import_rate, buffer, position, comm);
pack(data.network_node, buffer, position, comm);
pack(data.udq_undefined, buffer, position, comm);
pack(data.unit_system, buffer, position, comm);
}
void pack(const GConSump& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getGroups(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -4928,6 +4962,26 @@ void unpack(GConSale& data,
data = GConSale(groups);
}
void unpack(GConSump::GCONSUMPGroup& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
unpack(data.consumption_rate, buffer, position, comm);
unpack(data.import_rate, buffer, position, comm);
unpack(data.network_node, buffer, position, comm);
unpack(data.udq_undefined, buffer, position, comm);
unpack(data.unit_system, buffer, position, comm);
}
void unpack(GConSump& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
std::map<std::string,GConSump::GCONSUMPGroup> groups;
unpack(groups, buffer, position, comm);
data = GConSump(groups);
}
#define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -42,6 +42,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
@ -604,6 +605,8 @@ ADD_PACK_PROTOTYPES(FoamConfig)
ADD_PACK_PROTOTYPES(FoamData)
ADD_PACK_PROTOTYPES(GConSale)
ADD_PACK_PROTOTYPES(GConSale::GCONSALEGroup)
ADD_PACK_PROTOTYPES(GConSump)
ADD_PACK_PROTOTYPES(GConSump::GCONSUMPGroup)
ADD_PACK_PROTOTYPES(GuideRateConfig)
ADD_PACK_PROTOTYPES(GuideRateConfig::GroupTarget)
ADD_PACK_PROTOTYPES(GuideRateConfig::WellTarget)

View File

@ -1934,6 +1934,35 @@ BOOST_AUTO_TEST_CASE(GConSale)
}
BOOST_AUTO_TEST_CASE(GConSumpGroup)
{
#ifdef HAVE_MPI
Opm::GConSump::GCONSUMPGroup val1{Opm::UDAValue(1.0),
Opm::UDAValue(2.0),
"test",
3.0, Opm::UnitSystem()};
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(GConSump)
{
#ifdef HAVE_MPI
Opm::GConSump::GCONSUMPGroup group{Opm::UDAValue(1.0),
Opm::UDAValue(2.0),
"test",
3.0, Opm::UnitSystem()};
Opm::GConSump val1({{"test1", group}, {"test2", group}});
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;