Merge pull request #278 from andlaus/fix_fluidstate_getters

Fix fluid state getters for blackoil quantities
This commit is contained in:
Andreas Lauser 2018-01-19 13:01:17 +01:00 committed by GitHub
commit a03f9a73cc
2 changed files with 28 additions and 27 deletions

View File

@ -52,27 +52,27 @@ unsigned getPvtRegionIndex_(typename std::enable_if<!HasMember_pvtRegionIndex<Fl
OPM_GENERATE_HAS_MEMBER(invB, ) // Creates 'HasMember_invB<T>'.
template <class FluidState, class FluidSystem, class LhsEval>
LhsEval getInvB_(typename std::enable_if<HasMember_pvtRegionIndex<FluidState>::value,
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getInvB_(typename std::enable_if<HasMember_invB<FluidState>::value,
const FluidState&>::type fluidState,
unsigned phaseIdx)
unsigned phaseIdx,
unsigned pvtRegionIdx OPM_UNUSED)
{ return Opm::decay<LhsEval>(fluidState.invB(phaseIdx)); }
template <class FluidState, class FluidSystem, class LhsEval>
LhsEval getInvB_(typename std::enable_if<!HasMember_pvtRegionIndex<FluidState>::value,
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getInvB_(typename std::enable_if<!HasMember_invB<FluidState>::value,
const FluidState&>::type fluidState,
unsigned phaseIdx)
unsigned phaseIdx,
unsigned pvtRegionIdx)
{
const auto& rho = fluidState.density(phaseIdx);
const auto& Xsolvent =
fluidState.massFraction(phaseIdx, FluidSystem::solventComponentIndx(phaseIdx));
fluidState.massFraction(phaseIdx, FluidSystem::solventComponentIndex(phaseIdx));
unsigned pvtRegionIdx = getPvtRegionIndex_(fluidState);
return
Opm::decay<LhsEval>(rho)
*Opm::decay<LhsEval>(Xsolvent)
/FluidSystem::referenceDensity(phaseIdx, pvtRegionIdx);
}
/*!
@ -142,9 +142,10 @@ public:
if (enableTemperature || enableEnergy)
setTemperature(fs.temperature(/*phaseIdx=*/0));
setPvtRegionIndex(getPvtRegionIndex_<FluidState>(fs));
setRs(Opm::BlackOil::getRs_<FluidSystem, Scalar, FluidState>(fs, /*regionIdx=*/0));
setRv(Opm::BlackOil::getRv_<FluidSystem, Scalar, FluidState>(fs, /*regionIdx=*/0));
unsigned pvtRegionIdx = getPvtRegionIndex_<FluidState>(fs);
setPvtRegionIndex(pvtRegionIdx);
setRs(Opm::BlackOil::getRs_<FluidSystem, FluidState, Scalar>(fs, pvtRegionIdx));
setRv(Opm::BlackOil::getRv_<FluidSystem, FluidState, Scalar>(fs, pvtRegionIdx));
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
setSaturation(phaseIdx, fs.saturation(phaseIdx));
@ -154,7 +155,7 @@ public:
if (enableEnergy)
setEnthalpy(phaseIdx, fs.enthalpy(phaseIdx));
setInvB(phaseIdx, getInvB_<FluidState, FluidSystem, Scalar>(fs, phaseIdx));
setInvB(phaseIdx, getInvB_<FluidSystem, FluidState, Scalar>(fs, phaseIdx, pvtRegionIdx));
}
}

View File

@ -49,7 +49,7 @@ namespace BlackOil {
OPM_GENERATE_HAS_MEMBER(Rs, ) // Creates 'HasMember_Rs<T>'.
OPM_GENERATE_HAS_MEMBER(Rv, ) // Creates 'HasMember_Rv<T>'.
template <class FluidSystem, class LhsEval, class FluidState>
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getRs_(typename std::enable_if<!HasMember_Rs<FluidState>::value, const FluidState&>::type fluidState,
unsigned regionIdx)
{
@ -59,7 +59,7 @@ LhsEval getRs_(typename std::enable_if<!HasMember_Rs<FluidState>::value, const F
return FluidSystem::convertXoGToRs(XoG, regionIdx);
}
template <class FluidSystem, class LhsEval, class FluidState>
template <class FluidSystem, class FluidState, class LhsEval>
auto getRs_(typename std::enable_if<HasMember_Rs<FluidState>::value, const FluidState&>::type fluidState,
unsigned regionIdx OPM_UNUSED)
-> decltype(Opm::MathToolbox<typename FluidState::Scalar>
@ -68,7 +68,7 @@ auto getRs_(typename std::enable_if<HasMember_Rs<FluidState>::value, const Fluid
return Opm::decay<LhsEval>(fluidState.Rs());
}
template <class FluidSystem, class LhsEval, class FluidState>
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getRv_(typename std::enable_if<!HasMember_Rv<FluidState>::value, const FluidState&>::type fluidState,
unsigned regionIdx)
{
@ -78,7 +78,7 @@ LhsEval getRv_(typename std::enable_if<!HasMember_Rv<FluidState>::value, const F
return FluidSystem::convertXgOToRv(XgO, regionIdx);
}
template <class FluidSystem, class LhsEval, class FluidState>
template <class FluidSystem, class FluidState, class LhsEval>
auto getRv_(typename std::enable_if<HasMember_Rv<FluidState>::value, const FluidState&>::type fluidState,
unsigned regionIdx OPM_UNUSED)
-> decltype(Opm::MathToolbox<typename FluidState::Scalar>
@ -558,7 +558,7 @@ public:
case oilPhaseIdx: {
if (enableDissolvedGas()) {
// miscible oil
const LhsEval& Rs = Opm::BlackOil::template getRs_<ThisType, LhsEval, FluidState>(fluidState, regionIdx);
const LhsEval& Rs = Opm::BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bo = oilPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rs);
return
@ -576,7 +576,7 @@ public:
case gasPhaseIdx: {
if (enableVaporizedOil()) {
// miscible gas
const LhsEval& Rv = Opm::BlackOil::template getRv_<ThisType, LhsEval, FluidState>(fluidState, regionIdx);
const LhsEval& Rv = Opm::BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv);
return
@ -685,7 +685,7 @@ public:
switch (phaseIdx) {
case oilPhaseIdx: {
if (enableDissolvedGas()) {
const auto& Rs = Opm::BlackOil::template getRs_<ThisType, LhsEval, FluidState>(fluidState, regionIdx);
const auto& Rs = Opm::BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (fluidState.saturation(gasPhaseIdx) > 0.0
&& Rs >= (1.0 - 1e-10)*oilPvt_->saturatedGasDissolutionFactor(regionIdx, Opm::scalarValue(T), Opm::scalarValue(p)))
{
@ -710,7 +710,7 @@ public:
}
case gasPhaseIdx: {
if (enableVaporizedOil()) {
const auto& Rv = Opm::BlackOil::template getRv_<ThisType, LhsEval, FluidState>(fluidState, regionIdx);
const auto& Rv = Opm::BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (fluidState.saturation(oilPhaseIdx) > 0.0
&& Rv >= (1.0 - 1e-10)*gasPvt_->saturatedOilVaporizationFactor(regionIdx, Opm::scalarValue(T), Opm::scalarValue(p)))
{
@ -906,7 +906,7 @@ public:
switch (phaseIdx) {
case oilPhaseIdx: {
if (enableDissolvedGas()) {
const auto& Rs = Opm::BlackOil::template getRs_<ThisType, LhsEval, FluidState>(fluidState, regionIdx);
const auto& Rs = Opm::BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (fluidState.saturation(gasPhaseIdx) > 0.0
&& Rs >= (1.0 - 1e-10)*oilPvt_->saturatedGasDissolutionFactor(regionIdx, Opm::scalarValue(T), Opm::scalarValue(p)))
{
@ -932,7 +932,7 @@ public:
case gasPhaseIdx: {
if (enableVaporizedOil()) {
const auto& Rv = Opm::BlackOil::template getRv_<ThisType, LhsEval, FluidState>(fluidState, regionIdx);
const auto& Rv = Opm::BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (fluidState.saturation(oilPhaseIdx) > 0.0
&& Rv >= (1.0 - 1e-10)*gasPvt_->saturatedOilVaporizationFactor(regionIdx, Opm::scalarValue(T), Opm::scalarValue(p)))
{
@ -977,8 +977,8 @@ public:
const auto& p = Opm::decay<LhsEval>(fluidState.pressure(phaseIdx));
const auto& T = Opm::decay<LhsEval>(fluidState.temperature(phaseIdx));
switch (phaseIdx) {
case oilPhaseIdx: return oilPvt_->enthalpy(regionIdx, T, p, Opm::BlackOil::template getRs_<ThisType, LhsEval, FluidState>(fluidState, regionIdx));
case gasPhaseIdx: return gasPvt_->enthalpy(regionIdx, T, p, Opm::BlackOil::template getRv_<ThisType, LhsEval, FluidState>(fluidState, regionIdx));
case oilPhaseIdx: return oilPvt_->enthalpy(regionIdx, T, p, Opm::BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
case gasPhaseIdx: return gasPvt_->enthalpy(regionIdx, T, p, Opm::BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
case waterPhaseIdx: return waterPvt_->enthalpy(regionIdx, T, p);
default: OPM_THROW(std::logic_error, "Unhandled phase index " << phaseIdx);
}
@ -1082,8 +1082,8 @@ public:
const auto& T = Opm::decay<LhsEval>(fluidState.temperature(phaseIdx));
switch (phaseIdx) {
case oilPhaseIdx: return oilPvt_->saturationPressure(regionIdx, T, Opm::BlackOil::template getRs_<ThisType, LhsEval, FluidState>(fluidState, regionIdx));
case gasPhaseIdx: return gasPvt_->saturationPressure(regionIdx, T, Opm::BlackOil::template getRv_<ThisType, LhsEval, FluidState>(fluidState, regionIdx));
case oilPhaseIdx: return oilPvt_->saturationPressure(regionIdx, T, Opm::BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
case gasPhaseIdx: return gasPvt_->saturationPressure(regionIdx, T, Opm::BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
case waterPhaseIdx: return 0.0;
default: OPM_THROW(std::logic_error, "Unhandled phase index " << phaseIdx);
}