From 63042c25eebe6bec7c5871bb3e68fc092154a65c Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 30 Jan 2025 16:19:10 +0100 Subject: [PATCH] OutputBlackoilModule: move gas-water fip assignment code to FIPContainer --- opm/simulators/flow/FIPContainer.cpp | 33 ++++++++++++++++++++ opm/simulators/flow/FIPContainer.hpp | 10 ++++++ opm/simulators/flow/OutputBlackoilModule.hpp | 24 +------------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/opm/simulators/flow/FIPContainer.cpp b/opm/simulators/flow/FIPContainer.cpp index 14dc75d91..0f6731857 100644 --- a/opm/simulators/flow/FIPContainer.cpp +++ b/opm/simulators/flow/FIPContainer.cpp @@ -151,6 +151,39 @@ assignCo2InGas(const unsigned globalDofIdx, const Co2InGasInput& v) } } +template +void +FIPContainer:: +assignGasWater(const unsigned globalDofIdx, + const std::array& 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 using FS = BlackOilFluidSystem; #define INSTANTIATE_TYPE(T) \ diff --git a/opm/simulators/flow/FIPContainer.hpp b/opm/simulators/flow/FIPContainer.hpp index 15f84a4e1..e874cdff9 100644 --- a/opm/simulators/flow/FIPContainer.hpp +++ b/opm/simulators/flow/FIPContainer.hpp @@ -28,6 +28,7 @@ #include +#include #include #include #include @@ -42,6 +43,10 @@ public: using Scalar = typename FluidSystem::Scalar; using FIPMap = std::unordered_map>; + 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& fip, + const Scalar gasInPlaceWater, + const Scalar waterInPlaceGas); + private: FIPMap& fip_; std::size_t bufferSize_ = 0; diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index 6d8cf9303..4386c6bef 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -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