diff --git a/opm/simulators/flow/FlowsContainer.cpp b/opm/simulators/flow/FlowsContainer.cpp index 1128a9db2c..819f48d1cc 100644 --- a/opm/simulators/flow/FlowsContainer.cpp +++ b/opm/simulators/flow/FlowsContainer.cpp @@ -211,6 +211,27 @@ allocate(const std::size_t bufferSize, } } +template +void FlowsContainer:: +assignFlores(const unsigned globalDofIdx, + const int faceId, + const unsigned nncId, + const Scalar gas, + const Scalar oil, + const Scalar water) +{ + if (faceId >= 0) { + assignToVec(this->flores_[faceId], globalDofIdx, gas); + assignToVec(this->flores_[faceId], globalDofIdx, oil); + assignToVec(this->flores_[faceId], globalDofIdx, water); + } + else if (faceId == -2) { + assignToNnc(this->floresn_, nncId, gas); + assignToNnc(this->floresn_, nncId, oil); + assignToNnc(this->floresn_, nncId, water); + } +} + template void FlowsContainer:: assignFlows(const unsigned globalDofIdx, diff --git a/opm/simulators/flow/FlowsContainer.hpp b/opm/simulators/flow/FlowsContainer.hpp index a70bc4bdad..8caa8dec87 100644 --- a/opm/simulators/flow/FlowsContainer.hpp +++ b/opm/simulators/flow/FlowsContainer.hpp @@ -60,6 +60,13 @@ public: const bool allocRestart, std::map& rstKeywords); + void assignFlores(const unsigned globalDofIdx, + const int faceId, + const unsigned nncId, + const Scalar gas, + const Scalar oil, + const Scalar water); + void assignFlows(const unsigned globalDofIdx, const int faceId, const unsigned nncId, diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index 0d50193a5c..348dff5cc0 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -690,44 +690,12 @@ public: const auto& floresInf = problem.model().linearizer().getFloresInfo(); auto floresInfos = floresInf[globalDofIdx]; for (const auto& floresInfo : floresInfos) { - if (floresInfo.faceId >= 0) { - if constexpr (gas_idx >= 0) { - if (!this->flowsC_.flores_[floresInfo.faceId][gasCompIdx].empty()) { - this->flowsC_.flores_[floresInfo.faceId][gasCompIdx][globalDofIdx] - = floresInfo.flow[gas_idx]; - } - } - if constexpr (oil_idx >= 0) { - if (!this->flowsC_.flores_[floresInfo.faceId][oilCompIdx].empty()) { - this->flowsC_.flores_[floresInfo.faceId][oilCompIdx][globalDofIdx] - = floresInfo.flow[oil_idx]; - } - } - if constexpr (water_idx >= 0) { - if (!this->flowsC_.flores_[floresInfo.faceId][waterCompIdx].empty()) { - this->flowsC_.flores_[floresInfo.faceId][waterCompIdx][globalDofIdx] - = floresInfo.flow[water_idx]; - } - } - } - - if (floresInfo.faceId == -2) { - if (!this->flowsC_.floresn_[gasCompIdx].indices.empty()) { - this->flowsC_.floresn_[gasCompIdx].indices[floresInfo.nncId] = floresInfo.nncId; - this->flowsC_.floresn_[gasCompIdx].values[floresInfo.nncId] - = floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(gasCompIdx)]; - } - if (!this->flowsC_.floresn_[oilCompIdx].indices.empty()) { - this->flowsC_.floresn_[oilCompIdx].indices[floresInfo.nncId] = floresInfo.nncId; - this->flowsC_.floresn_[oilCompIdx].values[floresInfo.nncId] - = floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(oilCompIdx)]; - } - if (!this->flowsC_.floresn_[waterCompIdx].indices.empty()) { - this->flowsC_.floresn_[waterCompIdx].indices[floresInfo.nncId] = floresInfo.nncId; - this->flowsC_.floresn_[waterCompIdx].values[floresInfo.nncId] - = floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(waterCompIdx)]; - } - } + this->flowsC_.assignFlores(globalDofIdx, + floresInfo.faceId, + floresInfo.nncId, + value_or_zero(floresInfo.flow), + value_or_zero(floresInfo.flow), + value_or_zero(floresInfo.flow)); } } }