add mpi serialization for SummaryConfig

This commit is contained in:
Arne Morten Kvarving 2020-01-06 15:27:37 +01:00
parent b596ac6e6e
commit fa5f026fe4
3 changed files with 50 additions and 0 deletions

View File

@ -1688,6 +1688,14 @@ std::size_t packSize(const SummaryNode& data,
packSize(data.isUserDefined(), comm);
}
std::size_t packSize(const SummaryConfig& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getKwds(), comm) +
packSize(data.getShortKwds(), comm) +
packSize(data.getSmryKwds(), comm);
}
////// pack routines
template<class T>
@ -3398,6 +3406,15 @@ void pack(const SummaryNode& data,
pack(data.isUserDefined(), buffer, position, comm);
}
void pack(const SummaryConfig& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getKwds(), buffer, position, comm);
pack(data.getShortKwds(), buffer, position, comm);
pack(data.getSmryKwds(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -5856,6 +5873,19 @@ void unpack(SummaryNode& data,
.isUserDefined(isUserDefined);
}
void unpack(SummaryConfig& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
SummaryConfig::keyword_list kwds;
std::set<std::string> shortKwds, smryKwds;
unpack(kwds, buffer, position, comm);
unpack(shortKwds, buffer, position, comm);
unpack(smryKwds, buffer, position, comm);
data = SummaryConfig(kwds, shortKwds, smryKwds);
}
#define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -126,6 +126,7 @@ class SimpleTable;
class SkprpolyTable;
class SkprwatTable;
class SpiralICD;
class SummaryConfig;
class SummaryNode;
class Tabdims;
class TableColumn;
@ -705,6 +706,7 @@ ADD_PACK_PROTOTYPES(SkprpolyTable)
ADD_PACK_PROTOTYPES(SkprwatTable)
ADD_PACK_PROTOTYPES(SpiralICD)
ADD_PACK_PROTOTYPES(std::string)
ADD_PACK_PROTOTYPES(SummaryConfig)
ADD_PACK_PROTOTYPES(SummaryNode)
ADD_PACK_PROTOTYPES(Tabdims)
ADD_PACK_PROTOTYPES(TableColumn)

View File

@ -2358,6 +2358,24 @@ BOOST_AUTO_TEST_CASE(SummaryNode)
}
BOOST_AUTO_TEST_CASE(SummaryConfig)
{
#ifdef HAVE_MPI
auto node = Opm::SummaryNode{"test1", Opm::SummaryNode::Category::Region,
Opm::Location{"test2", 1}}
.parameterType(Opm::SummaryNode::Type::Pressure)
.namedEntity("test3")
.number(2)
.isUserDefined(true);
Opm::SummaryConfig val1({node}, {"test1", "test2"}, {"test3", "test4"});
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;