FIPContainer: change to using has()

This commit is contained in:
Arne Morten Kvarving
2025-01-31 11:27:07 +01:00
parent e78ce63b4e
commit 01a5641a3b

View File

@@ -134,25 +134,25 @@ FIPContainer<FluidSystem>::
assignCo2InGas(const unsigned globalDofIdx, const Co2InGasInput& v) assignCo2InGas(const unsigned globalDofIdx, const Co2InGasInput& v)
{ {
const Scalar massGas = (1.0 - v.xgW) * v.pv * v.rhog; const Scalar massGas = (1.0 - v.xgW) * v.pv * v.rhog;
if (!this->fip_[Inplace::Phase::CO2Mass].empty()) { if (this->has(Inplace::Phase::CO2Mass)) {
this->fip_[Inplace::Phase::CO2Mass][globalDofIdx] = massGas * v.sg; this->fip_[Inplace::Phase::CO2Mass][globalDofIdx] = massGas * v.sg;
} }
if (!this->fip_[Inplace::Phase::CO2MassInGasPhase].empty()) { if (this->has(Inplace::Phase::CO2MassInGasPhase)) {
this->fip_[Inplace::Phase::CO2MassInGasPhase][globalDofIdx] = massGas * v.sg; this->fip_[Inplace::Phase::CO2MassInGasPhase][globalDofIdx] = massGas * v.sg;
} }
if (!this->fip_[Inplace::Phase::CO2InGasPhaseInMob].empty()) { if (this->has(Inplace::Phase::CO2InGasPhaseInMob)) {
const Scalar imMobileGas = massGas / v.mM * std::min(v.sgcr , v.sg); const Scalar imMobileGas = massGas / v.mM * std::min(v.sgcr , v.sg);
this->fip_[Inplace::Phase::CO2InGasPhaseInMob][globalDofIdx] = imMobileGas; this->fip_[Inplace::Phase::CO2InGasPhaseInMob][globalDofIdx] = imMobileGas;
} }
if (!this->fip_[Inplace::Phase::CO2InGasPhaseMob].empty()) { if (this->has(Inplace::Phase::CO2InGasPhaseMob)) {
const Scalar mobileGas = massGas / v.mM * std::max(Scalar{0.0}, v.sg - v.sgcr); const Scalar mobileGas = massGas / v.mM * std::max(Scalar{0.0}, v.sg - v.sgcr);
this->fip_[Inplace::Phase::CO2InGasPhaseMob][globalDofIdx] = mobileGas; this->fip_[Inplace::Phase::CO2InGasPhaseMob][globalDofIdx] = mobileGas;
} }
if (!this->fip_[Inplace::Phase::CO2InGasPhaseInMobKrg].empty()) { if (this->has(Inplace::Phase::CO2InGasPhaseInMobKrg)) {
if (v.sgcr >= v.sg) { if (v.sgcr >= v.sg) {
const Scalar imMobileGasKrg = massGas / v.mM * v.sg; const Scalar imMobileGasKrg = massGas / v.mM * v.sg;
this->fip_[Inplace::Phase::CO2InGasPhaseInMobKrg][globalDofIdx] = imMobileGasKrg; this->fip_[Inplace::Phase::CO2InGasPhaseInMobKrg][globalDofIdx] = imMobileGasKrg;
@@ -161,7 +161,7 @@ assignCo2InGas(const unsigned globalDofIdx, const Co2InGasInput& v)
} }
} }
if (!this->fip_[Inplace::Phase::CO2InGasPhaseMobKrg].empty()) { if (this->has(Inplace::Phase::CO2InGasPhaseMobKrg)) {
if (v.sg > v.sgcr) { if (v.sg > v.sgcr) {
const Scalar mobileGasKrg = massGas / v.mM * v.sg; const Scalar mobileGasKrg = massGas / v.mM * v.sg;
this->fip_[Inplace::Phase::CO2InGasPhaseMobKrg][globalDofIdx] = mobileGasKrg; this->fip_[Inplace::Phase::CO2InGasPhaseMobKrg][globalDofIdx] = mobileGasKrg;
@@ -170,17 +170,17 @@ assignCo2InGas(const unsigned globalDofIdx, const Co2InGasInput& v)
} }
} }
if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseInMob].empty()) { if (this->has(Inplace::Phase::CO2MassInGasPhaseInMob)) {
const Scalar imMobileMassGas = massGas * std::min(v.sgcr , v.sg); const Scalar imMobileMassGas = massGas * std::min(v.sgcr , v.sg);
this->fip_[Inplace::Phase::CO2MassInGasPhaseInMob][globalDofIdx] = imMobileMassGas; this->fip_[Inplace::Phase::CO2MassInGasPhaseInMob][globalDofIdx] = imMobileMassGas;
} }
if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseMob].empty()) { if (this->has(Inplace::Phase::CO2MassInGasPhaseMob)) {
const Scalar mobileMassGas = massGas * std::max(Scalar{0.0}, v.sg - v.sgcr); const Scalar mobileMassGas = massGas * std::max(Scalar{0.0}, v.sg - v.sgcr);
this->fip_[Inplace::Phase::CO2MassInGasPhaseMob][globalDofIdx] = mobileMassGas; this->fip_[Inplace::Phase::CO2MassInGasPhaseMob][globalDofIdx] = mobileMassGas;
} }
if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseInMobKrg].empty()) { if (this->has(Inplace::Phase::CO2MassInGasPhaseInMobKrg)) {
if (v.sgcr >= v.sg) { if (v.sgcr >= v.sg) {
const Scalar imMobileMassGasKrg = massGas * v.sg; const Scalar imMobileMassGasKrg = massGas * v.sg;
this->fip_[Inplace::Phase::CO2MassInGasPhaseInMobKrg][globalDofIdx] = imMobileMassGasKrg; this->fip_[Inplace::Phase::CO2MassInGasPhaseInMobKrg][globalDofIdx] = imMobileMassGasKrg;
@@ -189,7 +189,7 @@ assignCo2InGas(const unsigned globalDofIdx, const Co2InGasInput& v)
} }
} }
if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseMobKrg].empty()) { if (this->has(Inplace::Phase::CO2MassInGasPhaseMobKrg)) {
if (v.sg > v.sgcr) { if (v.sg > v.sgcr) {
const Scalar mobileMassGasKrg = massGas * v.sg; const Scalar mobileMassGasKrg = massGas * v.sg;
this->fip_[Inplace::Phase::CO2MassInGasPhaseMobKrg][globalDofIdx] = mobileMassGasKrg; this->fip_[Inplace::Phase::CO2MassInGasPhaseMobKrg][globalDofIdx] = mobileMassGasKrg;
@@ -198,22 +198,22 @@ assignCo2InGas(const unsigned globalDofIdx, const Co2InGasInput& v)
} }
} }
if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumTrapped].empty()) { if (this->has(Inplace::Phase::CO2MassInGasPhaseMaximumTrapped)) {
const Scalar imMobileMassGas = massGas * std::min(v.trappedGas, v.sg); const Scalar imMobileMassGas = massGas * std::min(v.trappedGas, v.sg);
this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumTrapped][globalDofIdx] = imMobileMassGas; this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumTrapped][globalDofIdx] = imMobileMassGas;
} }
if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped].empty()) { if (this->has(Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped)) {
const Scalar mobileMassGas = massGas * std::max(Scalar{0.0}, v.sg - v.trappedGas); const Scalar mobileMassGas = massGas * std::max(Scalar{0.0}, v.sg - v.trappedGas);
this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped][globalDofIdx] = mobileMassGas; this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped][globalDofIdx] = mobileMassGas;
} }
if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped].empty()) { if (this->has(Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped)) {
const Scalar imMobileMassGas = massGas * std::min(v.strandedGas, v.sg); const Scalar imMobileMassGas = massGas * std::min(v.strandedGas, v.sg);
this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped][globalDofIdx] = imMobileMassGas; this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped][globalDofIdx] = imMobileMassGas;
} }
if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped].empty()) { if (this->has(Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped)) {
const Scalar mobileMassGas = massGas * std::max(Scalar{0.0}, v.sg - v.strandedGas); const Scalar mobileMassGas = massGas * std::max(Scalar{0.0}, v.sg - v.strandedGas);
this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped][globalDofIdx] = mobileMassGas; this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped][globalDofIdx] = mobileMassGas;
} }
@@ -227,27 +227,25 @@ assignGasWater(const unsigned globalDofIdx,
const Scalar gasInPlaceWater, const Scalar gasInPlaceWater,
const Scalar waterInPlaceGas) const Scalar waterInPlaceGas)
{ {
if (!this->fip_[Inplace::Phase::WaterInGasPhase].empty()) { if (this->has(Inplace::Phase::WaterInGasPhase)) {
this->fip_[Inplace::Phase::WaterInGasPhase][globalDofIdx] = waterInPlaceGas; this->fip_[Inplace::Phase::WaterInGasPhase][globalDofIdx] = waterInPlaceGas;
} }
if (!this->fip_[Inplace::Phase::WaterInWaterPhase].empty()) { if (this->has(Inplace::Phase::WaterInWaterPhase)) {
this->fip_[Inplace::Phase::WaterInWaterPhase][globalDofIdx] = fip[waterPhaseIdx]; this->fip_[Inplace::Phase::WaterInWaterPhase][globalDofIdx] = fip[waterPhaseIdx];
} }
// For water+gas cases the gas in water is added to the GIPL value // For water+gas cases the gas in water is added to the GIPL value
if (!this->fip_[Inplace::Phase::GasInLiquidPhase].empty() && if (this->has(Inplace::Phase::GasInLiquidPhase) && !FluidSystem::phaseIsActive(oilPhaseIdx)) {
!FluidSystem::phaseIsActive(oilPhaseIdx))
{
this->fip_[Inplace::Phase::GasInLiquidPhase][globalDofIdx] = gasInPlaceWater; this->fip_[Inplace::Phase::GasInLiquidPhase][globalDofIdx] = gasInPlaceWater;
} }
// Add dissolved gas and vaporized water to total Fip // Add dissolved gas and vaporized water to total Fip
if (!this->fip_[Inplace::Phase::WATER].empty()) { if (this->has(Inplace::Phase::WATER)) {
this->fip_[Inplace::Phase::WATER][globalDofIdx] += waterInPlaceGas; this->fip_[Inplace::Phase::WATER][globalDofIdx] += waterInPlaceGas;
} }
if (!this->fip_[Inplace::Phase::GAS].empty()) { if (this->has(Inplace::Phase::GAS)) {
this->fip_[Inplace::Phase::GAS][globalDofIdx] += gasInPlaceWater; this->fip_[Inplace::Phase::GAS][globalDofIdx] += gasInPlaceWater;
} }
} }
@@ -258,33 +256,23 @@ FIPContainer<FluidSystem>::
assignVolumesSurface(const unsigned globalDofIdx, assignVolumesSurface(const unsigned globalDofIdx,
const std::array<Scalar, numPhases>& fip) const std::array<Scalar, numPhases>& fip)
{ {
if (FluidSystem::phaseIsActive(oilPhaseIdx) && if (FluidSystem::phaseIsActive(oilPhaseIdx) && this->has(Inplace::Phase::OIL)) {
!this->fip_[Inplace::Phase::OIL].empty())
{
this->fip_[Inplace::Phase::OIL][globalDofIdx] = fip[oilPhaseIdx]; this->fip_[Inplace::Phase::OIL][globalDofIdx] = fip[oilPhaseIdx];
} }
if (FluidSystem::phaseIsActive(oilPhaseIdx) && if (FluidSystem::phaseIsActive(oilPhaseIdx) && this->has(Inplace::Phase::OilInLiquidPhase)) {
!this->fip_[Inplace::Phase::OilInLiquidPhase].empty())
{
this->fip_[Inplace::Phase::OilInLiquidPhase][globalDofIdx] = fip[oilPhaseIdx]; this->fip_[Inplace::Phase::OilInLiquidPhase][globalDofIdx] = fip[oilPhaseIdx];
} }
if (FluidSystem::phaseIsActive(gasPhaseIdx) && if (FluidSystem::phaseIsActive(gasPhaseIdx) && this->has(Inplace::Phase::GAS)) {
!this->fip_[Inplace::Phase::GAS].empty())
{
this->fip_[Inplace::Phase::GAS][globalDofIdx] = fip[gasPhaseIdx]; this->fip_[Inplace::Phase::GAS][globalDofIdx] = fip[gasPhaseIdx];
} }
if (FluidSystem::phaseIsActive(gasPhaseIdx) && if (FluidSystem::phaseIsActive(gasPhaseIdx) && this->has(Inplace::Phase::GasInGasPhase)) {
!this->fip_[Inplace::Phase::GasInGasPhase].empty())
{
this->fip_[Inplace::Phase::GasInGasPhase][globalDofIdx] = fip[gasPhaseIdx]; this->fip_[Inplace::Phase::GasInGasPhase][globalDofIdx] = fip[gasPhaseIdx];
} }
if (FluidSystem::phaseIsActive(waterPhaseIdx) && if (FluidSystem::phaseIsActive(waterPhaseIdx) && this->has(Inplace::Phase::WATER)) {
!this->fip_[Inplace::Phase::WATER].empty())
{
this->fip_[Inplace::Phase::WATER][globalDofIdx] = fip[waterPhaseIdx]; this->fip_[Inplace::Phase::WATER][globalDofIdx] = fip[waterPhaseIdx];
} }
} }
@@ -296,27 +284,19 @@ assignVolumesReservoir(const unsigned globalDofIdx,
const Scalar saltConcentration, const Scalar saltConcentration,
const std::array<Scalar, numPhases>& fipr) const std::array<Scalar, numPhases>& fipr)
{ {
if (FluidSystem::phaseIsActive(oilPhaseIdx) && if (FluidSystem::phaseIsActive(oilPhaseIdx) && this->has(Inplace::Phase::OilResVolume)) {
!this->fip_[Inplace::Phase::OilResVolume].empty())
{
this->fip_[Inplace::Phase::OilResVolume][globalDofIdx] = fipr[oilPhaseIdx]; this->fip_[Inplace::Phase::OilResVolume][globalDofIdx] = fipr[oilPhaseIdx];
} }
if (FluidSystem::phaseIsActive(gasPhaseIdx) && if (FluidSystem::phaseIsActive(gasPhaseIdx) && this->has(Inplace::Phase::GasResVolume)) {
!this->fip_[Inplace::Phase::GasResVolume].empty())
{
this->fip_[Inplace::Phase::GasResVolume][globalDofIdx] = fipr[gasPhaseIdx]; this->fip_[Inplace::Phase::GasResVolume][globalDofIdx] = fipr[gasPhaseIdx];
} }
if (FluidSystem::phaseIsActive(waterPhaseIdx) && if (FluidSystem::phaseIsActive(waterPhaseIdx) && this->has(Inplace::Phase::WaterResVolume)) {
!this->fip_[Inplace::Phase::WaterResVolume].empty())
{
this->fip_[Inplace::Phase::WaterResVolume][globalDofIdx] = fipr[waterPhaseIdx]; this->fip_[Inplace::Phase::WaterResVolume][globalDofIdx] = fipr[waterPhaseIdx];
} }
if (FluidSystem::phaseIsActive(waterPhaseIdx) && if (FluidSystem::phaseIsActive(waterPhaseIdx) && this->has(Inplace::Phase::SALT)) {
!this->fip_[Inplace::Phase::SALT].empty())
{
this->fip_[Inplace::Phase::SALT][globalDofIdx] = this->fip_[Inplace::Phase::SALT][globalDofIdx] =
fipr[waterPhaseIdx] * saltConcentration; fipr[waterPhaseIdx] * saltConcentration;
} }
@@ -344,13 +324,15 @@ assignCo2InWater(const unsigned globalDofIdx,
const Scalar co2InWater, const Scalar co2InWater,
const Scalar mM) const Scalar mM)
{ {
if (!this->fip_[Inplace::Phase::CO2Mass].empty()) { if (this->has(Inplace::Phase::CO2Mass)) {
this->fip_[Inplace::Phase::CO2Mass][globalDofIdx] += co2InWater * mM; this->fip_[Inplace::Phase::CO2Mass][globalDofIdx] += co2InWater * mM;
} }
if (!this->fip_[Inplace::Phase::CO2MassInWaterPhase].empty()) {
if (this->has(Inplace::Phase::CO2MassInWaterPhase)) {
this->fip_[Inplace::Phase::CO2MassInWaterPhase][globalDofIdx] = co2InWater * mM; this->fip_[Inplace::Phase::CO2MassInWaterPhase][globalDofIdx] = co2InWater * mM;
} }
if (!this->fip_[Inplace::Phase::CO2InWaterPhase].empty()) {
if (this->has(Inplace::Phase::CO2InWaterPhase)) {
this->fip_[Inplace::Phase::CO2InWaterPhase][globalDofIdx] = co2InWater; this->fip_[Inplace::Phase::CO2InWaterPhase][globalDofIdx] = co2InWater;
} }
} }
@@ -362,20 +344,20 @@ assignOilGasDistribution(const unsigned globalDofIdx,
const Scalar gasInPlaceLiquid, const Scalar gasInPlaceLiquid,
const Scalar oilInPlaceGas) const Scalar oilInPlaceGas)
{ {
if (!this->fip_[Inplace::Phase::GasInLiquidPhase].empty()) { if (this->has(Inplace::Phase::GasInLiquidPhase)) {
this->fip_[Inplace::Phase::GasInLiquidPhase][globalDofIdx] = gasInPlaceLiquid; this->fip_[Inplace::Phase::GasInLiquidPhase][globalDofIdx] = gasInPlaceLiquid;
} }
if (!this->fip_[Inplace::Phase::OilInGasPhase].empty()) { if (this->has(Inplace::Phase::OilInGasPhase)) {
this->fip_[Inplace::Phase::OilInGasPhase][globalDofIdx] = oilInPlaceGas; this->fip_[Inplace::Phase::OilInGasPhase][globalDofIdx] = oilInPlaceGas;
} }
// Add dissolved gas and vaporized oil to total Fip // Add dissolved gas and vaporized oil to total Fip
if (!this->fip_[Inplace::Phase::OIL].empty()) { if (this->has(Inplace::Phase::OIL)) {
this->fip_[Inplace::Phase::OIL][globalDofIdx] += oilInPlaceGas; this->fip_[Inplace::Phase::OIL][globalDofIdx] += oilInPlaceGas;
} }
if (!this->fip_[Inplace::Phase::GAS].empty()) { if (this->has(Inplace::Phase::GAS)) {
this->fip_[Inplace::Phase::GAS][globalDofIdx] += gasInPlaceLiquid; this->fip_[Inplace::Phase::GAS][globalDofIdx] += gasInPlaceLiquid;
} }
} }