add mpi serialization for LiveOilPvt

This commit is contained in:
Arne Morten Kvarving
2019-12-19 14:16:06 +01:00
parent 1a3f00f300
commit 30dde6f410
3 changed files with 119 additions and 0 deletions
+84
View File
@@ -725,6 +725,26 @@ std::size_t packSize(const DeadOilPvt<Scalar>& data,
template std::size_t packSize(const DeadOilPvt<double>& data,
Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
std::size_t packSize(const LiveOilPvt<Scalar>& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.gasReferenceDensity(), comm) +
packSize(data.oilReferenceDensity(), comm) +
packSize(data.inverseOilBTable(), comm) +
packSize(data.oilMuTable(), comm) +
packSize(data.inverseOilBMuTable(), comm) +
packSize(data.saturatedOilMuTable(), comm) +
packSize(data.inverseSaturatedOilBTable(), comm) +
packSize(data.inverseSaturatedOilBMuTable(), comm) +
packSize(data.saturatedGasDissolutionFactorTable(), comm) +
packSize(data.saturationPressure(), comm) +
packSize(data.vapPar2(), comm);
}
template std::size_t packSize(const LiveOilPvt<double>& data,
Dune::MPIHelper::MPICommunicator comm);
////// pack routines
template<class T>
@@ -1454,6 +1474,28 @@ template void pack(const DeadOilPvt<double>& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void pack(const LiveOilPvt<Scalar>& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.gasReferenceDensity(), buffer, position, comm);
pack(data.oilReferenceDensity(), buffer, position, comm);
pack(data.inverseOilBTable(), buffer, position, comm);
pack(data.oilMuTable(), buffer, position, comm);
pack(data.inverseOilBMuTable(), buffer, position, comm);
pack(data.saturatedOilMuTable(), buffer, position, comm);
pack(data.inverseSaturatedOilBTable(), buffer, position, comm);
pack(data.inverseSaturatedOilBMuTable(), buffer, position, comm);
pack(data.saturatedGasDissolutionFactorTable(), buffer, position, comm);
pack(data.saturationPressure(), buffer, position, comm);
pack(data.vapPar2(), buffer, position, comm);
}
template void pack(const LiveOilPvt<double>& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
/// unpack routines
template<class T>
@@ -2405,6 +2447,48 @@ template void unpack(DeadOilPvt<double>& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void unpack(LiveOilPvt<Scalar>& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
std::vector<Scalar> gasReferenceDensity, oilReferenceDensity;
using FuncVec = std::vector<typename LiveOilPvt<Scalar>::TabulatedOneDFunction>;
using FuncVec2 = std::vector<typename LiveOilPvt<Scalar>::TabulatedTwoDFunction>;
FuncVec2 inverseOilBTable, oilMuTable, inverseOilBMuTable;
FuncVec saturatedOilMuTable, inverseSaturatedOilBTable,
inverseSaturatedOilBMuTable,
saturatedGasDissolutionFactorTable, saturationPressure;
Scalar vapPar2;
unpack(gasReferenceDensity, buffer, position, comm);
unpack(oilReferenceDensity, buffer, position, comm);
unpack(inverseOilBTable, buffer, position, comm);
unpack(oilMuTable, buffer, position, comm);
unpack(inverseOilBMuTable, buffer, position, comm);
unpack(saturatedOilMuTable, buffer, position, comm);
unpack(inverseSaturatedOilBTable, buffer, position, comm);
unpack(inverseSaturatedOilBMuTable, buffer, position, comm);
unpack(saturatedGasDissolutionFactorTable, buffer, position, comm);
unpack(saturationPressure, buffer, position, comm);
unpack(vapPar2, buffer, position, comm);
data = LiveOilPvt<Scalar>(gasReferenceDensity,
oilReferenceDensity,
inverseOilBTable,
oilMuTable,
inverseOilBMuTable,
saturatedOilMuTable,
inverseSaturatedOilBTable,
inverseSaturatedOilBMuTable,
saturatedGasDissolutionFactorTable,
saturationPressure,
vapPar2);
}
template void unpack(LiveOilPvt<double>& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
} // end namespace Mpi
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
const std::vector<Opm::RestartKey>& solutionKeys,
+14
View File
@@ -30,6 +30,7 @@
#include <opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp>
#include <opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
@@ -187,6 +188,10 @@ template<class Scalar>
std::size_t packSize(const DeadOilPvt<Scalar>& data,
Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
std::size_t packSize(const LiveOilPvt<Scalar>& data,
Dune::MPIHelper::MPICommunicator comm);
////// pack routines
template<class T>
@@ -289,6 +294,11 @@ void pack(const DeadOilPvt<Scalar>& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void pack(const LiveOilPvt<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);
@@ -392,6 +402,10 @@ template<class Scalar>
void unpack(DeadOilPvt<Scalar>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
template<class Scalar>
void unpack(LiveOilPvt<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);
+21
View File
@@ -1099,6 +1099,27 @@ BOOST_AUTO_TEST_CASE(DeadOilPvt)
}
BOOST_AUTO_TEST_CASE(LiveOilPvt)
{
#ifdef HAVE_MPI
Opm::Tabulated1DFunction<double> func(2, std::vector<double>{1.0, 2.0},
std::vector<double>{3.0, 4.0});
std::vector<double> xPos{1.0, 2.0};
std::vector<double> yPos{3.0, 4.0};
using FFuncType = Opm::UniformXTabulated2DFunction<double>;
using Samples = std::vector<std::vector<FFuncType::SamplePoint>>;
Samples samples({{{1.0, 2.0, 3.0}, {3.0, 4.0, 5.0}}});
FFuncType func2(xPos, yPos, samples, FFuncType::Vertical);
Opm::LiveOilPvt<double> val1({1.0, 2.0}, {3.0, 4.0},
{func2}, {func2}, {func2},
{func}, {func}, {func}, {func}, {func}, 5.0);
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;