OutputBlackoilModule: move gas-water fip assignment code to FIPContainer

This commit is contained in:
Arne Morten Kvarving 2025-01-30 16:19:10 +01:00
parent efbda68f89
commit 63042c25ee
3 changed files with 44 additions and 23 deletions

View File

@ -151,6 +151,39 @@ assignCo2InGas(const unsigned globalDofIdx, const Co2InGasInput& v)
}
}
template<class FluidSystem>
void
FIPContainer<FluidSystem>::
assignGasWater(const unsigned globalDofIdx,
const std::array<Scalar, numPhases>& fip,
const Scalar gasInPlaceWater,
const Scalar waterInPlaceGas)
{
if (!this->fip_[Inplace::Phase::WaterInGasPhase].empty()) {
this->fip_[Inplace::Phase::WaterInGasPhase][globalDofIdx] = waterInPlaceGas;
}
if (!this->fip_[Inplace::Phase::WaterInWaterPhase].empty()) {
this->fip_[Inplace::Phase::WaterInWaterPhase][globalDofIdx] = fip[waterPhaseIdx];
}
// For water+gas cases the gas in water is added to the GIPL value
if (!this->fip_[Inplace::Phase::GasInLiquidPhase].empty() &&
!FluidSystem::phaseIsActive(oilPhaseIdx))
{
this->fip_[Inplace::Phase::GasInLiquidPhase][globalDofIdx] = gasInPlaceWater;
}
// Add dissolved gas and vaporized water to total Fip
if (!this->fip_[Inplace::Phase::WATER].empty()) {
this->fip_[Inplace::Phase::WATER][globalDofIdx] += waterInPlaceGas;
}
if (!this->fip_[Inplace::Phase::GAS].empty()) {
this->fip_[Inplace::Phase::GAS][globalDofIdx] += gasInPlaceWater;
}
}
template<class T> using FS = BlackOilFluidSystem<T,BlackOilDefaultIndexTraits>;
#define INSTANTIATE_TYPE(T) \

View File

@ -28,6 +28,7 @@
#include <opm/output/eclipse/Inplace.hpp>
#include <array>
#include <cstddef>
#include <unordered_map>
#include <vector>
@ -42,6 +43,10 @@ public:
using Scalar = typename FluidSystem::Scalar;
using FIPMap = std::unordered_map<Inplace::Phase, std::vector<Scalar>>;
static constexpr auto numPhases = FluidSystem::numPhases;
static constexpr auto oilPhaseIdx = FluidSystem::oilPhaseIdx;
static constexpr auto waterPhaseIdx = FluidSystem::waterPhaseIdx;
// Temporary constructor until we are ready to own the map
explicit FIPContainer(FIPMap& fip)
: fip_(fip) {}
@ -67,6 +72,11 @@ public:
void assignCo2InGas(const unsigned globalDofIdx,
const Co2InGasInput& v);
void assignGasWater(const unsigned globalDofIdx,
const std::array<Scalar, numPhases>& fip,
const Scalar gasInPlaceWater,
const Scalar waterInPlaceGas);
private:
FIPMap& fip_;
std::size_t bufferSize_ = 0;

View File

@ -1629,29 +1629,7 @@ private:
const auto gasInPlaceWater = getValue(fs.Rsw()) * fip[waterPhaseIdx];
const auto waterInPlaceGas = getValue(fs.Rvw()) * fip[gasPhaseIdx];
if (!this->fip_[Inplace::Phase::WaterInGasPhase].empty()) {
this->fip_[Inplace::Phase::WaterInGasPhase][globalDofIdx] = waterInPlaceGas;
}
if (!this->fip_[Inplace::Phase::WaterInWaterPhase].empty()) {
this->fip_[Inplace::Phase::WaterInWaterPhase][globalDofIdx] = fip[waterPhaseIdx];
}
// For water+gas cases the gas in water is added to the GIPL value
if (!this->fip_[Inplace::Phase::GasInLiquidPhase].empty() &&
!FluidSystem::phaseIsActive(oilPhaseIdx))
{
this->fip_[Inplace::Phase::GasInLiquidPhase][globalDofIdx] = gasInPlaceWater;
}
// Add dissolved gas and vaporized water to total Fip
if (!this->fip_[Inplace::Phase::WATER].empty()) {
this->fip_[Inplace::Phase::WATER][globalDofIdx] += waterInPlaceGas;
}
if (!this->fip_[Inplace::Phase::GAS].empty()) {
this->fip_[Inplace::Phase::GAS][globalDofIdx] += gasInPlaceWater;
}
this->fipC_.assignGasWater(globalDofIdx, fip, gasInPlaceWater, waterInPlaceGas);
}
template <typename IntensiveQuantities>