/*
Copyright 2019 Equinor AS.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see .
*/
#include
#if HAVE_MPI
#include
#endif
#include "ParallelRestart.hpp"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define HANDLE_AS_POD(T) \
std::size_t packSize(const T& data, Dune::MPIHelper::MPICommunicator comm) \
{ \
return packSize(data, comm, std::integral_constant()); \
} \
void pack(const T& data, std::vector& buffer, int& position, \
Dune::MPIHelper::MPICommunicator comm) \
{ \
pack(data, buffer, position, comm, std::integral_constant()); \
} \
void unpack(T& data, std::vector& buffer, int& position, \
Dune::MPIHelper::MPICommunicator comm) \
{ \
unpack(data, buffer, position, comm, std::integral_constant()); \
}
namespace Opm
{
namespace Mpi
{
template
std::size_t packSize(const T*, std::size_t, Dune::MPIHelper::MPICommunicator,
std::integral_constant)
{
OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type.");
}
template
std::size_t packSize(const T*, std::size_t l, Dune::MPIHelper::MPICommunicator comm,
std::integral_constant)
{
#if HAVE_MPI
int size;
MPI_Pack_size(1, Dune::MPITraits::getType(), comm, &size);
std::size_t totalSize = size;
MPI_Pack_size(l, Dune::MPITraits::getType(), comm, &size);
return totalSize + size;
#else
(void) comm;
return l-l;
#endif
}
template
std::size_t packSize(const T* data, std::size_t l, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data, l, comm, typename std::is_pod::type());
}
template
std::size_t packSize(const T&, Dune::MPIHelper::MPICommunicator,
std::integral_constant)
{
OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type.");
}
template
std::size_t packSize(const T&, Dune::MPIHelper::MPICommunicator comm,
std::integral_constant)
{
#if HAVE_MPI
int size{};
MPI_Pack_size(1, Dune::MPITraits::getType(), comm, &size);
return size;
#else
(void) comm;
return 0;
#endif
}
template
std::size_t packSize(const T& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data, comm, typename std::is_pod::type());
}
template
std::size_t packSize(const std::pair& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.first, comm) + packSize(data.second, comm);
}
template
std::size_t packSize(const std::vector& data, Dune::MPIHelper::MPICommunicator comm)
{
if (std::is_pod::value)
// size written automatically
return packSize(data.data(), data.size(), comm);
std::size_t size = packSize(data.size(), comm);
for (const auto& entry: data)
size+=packSize(entry, comm);
return size;
}
template
std::size_t packSize(const std::vector& data, Dune::MPIHelper::MPICommunicator comm)
{
bool entry;
return packSize(data.size(), comm) + data.size()*packSize(entry,comm);
}
template
typename std::enable_if::value, std::size_t>::type
pack_size_tuple_entry(const Tuple&, Dune::MPIHelper::MPICommunicator)
{
return 0;
}
template
typename std::enable_if::value, std::size_t>::type
pack_size_tuple_entry(const Tuple& tuple, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(std::get(tuple), comm) + pack_size_tuple_entry(tuple, comm);
}
template
std::size_t packSize(const std::tuple& data, Dune::MPIHelper::MPICommunicator comm)
{
return pack_size_tuple_entry(data, comm);
}
template
std::size_t packSize(const OrderedMap& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getIndex(), comm) + packSize(data.getStorage(), comm);
}
template
std::size_t packSize(const DynamicState& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.data(), comm) + packSize(data.initialRange(), comm);
}
template
std::size_t packSize(const DynamicVector& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.data(), comm);
}
std::size_t packSize(const char* str, Dune::MPIHelper::MPICommunicator comm)
{
#if HAVE_MPI
int size;
MPI_Pack_size(1, Dune::MPITraits::getType(), comm, &size);
int totalSize = size;
MPI_Pack_size(strlen(str)+1, MPI_CHAR, comm, &size);
return totalSize + size;
#else
(void) str;
(void) comm;
return 0;
#endif
}
std::size_t packSize(const std::string& str, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(str.c_str(), comm);
}
template
std::size_t packSize(const std::map& data, Dune::MPIHelper::MPICommunicator comm)
{
std::size_t totalSize = packSize(data.size(), comm);
for (const auto& entry: data)
{
totalSize += packSize(entry, comm);
}
return totalSize;
}
template
std::size_t packSize(const std::unordered_map& data, Dune::MPIHelper::MPICommunicator comm)
{
std::size_t totalSize = packSize(data.size(), comm);
for (const auto& entry: data)
{
totalSize += packSize(entry, comm);
}
return totalSize;
}
HANDLE_AS_POD(Actdims)
HANDLE_AS_POD(Aqudims)
HANDLE_AS_POD(data::Connection)
HANDLE_AS_POD(data::Rates)
HANDLE_AS_POD(data::Segment)
HANDLE_AS_POD(DENSITYRecord)
HANDLE_AS_POD(EclHysterConfig)
HANDLE_AS_POD(Eqldims)
HANDLE_AS_POD(EquilRecord)
HANDLE_AS_POD(FoamData)
HANDLE_AS_POD(JFunc)
HANDLE_AS_POD(MLimits)
HANDLE_AS_POD(PVTWRecord)
HANDLE_AS_POD(PVCDORecord)
HANDLE_AS_POD(Regdims)
HANDLE_AS_POD(RestartSchedule)
HANDLE_AS_POD(ROCKRecord)
HANDLE_AS_POD(Tabdims)
HANDLE_AS_POD(TimeMap::StepData)
HANDLE_AS_POD(VISCREFRecord)
HANDLE_AS_POD(WATDENTRecord)
HANDLE_AS_POD(Well::WellGuideRate)
HANDLE_AS_POD(Welldims)
HANDLE_AS_POD(WellFoamProperties)
HANDLE_AS_POD(WellPolymerProperties)
HANDLE_AS_POD(WellSegmentDims)
std::size_t packSize(const data::Well& data, Dune::MPIHelper::MPICommunicator comm)
{
std::size_t size = packSize(data.rates, comm);
size += packSize(data.bhp, comm) + packSize(data.thp, comm);
size += packSize(data.temperature, comm);
size += packSize(data.control, comm);
size += packSize(data.connections, comm);
size += packSize(data.segments, comm);
return size;
}
std::size_t packSize(const data::CellData& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.dim, comm) + packSize(data.data, comm) + packSize(data.target, comm);
}
std::size_t packSize(const RestartKey& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.key, comm) + packSize(data.dim, comm) + packSize(data.required, comm);
}
std::size_t packSize(const data::Solution& data, Dune::MPIHelper::MPICommunicator comm)
{
// Needs explicit conversion to a supported base type holding the data
// to prevent throwing.
return packSize(static_cast&>(data), comm);
}
std::size_t packSize(const data::WellRates& data, Dune::MPIHelper::MPICommunicator comm)
{
// Needs explicit conversion to a supported base type holding the data
// to prevent throwing.
return packSize(static_cast&>(data), comm);
}
std::size_t packSize(const RestartValue& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.solution, comm) + packSize(data.wells, comm) + packSize(data.extra, comm);
}
std::size_t packSize(const ThresholdPressure& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.active(), comm) +
packSize(data.restart(), comm) +
packSize(data.thresholdPressureTable(), comm) +
packSize(data.pressureTable(), comm);
}
std::size_t packSize(const NNC& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.data(), comm);
}
std::size_t packSize(const EDITNNC& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.data(), comm);
}
std::size_t packSize(const Rock2dTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.pvmultValues(), comm) +
packSize(data.pressureValues(), comm);
}
std::size_t packSize(const Rock2dtrTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.transMultValues(), comm) +
packSize(data.pressureValues(), comm);
}
std::size_t packSize(const ColumnSchema& data, Dune::MPIHelper::MPICommunicator comm)
{
std::size_t res = packSize(data.name(), comm) +
packSize(data.order(), comm) +
packSize(data.getDefaultMode(), comm);
if (data.getDefaultMode() == Table::DEFAULT_CONST) {
res += packSize(data.getDefaultValue(), comm);
}
return res;
}
std::size_t packSize(const TableSchema& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getColumns(), comm);
}
std::size_t packSize(const TableColumn& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.schema(), comm) +
packSize(data.name(), comm) +
packSize(data.values(), comm) +
packSize(data.defaults(), comm) +
packSize(data.defaultCount(), comm);
}
std::size_t packSize(const SimpleTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.schema(), comm) +
packSize(data.columns(), comm) +
packSize(data.jfunc(), comm);
}
std::size_t packSize(const TableContainer& data, Dune::MPIHelper::MPICommunicator comm)
{
size_t res = 2*packSize(data.max(), comm);
for (const auto& it : data.tables()) {
if (it.second) {
res += packSize(it.first, comm) + packSize(*it.second, comm);
}
}
return res;
}
std::size_t packSize(const Equil& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.records(), comm);
}
std::size_t packSize(const FoamConfig& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.records(), comm);
}
std::size_t packSize(const InitConfig& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getEquil(), comm) +
packSize(data.getFoamConfig(), comm) +
packSize(data.filleps(), comm) +
packSize(data.restartRequested(), comm) +
packSize(data.getRestartStep(), comm) +
packSize(data.getRestartRootName(), comm);
}
std::size_t packSize(const SimulationConfig& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getThresholdPressure(), comm) +
packSize(data.useCPR(), comm) +
packSize(data.hasDISGAS(), comm) +
packSize(data.hasVAPOIL(), comm) +
packSize(data.isThermal(), comm);
}
std::size_t packSize(const TimeMap& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.timeList(), comm) +
packSize(data.firstTimeStepMonths(), comm) +
packSize(data.firstTimeStepYears(), comm);
}
std::size_t packSize(const RestartConfig& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.timeMap(), comm) +
packSize(data.getFirstRestartStep(), comm) +
packSize(data.writeInitialRst(), comm) +
packSize(data.restartSchedule(), comm) +
packSize(data.restartKeywords(), comm) +
packSize(data.saveKeywords(), comm);
}
std::size_t packSize(const IOConfig& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getWriteINITFile(), comm) +
packSize(data.getWriteEGRIDFile(), comm) +
packSize(data.getUNIFIN(), comm) +
packSize(data.getUNIFOUT(), comm) +
packSize(data.getFMTIN(), comm) +
packSize(data.getFMTOUT(), comm) +
packSize(data.getFirstRestartStep(), comm) +
packSize(data.getDeckFileName(), comm) +
packSize(data.getOutputEnabled(), comm) +
packSize(data.getOutputDir(), comm) +
packSize(data.getNoSim(), comm) +
packSize(data.getBaseName(), comm) +
packSize(data.getEclCompatibleRST(), comm);
}
std::size_t packSize(const Phases& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getBits(), comm);
}
std::size_t packSize(const EndpointScaling& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getBits(), comm);
}
std::size_t packSize(const UDQParams& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.reseed(), comm) +
packSize(data.rand_seed(), comm) +
packSize(data.range(), comm) +
packSize(data.undefinedValue(), comm) +
packSize(data.cmpEpsilon(), comm);
}
std::size_t packSize(const Runspec& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.phases(), comm) +
packSize(data.tabdims(), comm) +
packSize(data.endpointScaling(), comm) +
packSize(data.wellDimensions(), comm) +
packSize(data.wellSegmentDimensions(), comm) +
packSize(data.udqParams(), comm) +
packSize(data.hysterPar(), comm) +
packSize(data.actdims(), comm);
}
std::size_t packSize(const PvtxTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getOuterColumnSchema(), comm) +
packSize(data.getOuterColumn(), comm) +
packSize(data.getUnderSaturatedSchema(), comm) +
packSize(data.getSaturatedSchema(), comm) +
packSize(data.getUnderSaturatedTables(), comm) +
packSize(data.getSaturatedTable(), comm);
}
std::size_t packSize(const PvtgTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast(data), comm);
}
std::size_t packSize(const PvtoTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast(data), comm);
}
std::size_t packSize(const PvtwTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast&>(data), comm);
}
std::size_t packSize(const PvcdoTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast&>(data), comm);
}
std::size_t packSize(const DensityTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast&>(data), comm);
}
std::size_t packSize(const ViscrefTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast&>(data), comm);
}
std::size_t packSize(const WatdentTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast&>(data), comm);
}
std::size_t packSize(const PolyInjTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getThroughputs(), comm) +
packSize(data.getVelocities(), comm) +
packSize(data.getTableNumber(), comm) +
packSize(data.getTableData(), comm);
}
std::size_t packSize(const PlymwinjTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast(data), comm);
}
std::size_t packSize(const SkprpolyTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast(data), comm) +
packSize(data.referenceConcentration(), comm);
}
std::size_t packSize(const SkprwatTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast(data), comm);
}
std::size_t packSize(const RockTable& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(static_cast&>(data), comm);
}
std::size_t packSize(const TableManager& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getSimpleTables(), comm) +
packSize(data.getPvtgTables(), comm) +
packSize(data.getPvtoTables(), comm) +
packSize(data.getRock2dTables(), comm) +
packSize(data.getRock2dtrTables(), comm) +
packSize(data.getPvtwTable(), comm) +
packSize(data.getPvcdoTable(), comm) +
packSize(data.getDensityTable(), comm) +
packSize(data.getRockTable(), comm) +
packSize(data.getViscrefTable(), comm) +
packSize(data.getWatdentTable(), comm) +
packSize(data.getPlymwinjTables(), comm) +
packSize(data.getSkprwatTables(), comm) +
packSize(data.getSkprpolyTables(), comm) +
packSize(data.getTabdims(), comm) +
packSize(data.getRegdims(), comm) +
packSize(data.getEqldims(), comm) +
packSize(data.getAqudims(), comm) +
packSize(data.useImptvd(), comm) +
packSize(data.useEnptvd(), comm) +
packSize(data.useEqlnum(), comm) +
packSize(data.useJFunc(), comm) +
(data.useJFunc() ? packSize(data.getJFunc(), comm) : 0) +
packSize(data.rtemp(), comm);
}
template
std::size_t packSize(const Tabulated1DFunction& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.xValues(), comm) +
packSize(data.yValues(), comm);
}
template std::size_t packSize(const Tabulated1DFunction& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const SolventPvt& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.solventReferenceDensity(), comm) +
packSize(data.inverseSolventB(), comm) +
packSize(data.solventMu(), comm) +
packSize(data.inverseSolventBMu(), comm);
}
template std::size_t packSize(const SolventPvt& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const IntervalTabulated2DFunction& 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& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const UniformXTabulated2DFunction& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.xPos(), comm) +
packSize(data.yPos(), comm) +
packSize(data.samples(), comm) +
packSize(data.interpolationGuide(), comm);
}
template std::size_t packSize(const UniformXTabulated2DFunction& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const DryGasPvt& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.gasReferenceDensity(), comm) +
packSize(data.inverseGasB(), comm) +
packSize(data.gasMu(), comm) +
packSize(data.inverseGasBMu(), comm);
}
template std::size_t packSize(const DryGasPvt& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const GasPvtThermal& data,
Dune::MPIHelper::MPICommunicator comm)
{
std::size_t size = packSize(data.gasvisctCurves(), comm) +
packSize(data.gasdentRefTemp(), comm) +
packSize(data.gasdentCT1(), comm) +
packSize(data.gasdentCT2(), 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 GasPvtThermal& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const GasPvtMultiplexer& data,
Dune::MPIHelper::MPICommunicator comm)
{
std::size_t size = packSize(data.gasPvtApproach(), comm);
const void* realGasPvt = data.realGasPvt();
using PvtApproach = GasPvtMultiplexer;
if (data.gasPvtApproach() == PvtApproach::DryGasPvt) {
const auto& pvt = *static_cast*>(realGasPvt);
size += packSize(pvt, comm);
} else if (data.gasPvtApproach() == PvtApproach::WetGasPvt) {
const auto& pvt = *static_cast*>(realGasPvt);
size += packSize(pvt, comm);
} else if (data.gasPvtApproach() == PvtApproach::ThermalGasPvt) {
const auto& pvt = *static_cast*>(realGasPvt);
size += packSize(pvt, comm);
}
return size;
}
template std::size_t packSize(const GasPvtMultiplexer& data,
Dune::MPIHelper::MPICommunicator comm);
template std::size_t packSize(const GasPvtMultiplexer& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const WetGasPvt& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.gasReferenceDensity(), comm) +
packSize(data.oilReferenceDensity(), comm) +
packSize(data.inverseGasB(), comm) +
packSize(data.inverseSaturatedGasB(), comm) +
packSize(data.gasMu(), comm) +
packSize(data.inverseGasBMu(), comm) +
packSize(data.inverseSaturatedGasBMu(), comm) +
packSize(data.saturatedOilVaporizationFactorTable(), comm) +
packSize(data.saturationPressure(), comm) +
packSize(data.vapPar1(), comm);
}
template std::size_t packSize(const WetGasPvt& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const OilPvtMultiplexer& data,
Dune::MPIHelper::MPICommunicator comm)
{
std::size_t size = packSize(data.approach(), comm);
const void* realOilPvt = data.realOilPvt();
using PvtApproach = OilPvtMultiplexer;
if (data.approach() == PvtApproach::ConstantCompressibilityOilPvt) {
const auto& pvt = *static_cast*>(realOilPvt);
size += packSize(pvt, comm);
} else if (data.approach() == PvtApproach::DeadOilPvt) {
const auto& pvt = *static_cast*>(realOilPvt);
size += packSize(pvt, comm);
} else if (data.approach() == PvtApproach::LiveOilPvt) {
const auto& pvt = *static_cast*>(realOilPvt);
size += packSize(pvt, comm);
} else if (data.approach() == PvtApproach::ThermalOilPvt) {
const auto& pvt = *static_cast*>(realOilPvt);
size += packSize(pvt, comm);
}
return size;
}
template std::size_t packSize(const OilPvtMultiplexer& data,
Dune::MPIHelper::MPICommunicator comm);
template std::size_t packSize(const OilPvtMultiplexer& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const ConstantCompressibilityOilPvt& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.oilReferenceDensity(), comm) +
packSize(data.oilReferencePressure(), comm) +
packSize(data.oilReferenceFormationVolumeFactor(), comm) +
packSize(data.oilCompressibility(), comm) +
packSize(data.oilViscosity(), comm) +
packSize(data.oilViscosibility(), comm);
}
template std::size_t packSize(const ConstantCompressibilityOilPvt& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const DeadOilPvt& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.oilReferenceDensity(), comm) +
packSize(data.inverseOilB(), comm) +
packSize(data.oilMu(), comm) +
packSize(data.inverseOilBMu(), comm);
}
template std::size_t packSize(const DeadOilPvt& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const LiveOilPvt& 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& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const OilPvtThermal& data,
Dune::MPIHelper::MPICommunicator comm)
{
std::size_t size = packSize(data.oilvisctCurves(), comm) +
packSize(data.viscrefPress(), comm) +
packSize(data.viscrefRs(), comm) +
packSize(data.viscRef(), comm) +
packSize(data.oildentRefTemp(), comm) +
packSize(data.oildentCT1(), comm) +
packSize(data.oildentCT2(), 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 OilPvtThermal& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const WaterPvtMultiplexer& data,
Dune::MPIHelper::MPICommunicator comm)
{
std::size_t size = packSize(data.approach(), comm);
const void* realWaterPvt = data.realWaterPvt();
using PvtApproach = WaterPvtMultiplexer;
if (data.approach() == PvtApproach::ConstantCompressibilityWaterPvt) {
const auto& pvt = *static_cast*>(realWaterPvt);
size += packSize(pvt, comm);
} else if (data.approach() == PvtApproach::ThermalWaterPvt) {
const auto& pvt = *static_cast*>(realWaterPvt);
size += packSize(pvt, comm);
}
return size;
}
template std::size_t packSize(const WaterPvtMultiplexer& data,
Dune::MPIHelper::MPICommunicator comm);
template std::size_t packSize(const WaterPvtMultiplexer& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const ConstantCompressibilityWaterPvt& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.waterReferenceDensity(), comm) +
packSize(data.waterReferencePressure(), comm) +
packSize(data.waterReferenceFormationVolumeFactor(), comm) +
packSize(data.waterCompressibility(), comm) +
packSize(data.waterViscosity(), comm) +
packSize(data.waterViscosibility(), comm);
}
template std::size_t packSize(const ConstantCompressibilityWaterPvt& data,
Dune::MPIHelper::MPICommunicator comm);
template
std::size_t packSize(const WaterPvtThermal& 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& data,
Dune::MPIHelper::MPICommunicator comm);
std::size_t packSize(const OilVaporizationProperties& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getType(), comm) +
packSize(data.vap1(), comm) +
packSize(data.vap2(), comm) +
packSize(data.maxDRSDT(), comm) +
packSize(data.maxDRSDT_allCells(), comm) +
packSize(data.maxDRVDT(), comm);
}
std::size_t packSize(const Events& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.events(), comm);
}
std::size_t packSize(const MessageLimits& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getLimits(), comm);
}
std::size_t packSize(const VFPInjTable& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getTableNum(), comm) +
packSize(data.getDatumDepth(), comm) +
packSize(data.getFloType(), comm) +
packSize(data.getFloAxis(), comm) +
packSize(data.getTHPAxis(), comm) +
data.getTable().num_elements() *
packSize(double(), comm);
}
std::size_t packSize(const VFPProdTable& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getTableNum(), comm) +
packSize(data.getDatumDepth(), comm) +
packSize(data.getFloType(), comm) +
packSize(data.getWFRType(), comm) +
packSize(data.getGFRType(), comm) +
packSize(data.getALQType(), comm) +
packSize(data.getFloAxis(), comm) +
packSize(data.getTHPAxis(), comm) +
packSize(data.getWFRAxis(), comm) +
packSize(data.getGFRAxis(), comm) +
packSize(data.getALQAxis(), comm) +
data.getTable().num_elements() *
packSize(double(), comm);
}
std::size_t packSize(const WellTestConfig::WTESTWell& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.name, comm) +
packSize(data.shut_reason, comm) +
packSize(data.test_interval, comm) +
packSize(data.num_test, comm) +
packSize(data.startup_time, comm) +
packSize(data.begin_report_step, comm);
}
std::size_t packSize(const WellTestConfig& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getWells(), comm);
}
std::size_t packSize(const WellTracerProperties& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getConcentrations(), comm);
}
std::size_t packSize(const UDAValue& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.is(), comm) +
(data.is() ? packSize(data.get(), comm) :
packSize(data.get(), comm));
}
std::size_t packSize(const Connection& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.dir(), comm) +
packSize(data.depth(), comm) +
packSize(data.state(), comm) +
packSize(data.satTableId(), comm) +
packSize(data.complnum(), comm) +
packSize(data.CF(), comm) +
packSize(data.Kh(), comm) +
packSize(data.rw(), comm) +
packSize(data.r0(), comm) +
packSize(data.skinFactor(), comm) +
packSize(data.getI(), comm) +
packSize(data.getJ(), comm) +
packSize(data.getK(), comm) +
packSize(data.getSeqIndex(), comm) +
packSize(data.getSegDistStart(), comm) +
packSize(data.getSegDistEnd(), comm) +
packSize(data.getDefaultSatTabId(), comm) +
packSize(data.getCompSegSeqIndex(), comm) +
packSize(data.segment(), comm) +
packSize(data.wellPi(), comm);
}
std::size_t packSize(const Well::WellInjectionProperties& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.name, comm) +
packSize(data.surfaceInjectionRate, comm) +
packSize(data.reservoirInjectionRate, comm) +
packSize(data.BHPLimit, comm) +
packSize(data.THPLimit, comm) +
packSize(data.temperature, comm) +
packSize(data.BHPH, comm) +
packSize(data.THPH, comm) +
packSize(data.VFPTableNumber, comm) +
packSize(data.predictionMode, comm) +
packSize(data.injectionControls, comm) +
packSize(data.injectorType, comm) +
packSize(data.controlMode, comm);
}
std::size_t packSize(const WellEconProductionLimits& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.minOilRate(), comm) +
packSize(data.minGasRate(), comm) +
packSize(data.maxWaterCut(), comm) +
packSize(data.maxGasOilRatio(), comm) +
packSize(data.maxWaterGasRatio(), comm) +
packSize(data.workover(), comm) +
packSize(data.endRun(), comm) +
packSize(data.followonWell(), comm) +
packSize(data.quantityLimit(), comm) +
packSize(data.maxSecondaryMaxWaterCut(), comm) +
packSize(data.workoverSecondary(), comm) +
packSize(data.maxGasLiquidRatio(), comm) +
packSize(data.minLiquidRate(), comm) +
packSize(data.maxTemperature(), comm) +
packSize(data.minReservoirFluidRate(), comm);
}
std::size_t packSize(const WellConnections& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getHeadI(), comm) +
packSize(data.getHeadJ(), comm) +
packSize(data.getNumRemoved(), comm) +
packSize(data.getConnections(), comm);
}
std::size_t packSize(const Well::WellProductionProperties& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.name, comm) +
packSize(data.OilRate, comm) +
packSize(data.WaterRate, comm) +
packSize(data.GasRate, comm) +
packSize(data.LiquidRate, comm) +
packSize(data.ResVRate, comm) +
packSize(data.BHPLimit, comm) +
packSize(data.THPLimit, comm) +
packSize(data.BHPH, comm) +
packSize(data.THPH, comm) +
packSize(data.VFPTableNumber, comm) +
packSize(data.ALQValue, comm) +
packSize(data.predictionMode, comm) +
packSize(data.controlMode, comm) +
packSize(data.whistctl_cmode, comm) +
packSize(data.getNumProductionControls(), comm);
}
std::size_t packSize(const SpiralICD& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.strength(), comm) +
packSize(data.length(), comm) +
packSize(data.densityCalibration(), comm) +
packSize(data.viscosityCalibration(), comm) +
packSize(data.criticalValue(), comm) +
packSize(data.widthTransitionRegion(), comm) +
packSize(data.maxViscosityRatio(), comm) +
packSize(data.methodFlowScaling(), comm) +
packSize(data.maxAbsoluteRate(), comm) +
packSize(data.status(), comm) +
packSize(data.scalingFactor(), comm);
}
std::size_t packSize(const Valve& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.conFlowCoefficient(), comm) +
packSize(data.conCrossArea(), comm) +
packSize(data.conMaxCrossArea(), comm) +
packSize(data.pipeAdditionalLength(), comm) +
packSize(data.pipeDiameter(), comm) +
packSize(data.pipeRoughness(), comm) +
packSize(data.pipeCrossArea(), comm) +
packSize(data.status(), comm);
}
std::size_t packSize(const Segment& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.segmentNumber(), comm) +
packSize(data.branchNumber(), comm) +
packSize(data.outletSegment(), comm) +
packSize(data.inletSegments(), comm) +
packSize(data.totalLength(), comm) +
packSize(data.depth(), comm) +
packSize(data.internalDiameter(), comm) +
packSize(data.roughness(), comm) +
packSize(data.crossArea(), comm) +
packSize(data.volume(), comm) +
packSize(data.dataReady(), comm) +
packSize(data.segmentType(), comm) +
packSize(data.spiralICD(), comm) +
packSize(data.getValve(), comm);
}
template
std::size_t packSize(const std::shared_ptr& data,
Dune::MPIHelper::MPICommunicator comm)
{
std::size_t size = packSize(bool(), comm);
if (data)
size += packSize(*data, comm);
return size;
}
template std::size_t packSize(const std::shared_ptr& data,
Dune::MPIHelper::MPICommunicator comm);
////// pack routines
template
void pack(const T*, std::size_t, std::vector&, int&,
Dune::MPIHelper::MPICommunicator, std::integral_constant)
{
OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type.");
}
template
void pack(const T* data, std::size_t l, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm,
std::integral_constant)
{
#if HAVE_MPI
MPI_Pack(&l, 1, Dune::MPITraits::getType(), buffer.data(),
buffer.size(), &position, comm);
MPI_Pack(data, l, Dune::MPITraits::getType(), buffer.data(),
buffer.size(), &position, comm);
#else
(void) data;
(void) comm;
(void) l;
(void) buffer;
(void) position;
#endif
}
template
void pack(const T* data, std::size_t l, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data, l, buffer, position, comm, typename std::is_pod::type());
}
template
void pack(const T&, std::vector&, int&,
Dune::MPIHelper::MPICommunicator, std::integral_constant)
{
OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type.");
}
template
void pack(const T& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm, std::integral_constant)
{
#if HAVE_MPI
MPI_Pack(&data, 1, Dune::MPITraits::getType(), buffer.data(),
buffer.size(), &position, comm);
#else
(void) data;
(void) comm;
(void) buffer;
(void) position;
#endif
}
template
void pack(const T& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data, buffer, position, comm, typename std::is_pod::type());
}
template
void pack(const std::pair& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.first, buffer, position, comm);
pack(data.second, buffer, position, comm);
}
template
void pack(const std::vector& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
if (std::is_pod::value)
{
// size written automatically
pack(data.data(), data.size(), buffer, position, comm);
return;
}
pack(data.size(), buffer, position, comm);
for (const auto& entry: data)
pack(entry, buffer, position, comm);
}
template
void pack(const std::vector& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.size(), buffer, position, comm);
for (const auto& entry : data) {
bool b = entry;
pack(b, buffer, position, comm);
}
}
template
typename std::enable_if::value, void>::type
pack_tuple_entry(const Tuple&, std::vector&, int&,
Dune::MPIHelper::MPICommunicator)
{
}
template
typename std::enable_if::value, void>::type
pack_tuple_entry(const Tuple& tuple, std::vector& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm)
{
pack(std::get(tuple), buffer, position, comm);
pack_tuple_entry(tuple, buffer, position, comm);
}
template
void pack(const std::tuple& data, std::vector& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm)
{
pack_tuple_entry(data, buffer, position, comm);
}
template
void pack(const OrderedMap& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getIndex(), buffer, position, comm);
pack(data.getStorage(), buffer, position, comm);
}
template
void pack(const DynamicState& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.data(), buffer, position, comm);
pack(data.initialRange(), buffer, position, comm);
}
template
void pack(const DynamicVector& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.data(), buffer, position, comm);
}
void pack(const char* str, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
#if HAVE_MPI
std::size_t length = strlen(str)+1;
MPI_Pack(&length, 1, Dune::MPITraits::getType(), buffer.data(),
buffer.size(), &position, comm);
MPI_Pack(str, strlen(str)+1, MPI_CHAR, buffer.data(), buffer.size(),
&position, comm);
#else
(void) str;
(void) comm;
(void) buffer;
(void) position;
#endif
}
void pack(const std::string& str, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(str.c_str(), buffer, position, comm);
}
template
void pack(const std::map& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.size(), buffer, position, comm);
for (const auto& entry: data)
{
pack(entry, buffer, position, comm);
}
}
template
void pack(const std::unordered_map& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.size(), buffer, position, comm);
for (const auto& entry: data)
{
pack(entry, buffer, position, comm);
}
}
void pack(const data::Well& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.rates, buffer, position, comm);
pack(data.bhp, buffer, position, comm);
pack(data.thp, buffer, position, comm);
pack(data.temperature, buffer, position, comm);
pack(data.control, buffer, position, comm);
pack(data.connections, buffer, position, comm);
pack(data.segments, buffer, position, comm);
}
void pack(const RestartKey& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.key, buffer, position, comm);
pack(data.dim, buffer, position, comm);
pack(data.required, buffer, position, comm);
}
void pack(const data::CellData& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.dim, buffer, position, comm);
pack(data.data, buffer, position, comm);
pack(data.target, buffer, position, comm);
}
void pack(const data::Solution& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
// Needs explicit conversion to a supported base type holding the data
// to prevent throwing.
pack(static_cast&>(data),
buffer, position, comm);
}
void pack(const data::WellRates& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
// Needs explicit conversion to a supported base type holding the data
// to prevent throwing.
pack(static_cast&>(data),
buffer, position, comm);
}
void pack(const RestartValue& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.solution, buffer, position, comm);
pack(data.wells, buffer, position, comm);
pack(data.extra, buffer, position, comm);
}
void pack(const ThresholdPressure& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.active(), buffer, position, comm);
pack(data.restart(), buffer, position, comm);
pack(data.thresholdPressureTable(), buffer, position, comm);
pack(data.pressureTable(), buffer, position, comm);
}
void pack(const NNC& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.data(), buffer, position, comm);
}
void pack(const EDITNNC& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.data(), buffer, position, comm);
}
void pack(const Rock2dTable& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.pvmultValues(), buffer, position, comm);
pack(data.pressureValues(), buffer, position, comm);
}
void pack(const Rock2dtrTable& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.transMultValues(), buffer, position, comm);
pack(data.pressureValues(), buffer, position, comm);
}
void pack(const ColumnSchema& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.name(), buffer, position, comm);
pack(data.order(), buffer, position, comm);
pack(data.getDefaultMode(), buffer, position, comm);
if (data.getDefaultMode() == Table::DEFAULT_CONST)
pack(data.getDefaultValue(), buffer, position, comm);
}
void pack(const TableSchema& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getColumns(), buffer, position, comm);
}
void pack(const TableColumn& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.schema(), buffer, position, comm);
pack(data.name(), buffer, position, comm);
pack(data.values(), buffer, position, comm);
pack(data.defaults(), buffer, position, comm);
pack(data.defaultCount(), buffer, position, comm);
}
void pack(const SimpleTable& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.schema(), buffer, position, comm);
pack(data.columns(), buffer, position, comm);
pack(data.jfunc(), buffer, position, comm);
}
void pack(const TableContainer& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.max(), buffer, position, comm);
size_t entries = 0;
for (const auto& it : data.tables()) {
if (it.second) {
++entries;
}
}
pack(entries, buffer, position, comm);
for (const auto& it : data.tables()) {
if (it.second) {
pack(it.first, buffer, position, comm);
pack(*it.second, buffer, position, comm);
}
}
}
void pack(const Equil& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.records(), buffer, position, comm);
}
void pack(const FoamConfig& data, std::vector& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.records(), buffer, position, comm);
}
void pack(const InitConfig& data, std::vector