mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-03 21:16:54 -06:00
add mpi serialization for UnitSystem
This commit is contained in:
parent
e53072faf5
commit
5bc506cd3b
@ -1134,6 +1134,15 @@ std::size_t packSize(const Dimension& data,
|
||||
packSize(data.getSIOffset(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const UnitSystem& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.getName(), comm) +
|
||||
packSize(data.getType(), comm) +
|
||||
packSize(data.getDimensions(), comm) +
|
||||
packSize(data.use_count(), comm);
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -2281,6 +2290,16 @@ void pack(const Dimension& data,
|
||||
pack(data.getSIOffset(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const UnitSystem& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.getName(), buffer, position, comm);
|
||||
pack(data.getType(), buffer, position, comm);
|
||||
pack(data.getDimensions(), buffer, position, comm);
|
||||
pack(data.use_count(), buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -3881,6 +3900,22 @@ void unpack(Dimension& data,
|
||||
data = Dimension(name, siScaling, siOffset);
|
||||
}
|
||||
|
||||
void unpack(UnitSystem& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::string name;
|
||||
UnitSystem::UnitType type;
|
||||
std::map<std::string, Dimension> dimensions;
|
||||
size_t use_count;
|
||||
unpack(name, buffer, position, comm);
|
||||
unpack(type, buffer, position, comm);
|
||||
unpack(dimensions, buffer, position, comm);
|
||||
unpack(use_count, buffer, position, comm);
|
||||
|
||||
data = UnitSystem(name, type, dimensions, use_count);
|
||||
}
|
||||
|
||||
#define INSTANTIATE_PACK_VECTOR(T) \
|
||||
template std::size_t packSize(const std::vector<T>& data, \
|
||||
Dune::MPIHelper::MPICommunicator comm); \
|
||||
|
@ -111,6 +111,7 @@ class TableSchema;
|
||||
class ThresholdPressure;
|
||||
class UDAValue;
|
||||
class UDQParams;
|
||||
class UnitSystem;
|
||||
class Valve;
|
||||
class VFPInjTable;
|
||||
class VFPProdTable;
|
||||
@ -594,6 +595,7 @@ ADD_PACK_PROTOTYPES(TimeMap)
|
||||
ADD_PACK_PROTOTYPES(TimeMap::StepData)
|
||||
ADD_PACK_PROTOTYPES(UDAValue)
|
||||
ADD_PACK_PROTOTYPES(UDQParams)
|
||||
ADD_PACK_PROTOTYPES(UnitSystem)
|
||||
ADD_PACK_PROTOTYPES(Valve)
|
||||
ADD_PACK_PROTOTYPES(VFPInjTable)
|
||||
ADD_PACK_PROTOTYPES(VFPProdTable)
|
||||
|
@ -1518,6 +1518,17 @@ BOOST_AUTO_TEST_CASE(Dimension)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UnitSystem)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
Opm::UnitSystem val1(Opm::UnitSystem::UnitType::UNIT_TYPE_METRIC);
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user