add mpi serialization for IntervalTabulated2DFunction

This commit is contained in:
Arne Morten Kvarving
2019-12-04 11:12:51 +01:00
parent 6fde7dcb47
commit f2640197be
3 changed files with 78 additions and 0 deletions

View File

@@ -570,6 +570,23 @@ std::size_t packSize(const SolventPvt<Scalar>& data,
template std::size_t packSize(const SolventPvt<double>& data,
Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
std::size_t packSize(const IntervalTabulated2DFunction<Scalar>& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.xPos(), comm) +
packSize(data.yPos(), comm) +
packSize(data.samples(), comm) +
packSize(data.xExtrapolate(), comm) +
packSize(data.yExtrapolate(), comm);
}
template std::size_t packSize(const IntervalTabulated2DFunction<double>& data,
Dune::MPIHelper::MPICommunicator comm);
template std::size_t packSize(const std::map<int,IntervalTabulated2DFunction<double>>& data,
Dune::MPIHelper::MPICommunicator comm);
////// pack routines
template<class T>
@@ -1108,6 +1125,21 @@ void pack(const Tabulated1DFunction<Scalar>& data, std::vector<char>& buffer,
template void pack(const Tabulated1DFunction<double>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void pack(const IntervalTabulated2DFunction<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm)
{
pack(data.xPos(), buffer, position, comm);
pack(data.yPos(), buffer, position, comm);
pack(data.samples(), buffer, position, comm);
pack(data.xExtrapolate(), buffer, position, comm);
pack(data.yExtrapolate(), buffer, position, comm);
}
template void pack(const IntervalTabulated2DFunction<double>& data,
std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void pack(const SolventPvt<Scalar>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
@@ -1822,6 +1854,26 @@ void unpack(Tabulated1DFunction<Scalar>& data, std::vector<char>& buffer,
template void unpack(Tabulated1DFunction<double>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void unpack(IntervalTabulated2DFunction<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm)
{
std::vector<Scalar> xPos, yPos;
std::vector<std::vector<Scalar>> samples;
bool xExtrapolate, yExtrapolate;
unpack(xPos, buffer, position, comm);
unpack(yPos, buffer, position, comm);
unpack(samples, buffer, position, comm);
unpack(xExtrapolate, buffer, position, comm);
unpack(yExtrapolate, buffer, position, comm);
data = IntervalTabulated2DFunction<Scalar>(xPos, yPos, samples,
xExtrapolate, yExtrapolate);
}
template void unpack(IntervalTabulated2DFunction<double>& data,
std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void unpack(SolventPvt<Scalar>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)

View File

@@ -24,6 +24,7 @@
#endif
#include <opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp>
#include <opm/material/common/IntervalTabulated2DFunction.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/output/eclipse/EclipseIO.hpp>
#include <opm/output/eclipse/Summary.hpp>
@@ -145,6 +146,9 @@ std::size_t packSize(const DynamicState<T>& data, Dune::MPIHelper::MPICommunicat
template<class Scalar>
std::size_t packSize(const Tabulated1DFunction<Scalar>& data, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
std::size_t packSize(const IntervalTabulated2DFunction<Scalar>& data, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
std::size_t packSize(const SolventPvt<Scalar>& data, Dune::MPIHelper::MPICommunicator comm);
@@ -207,6 +211,10 @@ template<class Scalar>
void pack(const Tabulated1DFunction<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void pack(const IntervalTabulated2DFunction<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void pack(const SolventPvt<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
@@ -273,6 +281,10 @@ template<class Scalar>
void unpack(Tabulated1DFunction<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void unpack(IntervalTabulated2DFunction<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void unpack(SolventPvt<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);

View File

@@ -981,6 +981,20 @@ BOOST_AUTO_TEST_CASE(TabulatedOneDFunction)
}
BOOST_AUTO_TEST_CASE(IntervalTabulatedTwoDFunction)
{
#ifdef HAVE_MPI
std::vector<double> xPos{1.0, 2.0};
std::vector<double> yPos{3.0, 4.0};
std::vector<std::vector<double>> samples{{1.0, 2.0}, {3.0, 4.0}};
Opm::IntervalTabulated2DFunction<double> val1(xPos, yPos, samples, true, true);
auto val2 = PackUnpack(val1);
BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2));
BOOST_CHECK(val1 == std::get<0>(val2));
#endif
}
BOOST_AUTO_TEST_CASE(SolventPvt)
{
#ifdef HAVE_MPI