diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 51372468d..f4aa0dec2 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -90,6 +90,7 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/flow/BlackoilModelParameters.cpp opm/simulators/flow/BlackoilModelConvergenceMonitor.cpp opm/simulators/flow/CollectDataOnIORank.cpp + opm/simulators/flow/CompositionalContainer.cpp opm/simulators/flow/ConvergenceOutputConfiguration.cpp opm/simulators/flow/EclGenericWriter.cpp opm/simulators/flow/ExtboContainer.cpp @@ -821,6 +822,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/BlackoilModelProperties.hpp opm/simulators/flow/CollectDataOnIORank.hpp opm/simulators/flow/CollectDataOnIORank_impl.hpp + opm/simulators/flow/CompositionalContainer.hpp opm/simulators/flow/ConvergenceOutputConfiguration.hpp opm/simulators/flow/countGlobalCells.hpp opm/simulators/flow/CpGridVanguard.hpp diff --git a/opm/simulators/flow/CompositionalContainer.cpp b/opm/simulators/flow/CompositionalContainer.cpp new file mode 100644 index 000000000..ff82dd9de --- /dev/null +++ b/opm/simulators/flow/CompositionalContainer.cpp @@ -0,0 +1,29 @@ +// -*- 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 { + +} // namespace Opm diff --git a/opm/simulators/flow/CompositionalContainer.hpp b/opm/simulators/flow/CompositionalContainer.hpp new file mode 100644 index 000000000..a9c885107 --- /dev/null +++ b/opm/simulators/flow/CompositionalContainer.hpp @@ -0,0 +1,52 @@ +// -*- 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_COMPOSITIONAL_CONTAINER_HPP +#define OPM_COMPOSITIONAL_CONTAINER_HPP + +#include +#include + +namespace Opm { + +template +class CompositionalContainer +{ + using Scalar = typename FluidSystem::Scalar; + using ScalarBuffer = std::vector; + + static constexpr int numComponents = FluidSystem::numComponents; + static constexpr int numPhases = FluidSystem::numPhases; + +public: + // total mole fractions for each component + std::array moleFractions_; + // mole fractions for each component in each phase + std::array, numPhases> phaseMoleFractions_; +}; + +} // namespace Opm + +#endif // OPM_COMPOSITIONAL_CONTAINER_HPP diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.cpp b/opm/simulators/flow/GenericOutputBlackoilModule.cpp index 46f556241..4608cb071 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.cpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.cpp @@ -536,21 +536,21 @@ assignToSolution(data::Solution& sol) // ZMF for (int i = 0; i < numComponents; ++i) { const auto name = fmt::format("ZMF{}", i + 1); // Generate ZMF1, ZMF2, ... - compositionalEntries.emplace_back(name, UnitSystem::measure::identity, moleFractions_[i]); + compositionalEntries.emplace_back(name, UnitSystem::measure::identity, compC_.moleFractions_[i]); } // XMF for (int i = 0; i < numComponents; ++i) { const auto name = fmt::format("XMF{}", i + 1); // Generate XMF1, XMF2, ... compositionalEntries.emplace_back(name, UnitSystem::measure::identity, - phaseMoleFractions_[oilPhaseIdx][i]); + compC_.phaseMoleFractions_[oilPhaseIdx][i]); } // YMF for (int i = 0; i < numComponents; ++i) { const auto name = fmt::format("YMF{}", i + 1); // Generate YMF1, YMF2, ... compositionalEntries.emplace_back(name, UnitSystem::measure::identity, - phaseMoleFractions_[gasPhaseIdx][i]); + compC_.phaseMoleFractions_[gasPhaseIdx][i]); } } @@ -1297,21 +1297,21 @@ doAllocBuffers(const unsigned bufferSize, if (rstKeywords["ZMF"] > 0) { rstKeywords["ZMF"] = 0; for (int i = 0; i < numComponents; ++i) { - moleFractions_[i].resize(bufferSize, 0.0); + compC_.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); + compC_.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); + compC_.phaseMoleFractions_[gasPhaseIdx][i].resize(bufferSize, 0.0); } } } diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.hpp b/opm/simulators/flow/GenericOutputBlackoilModule.hpp index c2d45aafa..0a7b0a11b 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.hpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.hpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -468,10 +469,7 @@ protected: std::array viscosity_; std::array relativePermeability_; - // total mole fractions for each component - std::array moleFractions_; - // mole fractions for each component in each phase - std::array, numPhases> phaseMoleFractions_; + CompositionalContainer compC_; std::vector freeTracerConcentrations_; std::vector solTracerConcentrations_; diff --git a/opm/simulators/flow/OutputCompositionalModule.hpp b/opm/simulators/flow/OutputCompositionalModule.hpp index d6102528d..5f369f47d 100644 --- a/opm/simulators/flow/OutputCompositionalModule.hpp +++ b/opm/simulators/flow/OutputCompositionalModule.hpp @@ -32,12 +32,16 @@ #include #include +#include #include #include #include #include + +#include +#include #include #include @@ -188,19 +192,19 @@ public: } for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { - if (this->moleFractions_[compIdx].empty()) continue; + if (this->compC_.moleFractions_[compIdx].empty()) continue; - this->moleFractions_[compIdx][globalDofIdx] = getValue(fs.moleFraction(compIdx)); + this->compC_.moleFractions_[compIdx][globalDofIdx] = getValue(fs.moleFraction(compIdx)); } // XMF and YMF for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { if (FluidSystem::phaseIsActive(oilPhaseIdx)) { - if (this->phaseMoleFractions_[oilPhaseIdx][compIdx].empty()) continue; - this->phaseMoleFractions_[oilPhaseIdx][compIdx][globalDofIdx] = getValue(fs.moleFraction(oilPhaseIdx, compIdx)); + if (this->compC_.phaseMoleFractions_[oilPhaseIdx][compIdx].empty()) continue; + this->compC_.phaseMoleFractions_[oilPhaseIdx][compIdx][globalDofIdx] = getValue(fs.moleFraction(oilPhaseIdx, compIdx)); } if (FluidSystem::phaseIsActive(gasPhaseIdx)) { - if (this->phaseMoleFractions_[gasPhaseIdx][compIdx].empty()) continue; - this->phaseMoleFractions_[gasPhaseIdx][compIdx][globalDofIdx] = getValue(fs.moleFraction(gasPhaseIdx, compIdx)); + if (this->compC_.phaseMoleFractions_[gasPhaseIdx][compIdx].empty()) continue; + this->compC_.phaseMoleFractions_[gasPhaseIdx][compIdx][globalDofIdx] = getValue(fs.moleFraction(gasPhaseIdx, compIdx)); } }