add mpi serialization for GuideRateModel

This commit is contained in:
Arne Morten Kvarving 2019-12-12 13:00:47 +01:00
parent 34a55ed381
commit 805f68fdee
3 changed files with 76 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#include <opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateConfig.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>
@ -1390,6 +1391,19 @@ std::size_t packSize(const UDQActive& data,
packSize(data.getWgKeys(), comm);
}
std::size_t packSize(const GuideRateModel& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.timeInterval(), comm) +
packSize(data.target(), comm) +
packSize(data.coefs(), comm) +
packSize(data.allow_increase(), comm) +
packSize(data.damping_factor(), comm) +
packSize(data.free_gas(), comm) +
packSize(data.defaultModel(), comm) +
packSize(data.udaCoefs(), comm);
}
////// pack routines
template<class T>
@ -2803,6 +2817,20 @@ void pack(const UDQActive& data,
pack(data.getWgKeys(), buffer, position, comm);
}
void pack(const GuideRateModel& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.timeInterval(), buffer, position, comm);
pack(data.target(), buffer, position, comm);
pack(data.coefs(), buffer, position, comm);
pack(data.allow_increase(), buffer, position, comm);
pack(data.damping_factor(), buffer, position, comm);
pack(data.free_gas(), buffer, position, comm);
pack(data.defaultModel(), buffer, position, comm);
pack(data.udaCoefs(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -4787,6 +4815,29 @@ void unpack(UDQActive& data,
data = UDQActive(inputRecords, outputRecords, udqKeys, wgKeys);
}
void unpack(GuideRateModel& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
double timeInterval;
GuideRateModel::Target target;
std::array<double,6> coefs;
bool allow_increase, free_gas, defaultModel;
double damping_factor;
std::array<UDAValue,3> udaCoefs;
unpack(timeInterval, buffer, position, comm);
unpack(target, buffer, position, comm);
unpack(coefs, buffer, position, comm);
unpack(allow_increase, buffer, position, comm);
unpack(damping_factor, buffer, position, comm);
unpack(free_gas, buffer, position, comm);
unpack(defaultModel, buffer, position, comm);
unpack(udaCoefs, buffer, position, comm);
data = GuideRateModel(timeInterval, target, coefs, allow_increase,
damping_factor, free_gas, defaultModel, udaCoefs);
}
#define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -75,6 +75,7 @@ class EquilRecord;
class Events;
class FoamConfig;
class FoamData;
class GuideRateModel;
class InitConfig;
class IOConfig;
template<class T> class IOrderSet;
@ -600,6 +601,7 @@ ADD_PACK_PROTOTYPES(EquilRecord)
ADD_PACK_PROTOTYPES(Events)
ADD_PACK_PROTOTYPES(FoamConfig)
ADD_PACK_PROTOTYPES(FoamData)
ADD_PACK_PROTOTYPES(GuideRateModel)
ADD_PACK_PROTOTYPES(Group)
ADD_PACK_PROTOTYPES(Group::GroupInjectionProperties)
ADD_PACK_PROTOTYPES(Group::GroupProductionProperties)

View File

@ -38,6 +38,7 @@
#include <opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateModel.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>
@ -335,6 +336,17 @@ Opm::UDQConfig getUDQConfig()
omap,
{{Opm::UDQVarType::SCALAR, 5}, {Opm::UDQVarType::WELL_VAR, 6}});
}
Opm::GuideRateModel getGuideRateModel()
{
return Opm::GuideRateModel(1.0, Opm::GuideRateModel::Target::WAT,
{2.0, 3.0, 4.0, 5.0, 6.0, 7.0},
true, 8.0, false, false,
{Opm::UDAValue(9.0),
Opm::UDAValue(10.0),
Opm::UDAValue(11.0)});
}
#endif
@ -1831,6 +1843,17 @@ BOOST_AUTO_TEST_CASE(UDQActive)
}
BOOST_AUTO_TEST_CASE(GuideRateModel)
{
#ifdef HAVE_MPI
Opm::GuideRateModel val1 = getGuideRateModel();
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;