add mpi serialization for DeckKeyword

This commit is contained in:
Arne Morten Kvarving 2019-12-13 11:40:55 +01:00
parent 8ba18cf038
commit 1860141771
3 changed files with 52 additions and 0 deletions

View File

@ -1488,6 +1488,16 @@ std::size_t packSize(const Location& data,
packSize(data.lineno, comm);
}
std::size_t packSize(const DeckKeyword& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.name(), comm) +
packSize(data.location(), comm) +
packSize(data.records(), comm) +
packSize(data.isDataKeyword(), comm) +
packSize(data.isSlashTerminated(), comm);
}
////// pack routines
template<class T>
@ -3004,6 +3014,17 @@ void pack(const Location& data,
pack(data.lineno, buffer, position, comm);
}
void pack(const DeckKeyword& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.name(), buffer, position, comm);
pack(data.location(), buffer, position, comm);
pack(data.records(), buffer, position, comm);
pack(data.isDataKeyword(), buffer, position, comm);
pack(data.isSlashTerminated(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -5134,6 +5155,24 @@ void unpack(Location& data,
unpack(data.lineno, buffer, position, comm);
}
void unpack(DeckKeyword& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
std::string name;
Location location;
std::vector<DeckRecord> records;
bool isDataKeyword, isSlashTerminated;
unpack(name, buffer, position, comm);
unpack(location, buffer, position, comm);
unpack(records, buffer, position, comm);
unpack(isDataKeyword, buffer, position, comm);
unpack(isSlashTerminated, buffer, position, comm);
data = DeckKeyword(name, location, records,
isDataKeyword, isSlashTerminated);
}
#define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -596,6 +596,7 @@ ADD_PACK_PROTOTYPES(data::Solution)
ADD_PACK_PROTOTYPES(data::Well)
ADD_PACK_PROTOTYPES(data::WellRates)
ADD_PACK_PROTOTYPES(DeckItem)
ADD_PACK_PROTOTYPES(DeckKeyword)
ADD_PACK_PROTOTYPES(DeckRecord)
ADD_PACK_PROTOTYPES(DENSITYRecord)
ADD_PACK_PROTOTYPES(DensityTable)

View File

@ -2041,6 +2041,18 @@ BOOST_AUTO_TEST_CASE(Location)
}
BOOST_AUTO_TEST_CASE(DeckKeyword)
{
#ifdef HAVE_MPI
Opm::DeckKeyword val1("test", {"test",1},
{getDeckRecord(), getDeckRecord()}, true, false);
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;