From 336a99a2265850eba17a08e5d5525472dd1acc23 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 4 Feb 2025 16:31:52 +0100 Subject: [PATCH] add ExtboContainer, a container for extbo data output start by moving data members into it --- CMakeLists_files.cmake | 2 + opm/simulators/flow/ExtboContainer.cpp | 34 +++++++++++++ opm/simulators/flow/ExtboContainer.hpp | 49 +++++++++++++++++++ .../flow/GenericOutputBlackoilModule.cpp | 24 ++++----- .../flow/GenericOutputBlackoilModule.hpp | 8 +-- opm/simulators/flow/OutputBlackoilModule.hpp | 24 ++++----- 6 files changed, 111 insertions(+), 30 deletions(-) create mode 100644 opm/simulators/flow/ExtboContainer.cpp create mode 100644 opm/simulators/flow/ExtboContainer.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 058092fe3..0b657153f 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -92,6 +92,7 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/flow/CollectDataOnIORank.cpp opm/simulators/flow/ConvergenceOutputConfiguration.cpp opm/simulators/flow/EclGenericWriter.cpp + opm/simulators/flow/ExtboContainer.cpp opm/simulators/flow/ExtraConvergenceOutputThread.cpp opm/simulators/flow/FIPContainer.cpp opm/simulators/flow/FlowGenericProblem.cpp @@ -829,6 +830,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/EclGenericWriter_impl.hpp opm/simulators/flow/EclWriter.hpp opm/simulators/flow/EquilInitializer.hpp + opm/simulators/flow/ExtboContainer.hpp opm/simulators/flow/ExtraConvergenceOutputThread.hpp opm/simulators/flow/FemCpGridCompat.hpp opm/simulators/flow/FIBlackoilModel.hpp diff --git a/opm/simulators/flow/ExtboContainer.cpp b/opm/simulators/flow/ExtboContainer.cpp new file mode 100644 index 000000000..17251fd96 --- /dev/null +++ b/opm/simulators/flow/ExtboContainer.cpp @@ -0,0 +1,34 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/* + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + Consult the COPYING file in the top-level source directory of this + module for the precise wording of the license and the list of + copyright holders. +*/ + +#include +#include + +namespace Opm { + +template class ExtboContainer; + +#if FLOW_INSTANTIATE_FLOAT +template class ExtboContainer; +#endif + +} // namespace Opm diff --git a/opm/simulators/flow/ExtboContainer.hpp b/opm/simulators/flow/ExtboContainer.hpp new file mode 100644 index 000000000..032fa29e2 --- /dev/null +++ b/opm/simulators/flow/ExtboContainer.hpp @@ -0,0 +1,49 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/* + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + Consult the COPYING file in the top-level source directory of this + module for the precise wording of the license and the list of + copyright holders. +*/ +/*! + * \file + * \copydoc Opm::OutputBlackOilModule + */ +#ifndef OPM_EXTBO_CONTAINER_HPP +#define OPM_EXTBO_CONTAINER_HPP + +#include + +namespace Opm { + +template +class ExtboContainer +{ + using ScalarBuffer = std::vector; + +public: + ScalarBuffer X_volume_; + ScalarBuffer Y_volume_; + ScalarBuffer Z_fraction_; + ScalarBuffer mFracOil_; + ScalarBuffer mFracGas_; + ScalarBuffer mFracCo2_; +}; + +} // namespace Opm + +#endif // OPM_EXTBO_CONTAINER_HPP diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.cpp b/opm/simulators/flow/GenericOutputBlackoilModule.cpp index d1252f05f..6d968642e 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.cpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.cpp @@ -524,12 +524,12 @@ assignToSolution(data::Solution& sol) DataEntry{"RVW", UnitSystem::measure::oil_gas_ratio, rvw_}, DataEntry{"RVWSAT", UnitSystem::measure::oil_gas_ratio, waterVaporizationFactor_}, DataEntry{"SALTP", UnitSystem::measure::identity, pSalt_}, - DataEntry{"SS_X", UnitSystem::measure::identity, extboX_}, - DataEntry{"SS_Y", UnitSystem::measure::identity, extboY_}, - DataEntry{"SS_Z", UnitSystem::measure::identity, extboZ_}, - DataEntry{"STD_CO2", UnitSystem::measure::identity, mFracCo2_}, - DataEntry{"STD_GAS", UnitSystem::measure::identity, mFracGas_}, - DataEntry{"STD_OIL", UnitSystem::measure::identity, mFracOil_}, + DataEntry{"SS_X", UnitSystem::measure::identity, extboC_.X_volume_}, + DataEntry{"SS_Y", UnitSystem::measure::identity, extboC_.Y_volume_}, + DataEntry{"SS_Z", UnitSystem::measure::identity, extboC_.Z_fraction_}, + DataEntry{"STD_CO2", UnitSystem::measure::identity, extboC_.mFracCo2_}, + DataEntry{"STD_GAS", UnitSystem::measure::identity, extboC_.mFracGas_}, + DataEntry{"STD_OIL", UnitSystem::measure::identity, extboC_.mFracOil_}, DataEntry{"TMULT_RC", UnitSystem::measure::identity, rockCompTransMultiplier_}, }; @@ -1025,12 +1025,12 @@ doAllocBuffers(const unsigned bufferSize, } if (enableExtbo_) { - extboX_.resize(bufferSize, 0.0); - extboY_.resize(bufferSize, 0.0); - extboZ_.resize(bufferSize, 0.0); - mFracOil_.resize(bufferSize, 0.0); - mFracGas_.resize(bufferSize, 0.0); - mFracCo2_.resize(bufferSize, 0.0); + extboC_.X_volume_.resize(bufferSize, 0.0); + extboC_.Y_volume_.resize(bufferSize, 0.0); + extboC_.Z_fraction_.resize(bufferSize, 0.0); + extboC_.mFracOil_.resize(bufferSize, 0.0); + extboC_.mFracGas_.resize(bufferSize, 0.0); + extboC_.mFracCo2_.resize(bufferSize, 0.0); } if (enableMICP_) { diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.hpp b/opm/simulators/flow/GenericOutputBlackoilModule.hpp index 8c87aadc9..c2d45aafa 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.hpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.hpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -435,12 +436,7 @@ protected: ScalarBuffer cSalt_; ScalarBuffer pSalt_; ScalarBuffer permFact_; - ScalarBuffer extboX_; - ScalarBuffer extboY_; - ScalarBuffer extboZ_; - ScalarBuffer mFracOil_; - ScalarBuffer mFracGas_; - ScalarBuffer mFracCo2_; + ExtboContainer extboC_; ScalarBuffer soMax_; ScalarBuffer swMax_; ScalarBuffer sgmax_; diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index bd21bd308..9d7166f3e 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -388,9 +388,9 @@ public: if (this->viscosity_[phaseIdx].empty()) continue; - if (!this->extboX_.empty() && phaseIdx == oilPhaseIdx) + if (!this->extboC_.X_volume_.empty() && phaseIdx == oilPhaseIdx) this->viscosity_[phaseIdx][globalDofIdx] = getValue(intQuants.oilViscosity()); - else if (!this->extboX_.empty() && phaseIdx == gasPhaseIdx) + else if (!this->extboC_.X_volume_.empty() && phaseIdx == gasPhaseIdx) this->viscosity_[phaseIdx][globalDofIdx] = getValue(intQuants.gasViscosity()); else this->viscosity_[phaseIdx][globalDofIdx] = getValue(fs.viscosity(phaseIdx)); @@ -438,16 +438,16 @@ public: this->permFact_[globalDofIdx] = intQuants.permFactor().value(); } - if (!this->extboX_.empty()) { - this->extboX_[globalDofIdx] = intQuants.xVolume().value(); + if (!this->extboC_.X_volume_.empty()) { + this->extboC_.X_volume_[globalDofIdx] = intQuants.xVolume().value(); } - if (!this->extboY_.empty()) { - this->extboY_[globalDofIdx] = intQuants.yVolume().value(); + if (!this->extboC_.Y_volume_.empty()) { + this->extboC_.Y_volume_[globalDofIdx] = intQuants.yVolume().value(); } - if (!this->extboZ_.empty()) { - this->extboZ_[globalDofIdx] = intQuants.zFraction().value(); + if (!this->extboC_.Z_fraction_.empty()) { + this->extboC_.Z_fraction_[globalDofIdx] = intQuants.zFraction().value(); } if (!this->rPorV_.empty()) { @@ -455,7 +455,7 @@ public: this->rPorV_[globalDofIdx] = totVolume * intQuants.porosity().value(); } - if (!this->mFracCo2_.empty()) { + if (!this->extboC_.mFracCo2_.empty()) { const Scalar stdVolOil = getValue(fs.saturation(oilPhaseIdx)) * getValue(fs.invB(oilPhaseIdx)) + getValue(fs.saturation(gasPhaseIdx)) * getValue(fs.invB(gasPhaseIdx)) * getValue(fs.Rv()); const Scalar stdVolGas = getValue(fs.saturation(gasPhaseIdx)) * getValue(fs.invB(gasPhaseIdx)) @@ -470,9 +470,9 @@ public: const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx); const Scalar rhoCO2 = intQuants.zRefDensity(); const Scalar stdMassTotal = 1.0e-10 + stdVolOil * rhoO + stdVolGas * rhoG + stdVolCo2 * rhoCO2; - this->mFracOil_[globalDofIdx] = stdVolOil * rhoO / stdMassTotal; - this->mFracGas_[globalDofIdx] = stdVolGas * rhoG / stdMassTotal; - this->mFracCo2_[globalDofIdx] = stdVolCo2 * rhoCO2 / stdMassTotal; + this->extboC_.mFracOil_[globalDofIdx] = stdVolOil * rhoO / stdMassTotal; + this->extboC_.mFracGas_[globalDofIdx] = stdVolGas * rhoG / stdMassTotal; + this->extboC_.mFracCo2_[globalDofIdx] = stdVolCo2 * rhoCO2 / stdMassTotal; } if (this->micpC_.allocated()) {