add mpi serialization for Dimension

This commit is contained in:
Arne Morten Kvarving 2019-12-11 11:42:45 +01:00
parent 781625ec63
commit e53072faf5
3 changed files with 43 additions and 0 deletions

View File

@ -1126,6 +1126,14 @@ std::size_t packSize(const std::shared_ptr<T>& data,
template std::size_t packSize(const std::shared_ptr<SpiralICD>& data,
Dune::MPIHelper::MPICommunicator comm);
std::size_t packSize(const Dimension& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getName(), comm) +
packSize(data.getSIScalingRaw(), comm) +
packSize(data.getSIOffset(), comm);
}
////// pack routines
template<class T>
@ -2264,6 +2272,15 @@ void pack(const std::shared_ptr<T>& data, std::vector<char>& buffer, int& positi
template void pack(const std::shared_ptr<SpiralICD>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
void pack(const Dimension& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getName(), buffer, position, comm);
pack(data.getSIScalingRaw(), buffer, position, comm);
pack(data.getSIOffset(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -3851,6 +3868,19 @@ template void unpack(std::shared_ptr<SpiralICD>& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
void unpack(Dimension& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
std::string name;
double siScaling, siOffset;
unpack(name, buffer, position, comm);
unpack(siScaling, buffer, position, comm);
unpack(siOffset, buffer, position, comm);
data = Dimension(name, siScaling, siOffset);
}
#define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -62,6 +62,7 @@ class ColumnSchema;
class Connection;
class DENSITYRecord;
class DensityTable;
class Dimension;
class EclHysterConfig;
class Eqldims;
class EDITNNC;
@ -539,6 +540,7 @@ ADD_PACK_PROTOTYPES(data::Well)
ADD_PACK_PROTOTYPES(data::WellRates)
ADD_PACK_PROTOTYPES(DENSITYRecord)
ADD_PACK_PROTOTYPES(DensityTable)
ADD_PACK_PROTOTYPES(Dimension)
ADD_PACK_PROTOTYPES(EDITNNC)
ADD_PACK_PROTOTYPES(EndpointScaling)
ADD_PACK_PROTOTYPES(Equil)

View File

@ -1507,6 +1507,17 @@ BOOST_AUTO_TEST_CASE(Segment)
}
BOOST_AUTO_TEST_CASE(Dimension)
{
#ifdef HAVE_MPI
Opm::Dimension val1("test", 1.0, 2.0);
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;