add mpi serialiation for Valve

This commit is contained in:
Arne Morten Kvarving 2019-12-18 11:04:31 +01:00
parent 9baba1bae9
commit cf7e81bb07
3 changed files with 68 additions and 0 deletions

View File

@ -33,6 +33,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MessageLimits.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
@ -1079,6 +1080,19 @@ std::size_t packSize(const SpiralICD& data,
packSize(data.scalingFactor(), comm);
}
std::size_t packSize(const Valve& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.conFlowCoefficient(), comm) +
packSize(data.conCrossArea(), comm) +
packSize(data.conMaxCrossArea(), comm) +
packSize(data.pipeAdditionalLength(), comm) +
packSize(data.pipeDiameter(), comm) +
packSize(data.pipeRoughness(), comm) +
packSize(data.pipeCrossArea(), comm) +
packSize(data.status(), comm);
}
////// pack routines
template<class T>
@ -2171,6 +2185,20 @@ void pack(const SpiralICD& data,
pack(data.scalingFactor(), buffer, position, comm);
}
void pack(const Valve& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.conFlowCoefficient(), buffer, position, comm);
pack(data.conCrossArea(), buffer, position, comm);
pack(data.conMaxCrossArea(), buffer, position, comm);
pack(data.pipeAdditionalLength(), buffer, position, comm);
pack(data.pipeDiameter(), buffer, position, comm);
pack(data.pipeRoughness(), buffer, position, comm);
pack(data.pipeCrossArea(), buffer, position, comm);
pack(data.status(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -3684,6 +3712,32 @@ void unpack(SpiralICD& data,
status, scalingFactor);
}
void unpack(Valve& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
double conFlowCoefficient;
double conCrossArea;
double conMaxCrossArea;
double pipeAdditionalLength;
double pipeDiameter;
double pipeRoughness;
double pipeCrossArea;
Valve::Status status;
unpack(conFlowCoefficient, buffer, position, comm);
unpack(conCrossArea, buffer, position, comm);
unpack(conMaxCrossArea, buffer, position, comm);
unpack(pipeAdditionalLength, buffer, position, comm);
unpack(pipeDiameter, buffer, position, comm);
unpack(pipeRoughness, buffer, position, comm);
unpack(pipeCrossArea, buffer, position, comm);
unpack(status, buffer, position, comm);
data = Valve(conFlowCoefficient, conCrossArea, conMaxCrossArea,
pipeAdditionalLength, pipeDiameter, pipeRoughness,
pipeCrossArea, status);
}
#define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -109,6 +109,7 @@ class TableSchema;
class ThresholdPressure;
class UDAValue;
class UDQParams;
class Valve;
class VFPInjTable;
class VFPProdTable;
class VISCREFRecord;
@ -577,6 +578,7 @@ ADD_PACK_PROTOTYPES(TimeMap)
ADD_PACK_PROTOTYPES(TimeMap::StepData)
ADD_PACK_PROTOTYPES(UDAValue)
ADD_PACK_PROTOTYPES(UDQParams)
ADD_PACK_PROTOTYPES(Valve)
ADD_PACK_PROTOTYPES(VFPInjTable)
ADD_PACK_PROTOTYPES(VFPProdTable)
ADD_PACK_PROTOTYPES(VISCREFRecord)

View File

@ -39,6 +39,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MessageLimits.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
@ -1481,6 +1482,17 @@ BOOST_AUTO_TEST_CASE(SpiralICD)
}
BOOST_AUTO_TEST_CASE(Valve)
{
#ifdef HAVE_MPI
Opm::Valve val1(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, Opm::Valve::Status::OPEN);
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;