refactor updateCO2InWater

This commit is contained in:
Tor Harald Sandve 2024-01-26 09:33:26 +01:00
parent 343f1201eb
commit 2fce942a5c

View File

@ -1329,20 +1329,7 @@ private:
(FluidSystem::phaseIsActive(waterPhaseIdx) ||
FluidSystem::phaseIsActive(oilPhaseIdx)))
{
const auto co2InWater = FluidSystem::phaseIsActive(oilPhaseIdx)
? this->co2InWaterFromOil(fs, pv)
: this->co2InWaterFromWater(fs, pv);
const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
if (!this->fip_[Inplace::Phase::CO2Mass].empty()) {
this->fip_[Inplace::Phase::CO2Mass][globalDofIdx] += co2InWater * mM;
}
if (!this->fip_[Inplace::Phase::CO2MassInWaterPhase].empty()) {
this->fip_[Inplace::Phase::CO2MassInWaterPhase][globalDofIdx] = co2InWater * mM;
}
if (!this->fip_[Inplace::Phase::CO2InWaterPhase].empty()) {
this->fip_[Inplace::Phase::CO2InWaterPhase][globalDofIdx] = co2InWater;
}
this->updateCO2InWater(globalDofIdx, pv, fs);
}
}
@ -1520,6 +1507,27 @@ private:
}
}
template <typename FluidState>
void updateCO2InWater(const unsigned globalDofIdx,
const double pv,
const FluidState& fs)
{
const auto co2InWater = FluidSystem::phaseIsActive(oilPhaseIdx)
? this->co2InWaterFromOil(fs, pv)
: this->co2InWaterFromWater(fs, pv);
const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
if (!this->fip_[Inplace::Phase::CO2Mass].empty()) {
this->fip_[Inplace::Phase::CO2Mass][globalDofIdx] += co2InWater * mM;
}
if (!this->fip_[Inplace::Phase::CO2MassInWaterPhase].empty()) {
this->fip_[Inplace::Phase::CO2MassInWaterPhase][globalDofIdx] = co2InWater * mM;
}
if (!this->fip_[Inplace::Phase::CO2InWaterPhase].empty()) {
this->fip_[Inplace::Phase::CO2InWaterPhase][globalDofIdx] = co2InWater;
}
}
template <typename FluidState>
Scalar co2InWaterFromWater(const FluidState& fs, const double pv) const
{