#7350 PVT curves : Use PVTNUM value to get PVT curve data

This commit is contained in:
Magne Sjaastad
2021-02-10 15:05:20 +01:00
parent bcdba1bb8f
commit 6ebf3aaaca
5 changed files with 142 additions and 169 deletions

View File

@@ -29,20 +29,6 @@
#include <ert/ecl/ecl_kw_magic.h>
namespace {
std::vector<int>
pvtnumVector(const ::Opm::ECLGraph& G,
const ::Opm::ECLInitFileData& init)
{
auto pvtnum = G.rawLinearisedCellData<int>(init, "PVTNUM");
if (pvtnum.empty()) {
// PVTNUM missing in one or more of the grids managed by 'G'.
// Put all cells in PVTNUM region 1.
pvtnum.assign(G.numCells(), 1);
}
return pvtnum;
}
template <class PVTInterp>
std::vector<Opm::ECLPVT::PVTGraph>
@@ -252,8 +238,7 @@ namespace {
Opm::ECLPVT::ECLPvtCurveCollection::
ECLPvtCurveCollection(const ECLGraph& G,
const ECLInitFileData& init)
: pvtnum_ (pvtnumVector(G, init))
, gas_ (CreateGasPVTInterpolant::fromECLOutput(init))
: gas_ (CreateGasPVTInterpolant::fromECLOutput(init))
, oil_ (CreateOilPVTInterpolant::fromECLOutput(init))
, usys_native_ (ECLUnits::serialisedUnitConventions(init))
, usys_internal_(ECLUnits::internalUnitConventions())
@@ -270,22 +255,22 @@ std::vector<Opm::ECLPVT::PVTGraph>
Opm::ECLPVT::ECLPvtCurveCollection::
getPvtCurve(const RawCurve curve,
const ECLPhaseIndex phase,
const int activeCell) const
const int pvtRegionID) const
{
if (! this->isValidRequest(phase, activeCell)) {
if (! this->isValidRequest(phase, pvtRegionID)) {
// Not a supported phase or cell index out of bounds. Not a valid
// request so return empty.
return {};
}
// PVTNUM is traditional one-based region identifier. Subtract one to
// pvtRegionID is traditional one-based region identifier. Subtract one to
// form valid index into std::vector<>s.
const auto regID = this->pvtnum_[activeCell] - 1;
const auto zeroBasedPvtIndex = pvtRegionID - 1;
if (phase == ECLPhaseIndex::Liquid) {
// Caller requests oil properties.
return this->convertToOutputUnits(
rawPvtCurve(this->oil_.get(), curve, regID), curve, phase);
rawPvtCurve(this->oil_.get(), curve, zeroBasedPvtIndex), curve, phase);
}
// Caller requests gas properties.
@@ -293,18 +278,18 @@ getPvtCurve(const RawCurve curve,
"Internal Logic Error Identifying Supported Phases");
return this->convertToOutputUnits(
rawPvtCurve(this->gas_.get(), curve, regID), curve, phase);
rawPvtCurve(this->gas_.get(), curve, zeroBasedPvtIndex), curve, phase);
}
std::vector<double>
Opm::ECLPVT::ECLPvtCurveCollection::
getDynamicPropertySI(const RawCurve property,
const ECLPhaseIndex phase,
const int activeCell,
const int pvtRegionID,
const std::vector<double>& phasePress,
const std::vector<double>& mixRatio) const
{
if (! this->isValidRequest(phase, activeCell) ||
if (! this->isValidRequest(phase, pvtRegionID) ||
(property == RawCurve::SaturatedState))
{
// Not a supported phase, cell index out of bounds, or caller
@@ -313,14 +298,14 @@ getDynamicPropertySI(const RawCurve property,
return {};
}
// PVTNUM is traditional one-based region identifier. Subtract one to
// pvtRegionID is traditional one-based region identifier. Subtract one to
// form valid index into std::vector<>s.
const auto regID = this->pvtnum_[activeCell] - 1;
const auto zeroBasedPvtIndex = pvtRegionID - 1;
if (phase == ECLPhaseIndex::Liquid) {
// Caller requests oil properties.
return oilProperty(this->oil_.get(), property,
regID, phasePress, mixRatio);
zeroBasedPvtIndex, phasePress, mixRatio);
}
// Caller requests gas properties.
@@ -328,18 +313,18 @@ getDynamicPropertySI(const RawCurve property,
"Internal Logic Error Identifying Supported Phases");
return gasProperty(this->gas_.get(), property,
regID, phasePress, mixRatio);
zeroBasedPvtIndex, phasePress, mixRatio);
}
std::vector<double>
Opm::ECLPVT::ECLPvtCurveCollection::
getDynamicPropertyNative(const RawCurve property,
const ECLPhaseIndex phase,
const int activeCell,
const int pvtRegionID,
std::vector<double> phasePress,
std::vector<double> mixRatio) const
{
if (! this->isValidRequest(phase, activeCell) ||
if (! this->isValidRequest(phase, pvtRegionID) ||
(property == RawCurve::SaturatedState))
{
// Not a supported phase, cell index out of bounds, or caller
@@ -370,7 +355,7 @@ getDynamicPropertyNative(const RawCurve property,
}
// 2) Evaluate requested property in strict SI units.
auto prop = this->getDynamicPropertySI(property, phase, activeCell,
auto prop = this->getDynamicPropertySI(property, phase, pvtRegionID,
phasePress, mixRatio);
// 3) Convert property values to user's requested system of units.
@@ -412,8 +397,7 @@ getDynamicPropertyNative(const RawCurve property,
bool
Opm::ECLPVT::ECLPvtCurveCollection::
isValidRequest(const ECLPhaseIndex phase,
const int activeCell) const
isValidRequest(const ECLPhaseIndex phase, const int pvtRegionID) const
{
if (! ((phase == ECLPhaseIndex::Liquid) ||
(phase == ECLPhaseIndex::Vapour)))
@@ -422,9 +406,7 @@ isValidRequest(const ECLPhaseIndex phase,
return false;
}
// Check if cell index is within bounds.
return static_cast<decltype(this->pvtnum_.size())>(activeCell)
< this->pvtnum_.size();
return pvtRegionID >= 1;
}
std::vector<Opm::ECLPVT::PVTGraph>

View File

@@ -81,11 +81,11 @@ namespace Opm { namespace ECLPVT {
/// \param[in] phase Phase for which to compute extract graph
/// representation of PVT property function.
///
/// \param[in] activeCell Index of particular active cell in model.
/// \param[in] pvtRegionID Value of pvtRegionID (1-based region value)
///
/// \return Collection of 2D graphs for PVT property curve
/// identified by requests represented by \p curve, \p phase and
/// \p activeCell. One curve (vector element) for each tabulated
/// \p pvtRegionID. One curve (vector element) for each tabulated
/// node of the primary look-up key. Single curve (i.e., a
/// single element vector) in the case of dry gas (no vaporised
/// oil) or dead oil (no dissolved gas). Return values provided
@@ -96,17 +96,17 @@ namespace Opm { namespace ECLPVT {
/// (i.e., keyword 'PVCDO' in the input deck).
///
/// Example: Retrieve collection of gas viscosity curves pertaining
/// to model's active cell 31415.
/// to PVT region 1.
///
/// \code
/// const auto curves =
/// pvtCC.getPvtCurve(ECLPVT::RawCurve::Viscosity,
/// ECLPhaseIndex::Vapour, 31415);
/// ECLPhaseIndex::Vapour, 1);
/// \endcode
std::vector<PVTGraph>
getPvtCurve(const RawCurve curve,
const ECLPhaseIndex phase,
const int activeCell) const;
const int pvtRegionID) const;
/// Compute a single dynamic property in a single active cell for a
/// collection of cell states.
@@ -124,7 +124,7 @@ namespace Opm { namespace ECLPVT {
/// ECLPhaseIndex::Liquid \endcode. All other values return an
/// empty result.
///
/// \param[in] activeCell Index of particular active cell in model.
/// \param[in] pvtRegionID Value of pvtRegionID (1-based region value)
///
/// \param[in] phasePress Sequence of phase pressure values
/// pertaining to \p activeCell. Could, for instance, be the
@@ -139,8 +139,8 @@ namespace Opm { namespace ECLPVT {
/// typically appropriate only for dry gas or dead oil cases.
///
/// \return Sequence of dynamic property values corresponding to the
/// requested property name of the identified phase in the
/// particular active cell. Empty for invalid requests, number
/// requested property name of the identified phase for the
/// current PVT region. Empty for invalid requests, number
/// of elements equal to \code phasePress.size() \endcode
/// otherwise. Return values are in strict SI units of
/// measure--i.e., rm^3/sm^3 for the formation volume factors and
@@ -148,7 +148,7 @@ namespace Opm { namespace ECLPVT {
std::vector<double>
getDynamicPropertySI(const RawCurve property,
const ECLPhaseIndex phase,
const int activeCell,
const int pvtRegionID,
const std::vector<double>& phasePress,
const std::vector<double>& mixRatio
= std::vector<double>()) const;
@@ -172,7 +172,7 @@ namespace Opm { namespace ECLPVT {
/// ECLPhaseIndex::Liquid \endcode. All other values return an
/// empty result.
///
/// \param[in] activeCell Index of particular active cell in model.
/// \param[in] pvtRegionID Value of pvtRegionID (1-based region value)
///
/// \param[in] phasePress Sequence of phase pressure values
/// pertaining to \p activeCell. Could, for instance, be the
@@ -207,15 +207,12 @@ namespace Opm { namespace ECLPVT {
std::vector<double>
getDynamicPropertyNative(const RawCurve property,
const ECLPhaseIndex phase,
const int activeCell,
const int pvtRegionID,
std::vector<double> phasePress, // Mutable copy
std::vector<double> mixRatio // Mutable copy
= std::vector<double>()) const;
private:
/// Forward map: Cell -> PVT Region ID
std::vector<int> pvtnum_;
/// Gas PVT property evaluator.
std::shared_ptr<Gas> gas_; // shared => default special member funcs.
@@ -239,12 +236,12 @@ namespace Opm { namespace ECLPVT {
///
/// \param[in] phase Phase for which to compute a property.
///
/// \param[in] activeCell Index of particular active cell in model.
/// \param[in] pvtRegionID Value of pvtRegionID (1-based region value)
///
/// \return True if \p phase is supported and \p activeCell is
/// within range of the currently defined model. False otherwise.
bool isValidRequest(const ECLPhaseIndex phase,
const int activeCell) const;
const int pvtRegionID) const;
/// Convert a sequence of 2D graphs to user-defined system of units.
///