mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-29 04:23:48 -06:00
add mpi serialization for UDAValue
This commit is contained in:
parent
cebb19ad01
commit
cadd8dc414
@ -958,6 +958,14 @@ std::size_t packSize(const WellTracerProperties& data,
|
||||
return packSize(data.getConcentrations(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const UDAValue& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.is<double>(), comm) +
|
||||
(data.is<double>() ? packSize(data.get<double>(), comm) :
|
||||
packSize(data.get<std::string>(), comm));
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -1924,6 +1932,17 @@ void pack(const WellTracerProperties& data,
|
||||
pack(data.getConcentrations(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const UDAValue& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.is<double>(), buffer, position, comm);
|
||||
if (data.is<double>())
|
||||
pack(data.get<double>(), buffer, position, comm);
|
||||
else
|
||||
pack(data.get<std::string>(), buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -3237,6 +3256,23 @@ void unpack(WellTracerProperties& data,
|
||||
data = WellTracerProperties(ddata);
|
||||
}
|
||||
|
||||
void unpack(UDAValue& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
bool isDouble;
|
||||
unpack(isDouble, buffer, position, comm);
|
||||
if (isDouble) {
|
||||
double val;
|
||||
unpack(val, buffer, position, comm);
|
||||
data = UDAValue(val);
|
||||
} else {
|
||||
std::string val;
|
||||
unpack(val, buffer, position, comm);
|
||||
data = UDAValue(val);
|
||||
}
|
||||
}
|
||||
|
||||
#define INSTANTIATE_PACK_VECTOR(T) \
|
||||
template std::size_t packSize(const std::vector<T>& data, \
|
||||
Dune::MPIHelper::MPICommunicator comm); \
|
||||
|
@ -104,6 +104,7 @@ class TableContainer;
|
||||
class TableManager;
|
||||
class TableSchema;
|
||||
class ThresholdPressure;
|
||||
class UDAValue;
|
||||
class UDQParams;
|
||||
class VFPInjTable;
|
||||
class VFPProdTable;
|
||||
@ -567,6 +568,7 @@ ADD_PACK_PROTOTYPES(TableSchema)
|
||||
ADD_PACK_PROTOTYPES(ThresholdPressure)
|
||||
ADD_PACK_PROTOTYPES(TimeMap)
|
||||
ADD_PACK_PROTOTYPES(TimeMap::StepData)
|
||||
ADD_PACK_PROTOTYPES(UDAValue)
|
||||
ADD_PACK_PROTOTYPES(UDQParams)
|
||||
ADD_PACK_PROTOTYPES(VFPInjTable)
|
||||
ADD_PACK_PROTOTYPES(VFPProdTable)
|
||||
|
@ -1348,6 +1348,21 @@ BOOST_AUTO_TEST_CASE(WellTracerProperties)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UDAValue)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
Opm::UDAValue val1("test");
|
||||
auto val2 = PackUnpack(val1);
|
||||
BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2));
|
||||
BOOST_CHECK(val1 == std::get<0>(val2));
|
||||
val1 = Opm::UDAValue(1.0);
|
||||
auto val22 = PackUnpack(val1);
|
||||
BOOST_CHECK(std::get<1>(val22) == std::get<2>(val22));
|
||||
BOOST_CHECK(val1 == std::get<0>(val22));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool init_unit_test_func()
|
||||
{
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user