mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for WaterPvtMultiplexer and WaterPvtThermal
these are intermixed so kept in one commit
This commit is contained in:
parent
e56bbba99c
commit
1ab9a66bf4
@ -799,6 +799,29 @@ std::size_t packSize(const OilPvtThermal<Scalar>& data,
|
||||
template std::size_t packSize(const OilPvtThermal<double>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar, bool enableThermal>
|
||||
std::size_t packSize(const WaterPvtMultiplexer<Scalar,enableThermal>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::size_t size = packSize(data.approach(), comm);
|
||||
const void* realWaterPvt = data.realWaterPvt();
|
||||
using PvtApproach = WaterPvtMultiplexer<Scalar,enableThermal>;
|
||||
if (data.approach() == PvtApproach::ConstantCompressibilityWaterPvt) {
|
||||
const auto& pvt = *static_cast<const ConstantCompressibilityWaterPvt<Scalar>*>(realWaterPvt);
|
||||
size += packSize(pvt, comm);
|
||||
} else if (data.approach() == PvtApproach::ThermalWaterPvt) {
|
||||
const auto& pvt = *static_cast<const WaterPvtThermal<Scalar>*>(realWaterPvt);
|
||||
size += packSize(pvt, comm);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
template std::size_t packSize(const WaterPvtMultiplexer<double,true>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
template std::size_t packSize(const WaterPvtMultiplexer<double,false>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
std::size_t packSize(const ConstantCompressibilityWaterPvt<Scalar>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
@ -814,6 +837,34 @@ std::size_t packSize(const ConstantCompressibilityWaterPvt<Scalar>& data,
|
||||
template std::size_t packSize(const ConstantCompressibilityWaterPvt<double>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
std::size_t packSize(const WaterPvtThermal<Scalar>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::size_t size = packSize(data.viscrefPress(), comm) +
|
||||
packSize(data.watdentRefTemp(), comm) +
|
||||
packSize(data.watdentCT1(), comm) +
|
||||
packSize(data.watdentCT2(), comm) +
|
||||
packSize(data.pvtwRefPress(), comm) +
|
||||
packSize(data.pvtwRefB(), comm) +
|
||||
packSize(data.pvtwCompressibility(), comm) +
|
||||
packSize(data.pvtwViscosity(), comm) +
|
||||
packSize(data.pvtwViscosibility(), comm) +
|
||||
packSize(data.watvisctCurves(), comm) +
|
||||
packSize(data.internalEnergyCurves(), comm) +
|
||||
packSize(data.enableThermalDensity(), comm) +
|
||||
packSize(data.enableThermalViscosity(), comm) +
|
||||
packSize(data.enableInternalEnergy(), comm);
|
||||
size += packSize(bool(), comm);
|
||||
if (data.isoThermalPvt())
|
||||
size += packSize(*data.isoThermalPvt(), comm);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
template std::size_t packSize(const WaterPvtThermal<double>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -1620,6 +1671,30 @@ template void pack(const OilPvtThermal<double>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar, bool enableThermal>
|
||||
void pack(const WaterPvtMultiplexer<Scalar,enableThermal>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.approach(), buffer, position, comm);
|
||||
const void* realWaterPvt = data.realWaterPvt();
|
||||
using PvtApproach = WaterPvtMultiplexer<Scalar,enableThermal>;
|
||||
if (data.approach() == PvtApproach::ConstantCompressibilityWaterPvt) {
|
||||
const auto& pvt = *static_cast<const ConstantCompressibilityWaterPvt<Scalar>*>(realWaterPvt);
|
||||
pack(pvt, buffer, position, comm);
|
||||
} else if (data.approach() == PvtApproach::ThermalWaterPvt) {
|
||||
const auto& pvt = *static_cast<const WaterPvtThermal<Scalar>*>(realWaterPvt);
|
||||
pack(pvt, buffer, position, comm);
|
||||
}
|
||||
}
|
||||
|
||||
template void pack(const WaterPvtMultiplexer<double,true>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
template void pack(const WaterPvtMultiplexer<double,false>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
void pack(const ConstantCompressibilityWaterPvt<Scalar>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
@ -1637,6 +1712,34 @@ template void pack(const ConstantCompressibilityWaterPvt<double>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
void pack(const WaterPvtThermal<Scalar>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.viscrefPress(), buffer, position, comm);
|
||||
pack(data.watdentRefTemp(), buffer, position, comm);
|
||||
pack(data.watdentCT1(), buffer, position, comm);
|
||||
pack(data.watdentCT2(), buffer, position, comm);
|
||||
pack(data.pvtwRefPress(), buffer, position, comm);
|
||||
pack(data.pvtwRefB(), buffer, position, comm);
|
||||
pack(data.pvtwCompressibility(), buffer, position, comm);
|
||||
pack(data.pvtwViscosity(), buffer, position, comm);
|
||||
pack(data.pvtwViscosibility(), buffer, position, comm);
|
||||
pack(data.watvisctCurves(), buffer, position, comm);
|
||||
pack(data.internalEnergyCurves(), buffer, position, comm);
|
||||
pack(data.enableThermalDensity(), buffer, position, comm);
|
||||
pack(data.enableThermalViscosity(), buffer, position, comm);
|
||||
pack(data.enableInternalEnergy(), buffer, position, comm);
|
||||
pack(data.isoThermalPvt() != nullptr, buffer, position, comm);
|
||||
if (data.isoThermalPvt())
|
||||
pack(*data.isoThermalPvt(), buffer, position, comm);
|
||||
}
|
||||
|
||||
template void pack(const WaterPvtThermal<double>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -2707,6 +2810,34 @@ template void unpack(OilPvtThermal<double>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar, bool enableThermal>
|
||||
void unpack(WaterPvtMultiplexer<Scalar,enableThermal>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
typename WaterPvtMultiplexer<Scalar,enableThermal>::WaterPvtApproach approach;
|
||||
unpack(approach, buffer, position, comm);
|
||||
using PvtApproach = WaterPvtMultiplexer<Scalar,enableThermal>;
|
||||
void* pvt = nullptr;
|
||||
if (approach == PvtApproach::ConstantCompressibilityWaterPvt) {
|
||||
auto* realPvt = new ConstantCompressibilityWaterPvt<Scalar>;
|
||||
unpack(*realPvt, buffer, position, comm);
|
||||
pvt = realPvt;
|
||||
} else if (data.approach() == PvtApproach::ThermalWaterPvt) {
|
||||
auto* realPvt = new WaterPvtThermal<Scalar>;
|
||||
unpack(*realPvt, buffer, position, comm);
|
||||
pvt = realPvt;
|
||||
}
|
||||
data = WaterPvtMultiplexer<Scalar,enableThermal>(approach, pvt);
|
||||
}
|
||||
|
||||
template void unpack(WaterPvtMultiplexer<double,true>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
template void unpack(WaterPvtMultiplexer<double,false>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
void unpack(ConstantCompressibilityWaterPvt<Scalar>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
@ -2734,6 +2865,55 @@ template void unpack(ConstantCompressibilityWaterPvt<double>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
void unpack(WaterPvtThermal<Scalar>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::vector<Scalar> viscrefPress, watdentRefTemp, watdentCT1, watdentCT2,
|
||||
pvtwRefPress, pvtwRefB, pvtwCompressibility,
|
||||
pvtwViscosity, pvtwViscosibility;
|
||||
std::vector<typename WaterPvtThermal<Scalar>::TabulatedOneDFunction> watvisctCurves;
|
||||
std::vector<typename WaterPvtThermal<Scalar>::TabulatedOneDFunction> internalEnergyCurves;
|
||||
bool enableThermalDensity, enableThermalViscosity, enableInternalEnergy;
|
||||
unpack(viscrefPress, buffer, position, comm);
|
||||
unpack(watdentRefTemp, buffer, position, comm);
|
||||
unpack(watdentCT1, buffer, position, comm);
|
||||
unpack(watdentCT2, buffer, position, comm);
|
||||
unpack(pvtwRefPress, buffer, position, comm);
|
||||
unpack(pvtwRefB, buffer, position, comm);
|
||||
unpack(pvtwCompressibility, buffer, position, comm);
|
||||
unpack(pvtwViscosity, buffer, position, comm);
|
||||
unpack(pvtwViscosibility, buffer, position, comm);
|
||||
unpack(watvisctCurves, buffer, position, comm);
|
||||
unpack(internalEnergyCurves, buffer, position, comm);
|
||||
unpack(enableThermalDensity, buffer, position, comm);
|
||||
unpack(enableThermalViscosity, buffer, position, comm);
|
||||
unpack(enableInternalEnergy, buffer, position, comm);
|
||||
bool isothermal;
|
||||
unpack(isothermal, buffer, position, comm);
|
||||
typename WaterPvtThermal<Scalar>::IsothermalPvt* pvt = nullptr;
|
||||
if (isothermal) {
|
||||
pvt = new typename WaterPvtThermal<Scalar>::IsothermalPvt;
|
||||
unpack(*pvt, buffer, position, comm);
|
||||
}
|
||||
data = WaterPvtThermal<Scalar>(pvt, viscrefPress, watdentRefTemp,
|
||||
watdentCT1, watdentCT2,
|
||||
pvtwRefPress, pvtwRefB,
|
||||
pvtwCompressibility,
|
||||
pvtwViscosity,
|
||||
pvtwViscosibility,
|
||||
watvisctCurves,
|
||||
internalEnergyCurves,
|
||||
enableThermalDensity,
|
||||
enableThermalViscosity,
|
||||
enableInternalEnergy);
|
||||
}
|
||||
|
||||
template void unpack(WaterPvtThermal<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,
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp>
|
||||
#include <opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp>
|
||||
#include <opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp>
|
||||
#include <opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.hpp>
|
||||
#include <opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp>
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
#include <opm/output/eclipse/EclipseIO.hpp>
|
||||
@ -201,10 +202,17 @@ std::size_t packSize(const LiveOilPvt<Scalar>& data,
|
||||
template<class Scalar>
|
||||
std::size_t packSize(const OilPvtThermal<Scalar>& data, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar, bool enableThermal>
|
||||
std::size_t packSize(const WaterPvtMultiplexer<Scalar,enableThermal>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
std::size_t packSize(const ConstantCompressibilityWaterPvt<Scalar>& data,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
std::size_t packSize(const WaterPvtThermal<Scalar>& data, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -321,11 +329,20 @@ template<class Scalar>
|
||||
void pack(const OilPvtThermal<Scalar>& data, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar, bool enableThermal>
|
||||
void pack(const WaterPvtMultiplexer<Scalar,enableThermal>& data,
|
||||
const std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
void pack(const ConstantCompressibilityWaterPvt<Scalar>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
void pack(const WaterPvtThermal<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);
|
||||
|
||||
@ -442,6 +459,15 @@ template<class Scalar>
|
||||
void unpack(OilPvtThermal<Scalar>& data, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar, bool enableThermal>
|
||||
void unpack(WaterPvtMultiplexer<Scalar,enableThermal>& data,
|
||||
const std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
void unpack(WaterPvtThermal<Scalar>& data, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class Scalar>
|
||||
void unpack(ConstantCompressibilityWaterPvt<Scalar>& data, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
@ -1148,6 +1148,23 @@ BOOST_AUTO_TEST_CASE(ConstantCompressibilityWaterPvt)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(WaterPvtThermal)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
Opm::Tabulated1DFunction<double> func(2, std::vector<double>{1.0, 2.0},
|
||||
std::vector<double>{3.0, 4.0});
|
||||
Opm::WaterPvtThermal<double>::IsothermalPvt* pvt = new Opm::WaterPvtThermal<double>::IsothermalPvt;
|
||||
Opm::WaterPvtThermal<double> val1(pvt, {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},
|
||||
{func}, {func}, true, true, false);
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user