From cd9009dc75e2c0e3c540d0e976f7750c64f3f666 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Thu, 24 Oct 2024 14:25:20 +0200 Subject: [PATCH] adding isCompositional_ variable to GenericOutputBlackoilModule to indicate whether it is a compostional simulation. --- .../flow/GenericOutputBlackoilModule.cpp | 83 ++++++++++--------- .../flow/GenericOutputBlackoilModule.hpp | 4 +- .../flow/OutputCompositionalModule.hpp | 3 +- 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.cpp b/opm/simulators/flow/GenericOutputBlackoilModule.cpp index d03ef18ac..7cebdee0f 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.cpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.cpp @@ -203,7 +203,8 @@ GenericOutputBlackoilModule(const EclipseState& eclState, bool enableBrine, bool enableSaltPrecipitation, bool enableExtbo, - bool enableMICP) + bool enableMICP, + bool isCompositional) : eclState_(eclState) , schedule_(schedule) , summaryState_(summaryState) @@ -222,6 +223,7 @@ GenericOutputBlackoilModule(const EclipseState& eclState, , enableSaltPrecipitation_(enableSaltPrecipitation) , enableExtbo_(enableExtbo) , enableMICP_(enableMICP) + , isCompositional_(isCompositional) , local_data_valid_(false) { const auto& fp = eclState_.fieldProps(); @@ -628,29 +630,34 @@ assignToSolution(data::Solution& sol) // basically, for compositional, we can not use std::array for this. We need to generate the ZMF1, ZMF2, and so on // and also, we need to map these values. - auto compositionalEntries = std::vector{}; - { - // ZMF - for (int i = 0; i < numComponents; ++i) { - const std::string name = "ZMF" + std::to_string(i + 1); // Generate ZMF1, ZMF2, ... - compositionalEntries.emplace_back(name, UnitSystem::measure::identity, moleFractions_[i]); + // TODO: the following should go to a function + if (this->isCompositional_) { + auto compositionalEntries = std::vector{}; + { + // ZMF + for (int i = 0; i < numComponents; ++i) { + const std::string name = "ZMF" + std::to_string(i + 1); // Generate ZMF1, ZMF2, ... + compositionalEntries.emplace_back(name, UnitSystem::measure::identity, moleFractions_[i]); + } + + // XMF + for (int i = 0; i < numComponents; ++i) { + const std::string name = "XMF" + std::to_string(i + 1); // Generate XMF1, XMF2, ... + compositionalEntries.emplace_back(name, UnitSystem::measure::identity, + phaseMoleFractions_[oilPhaseIdx][i]); + } + + // YMF + for (int i = 0; i < numComponents; ++i) { + const std::string name = "YMF" + std::to_string(i + 1); // Generate YMF1, YMF2, ... + compositionalEntries.emplace_back(name, UnitSystem::measure::identity, + phaseMoleFractions_[gasPhaseIdx][i]); + } } - // XMF - for (int i = 0; i < numComponents; ++i) { - const std::string name = "XMF" + std::to_string(i + 1); // Generate XMF1, XMF2, ... - compositionalEntries.emplace_back(name, UnitSystem::measure::identity, phaseMoleFractions_[oilPhaseIdx][i]); + for (const auto& array: compositionalEntries) { + doInsert(array, data::TargetType::RESTART_SOLUTION); } - - // YMF - for (int i = 0; i < numComponents; ++i) { - const std::string name = "YMF" + std::to_string(i + 1); // Generate YMF1, YMF2, ... - compositionalEntries.emplace_back(name, UnitSystem::measure::identity, phaseMoleFractions_[gasPhaseIdx][i]); - } - } - - for (const auto& array : compositionalEntries) { - doInsert(array, data::TargetType::RESTART_SOLUTION); } for (const auto& array : baseSolutionArrays) { @@ -688,8 +695,8 @@ assignToSolution(data::Solution& sol) std::move(this->saturation_[gasPhaseIdx]), data::TargetType::RESTART_SOLUTION); } - - if (FluidSystem::phaseIsActive(oilPhaseIdx) && + + if (this->isCompositional_ && FluidSystem::phaseIsActive(oilPhaseIdx) && ! this->saturation_[oilPhaseIdx].empty()) { sol.insert("SOIL", UnitSystem::measure::identity, @@ -1519,24 +1526,26 @@ doAllocBuffers(const unsigned bufferSize, overburdenPressure_.resize(bufferSize, 0.0); } - if (rstKeywords["ZMF"] > 0) { - rstKeywords["ZMF"] = 0; - for (int i = 0; i < numComponents; ++i) { - moleFractions_[i].resize(bufferSize, 0.0); + if (this->isCompositional_) { + if (rstKeywords["ZMF"] > 0) { + rstKeywords["ZMF"] = 0; + for (int i = 0; i < numComponents; ++i) { + moleFractions_[i].resize(bufferSize, 0.0); + } } - } - if (rstKeywords["XMF"] > 0 && FluidSystem::phaseIsActive(oilPhaseIdx)) { - rstKeywords["XMF"] = 0; - for (int i = 0; i < numComponents; ++i) { - phaseMoleFractions_[oilPhaseIdx][i].resize(bufferSize, 0.0); + if (rstKeywords["XMF"] > 0 && FluidSystem::phaseIsActive(oilPhaseIdx)) { + rstKeywords["XMF"] = 0; + for (int i = 0; i < numComponents; ++i) { + phaseMoleFractions_[oilPhaseIdx][i].resize(bufferSize, 0.0); + } } - } - if (rstKeywords["YMF"] > 0 && FluidSystem::phaseIsActive(gasPhaseIdx)) { - rstKeywords["YMF"] = 0; - for (int i = 0; i < numComponents; ++i) { - phaseMoleFractions_[gasPhaseIdx][i].resize(bufferSize, 0.0); + if (rstKeywords["YMF"] > 0 && FluidSystem::phaseIsActive(gasPhaseIdx)) { + rstKeywords["YMF"] = 0; + for (int i = 0; i < numComponents; ++i) { + phaseMoleFractions_[gasPhaseIdx][i].resize(bufferSize, 0.0); + } } } diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.hpp b/opm/simulators/flow/GenericOutputBlackoilModule.hpp index 9281f0467..19aff9caa 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.hpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.hpp @@ -335,7 +335,8 @@ protected: bool enableBrine, bool enableSaltPrecipitation, bool enableExtbo, - bool enableMICP); + bool enableMICP, + bool isCompositional = false); void doAllocBuffers(unsigned bufferSize, unsigned reportStepNum, @@ -405,6 +406,7 @@ protected: bool enableSaltPrecipitation_{false}; bool enableExtbo_{false}; bool enableMICP_{false}; + bool isCompositional_{false}; bool forceDisableFipOutput_{false}; bool forceDisableFipresvOutput_{false}; diff --git a/opm/simulators/flow/OutputCompositionalModule.hpp b/opm/simulators/flow/OutputCompositionalModule.hpp index bbd6880e5..02eccf908 100644 --- a/opm/simulators/flow/OutputCompositionalModule.hpp +++ b/opm/simulators/flow/OutputCompositionalModule.hpp @@ -126,7 +126,8 @@ public: getPropValue(), getPropValue(), getPropValue(), - getPropValue()) + getPropValue(), + true) , simulator_(simulator) { for (auto& region_pair : this->regions_) {