add mpi serialization for EclEpsScalingPointsInfo

This commit is contained in:
Arne Morten Kvarving 2020-01-22 11:02:01 +01:00
parent 9bbfd92604
commit 1354656f8b
3 changed files with 112 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include "ParallelRestart.hpp"
#include <opm/common/OpmLog/Location.hpp>
#include <opm/material/fluidmatrixinteractions/EclEpsScalingPoints.hpp>
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
@ -1081,6 +1082,33 @@ std::size_t packSize(const WaterPvtThermal<Scalar>& data,
template std::size_t packSize(const WaterPvtThermal<double>& data,
Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
std::size_t packSize(const EclEpsScalingPointsInfo<Scalar>& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.Swl, comm) +
packSize(data.Sgl, comm) +
packSize(data.Sowl, comm) +
packSize(data.Sogl, comm) +
packSize(data.krCriticalEps, comm) +
packSize(data.Swcr, comm) +
packSize(data.Sgcr, comm) +
packSize(data.Sowcr, comm) +
packSize(data.Sogcr, comm) +
packSize(data.Swu, comm) +
packSize(data.Sgu, comm) +
packSize(data.Sowu, comm) +
packSize(data.Sogu, comm) +
packSize(data.maxPcow, comm) +
packSize(data.maxPcgo, comm) +
packSize(data.pcowLeverettFactor, comm) +
packSize(data.pcgoLeverettFactor, comm) +
packSize(data.maxKrw, comm) +
packSize(data.maxKrow, comm) +
packSize(data.maxKrog, comm) +
packSize(data.maxKrg, comm);
}
std::size_t packSize(const OilVaporizationProperties& data,
Dune::MPIHelper::MPICommunicator comm)
{
@ -3932,6 +3960,33 @@ void pack(const FaultCollection& data,
pack(data.getFaults(), buffer, position, comm);
}
template<class Scalar>
void pack(const EclEpsScalingPointsInfo<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm)
{
pack(data.Swl, buffer, position, comm);
pack(data.Sgl, buffer, position, comm);
pack(data.Sowl, buffer, position, comm);
pack(data.Sogl, buffer, position, comm);
pack(data.krCriticalEps, buffer, position, comm);
pack(data.Swcr, buffer, position, comm);
pack(data.Sgcr, buffer, position, comm);
pack(data.Sowcr, buffer, position, comm);
pack(data.Sogcr, buffer, position, comm);
pack(data.Swu, buffer, position, comm);
pack(data.Sgu, buffer, position, comm);
pack(data.Sowu, buffer, position, comm);
pack(data.Sogu, buffer, position, comm);
pack(data.maxPcow, buffer, position, comm);
pack(data.maxPcgo, buffer, position, comm);
pack(data.pcowLeverettFactor, buffer, position, comm);
pack(data.pcgoLeverettFactor, buffer, position, comm);
pack(data.maxKrw, buffer, position, comm);
pack(data.maxKrow, buffer, position, comm);
pack(data.maxKrog, buffer, position, comm);
pack(data.maxKrg, buffer, position, comm);
}
/// unpack routines
template<class T>
@ -4129,6 +4184,33 @@ void unpack(DynamicVector<T>& data, std::vector<char>& buffer, int& position,
data = DynamicVector<T>(ddata);
}
template<class Scalar>
void unpack(EclEpsScalingPointsInfo<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm)
{
unpack(data.Swl, buffer, position, comm);
unpack(data.Sgl, buffer, position, comm);
unpack(data.Sowl, buffer, position, comm);
unpack(data.Sogl, buffer, position, comm);
unpack(data.krCriticalEps, buffer, position, comm);
unpack(data.Swcr, buffer, position, comm);
unpack(data.Sgcr, buffer, position, comm);
unpack(data.Sowcr, buffer, position, comm);
unpack(data.Sogcr, buffer, position, comm);
unpack(data.Swu, buffer, position, comm);
unpack(data.Sgu, buffer, position, comm);
unpack(data.Sowu, buffer, position, comm);
unpack(data.Sogu, buffer, position, comm);
unpack(data.maxPcow, buffer, position, comm);
unpack(data.maxPcgo, buffer, position, comm);
unpack(data.pcowLeverettFactor, buffer, position, comm);
unpack(data.pcgoLeverettFactor, buffer, position, comm);
unpack(data.maxKrw, buffer, position, comm);
unpack(data.maxKrow, buffer, position, comm);
unpack(data.maxKrog, buffer, position, comm);
unpack(data.maxKrg, buffer, position, comm);
}
void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
@ -6698,6 +6780,7 @@ INSTANTIATE_PACK_VECTOR(bool)
INSTANTIATE_PACK_VECTOR(char)
INSTANTIATE_PACK_VECTOR(Opm::Tabulated1DFunction<double>)
INSTANTIATE_PACK_VECTOR(std::array<double, 3>)
INSTANTIATE_PACK_VECTOR(EclEpsScalingPointsInfo<double>)
#undef INSTANTIATE_PACK_VECTOR
#define INSTANTIATE_PACK_SHARED_PTR(...) \
@ -6733,6 +6816,7 @@ INSTANTIATE_PACK(int)
INSTANTIATE_PACK(std::array<short,3>)
INSTANTIATE_PACK(std::array<bool,3>)
INSTANTIATE_PACK(unsigned char)
INSTANTIATE_PACK(EclEpsScalingPointsInfo<double>)
#undef INSTANTIATE_PACK
} // end namespace Mpi

View File

@ -86,6 +86,7 @@ class Dimension;
class EclHysterConfig;
class EclipseConfig;
class Eqldims;
template<class Scalar> struct EclEpsScalingPointsInfo;
class EDITNNC;
class EndpointScaling;
class Equil;
@ -304,6 +305,10 @@ std::size_t packSize(const WaterPvtThermal<Scalar>& data, Dune::MPIHelper::MPICo
template<class T>
std::size_t packSize(const IOrderSet<T>& data, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
std::size_t packSize(const EclEpsScalingPointsInfo<Scalar>& data,
Dune::MPIHelper::MPICommunicator comm);
////// pack routines
template<class T>
@ -464,6 +469,10 @@ template<class T>
void pack(const IOrderSet<T>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void pack(const EclEpsScalingPointsInfo<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
void pack(const char* str, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
@ -623,6 +632,10 @@ template<class T>
void unpack(IOrderSet<T>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void unpack(EclEpsScalingPointsInfo<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);

View File

@ -25,6 +25,7 @@
#include <boost/test/unit_test.hpp>
#include <opm/common/OpmLog/Location.hpp>
#include <opm/material/fluidmatrixinteractions/EclEpsScalingPoints.hpp>
#include <opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp>
@ -2526,6 +2527,20 @@ BOOST_AUTO_TEST_CASE(FaultCollection)
}
BOOST_AUTO_TEST_CASE(EclEpsScalingPointsInfo)
{
#ifdef HAVE_MPI
Opm::EclEpsScalingPointsInfo<double> val1{ 1.0, 2.0, 3.0, 4.0, 5.0,
6.0, 7.0, 8.0, 9.0, 10.0,
11.0, 12.0, 13.0, 14.0, 15.0,
16.0, 17.0, 18.0, 19.0, 20.0, 21};
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;