From 13fb52bf9e40175d6e8e3de8c8ab070624a609e8 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 4 Feb 2025 16:31:52 +0100 Subject: [PATCH] add TracerContainer, a container for tracer data output start by moving data members into it --- CMakeLists_files.cmake | 2 + .../flow/GenericOutputBlackoilModule.cpp | 22 ++++----- .../flow/GenericOutputBlackoilModule.hpp | 6 +-- opm/simulators/flow/OutputBlackoilModule.hpp | 12 ++--- opm/simulators/flow/TracerContainer.cpp | 28 +++++++++++ opm/simulators/flow/TracerContainer.hpp | 46 +++++++++++++++++++ 6 files changed, 96 insertions(+), 20 deletions(-) create mode 100644 opm/simulators/flow/TracerContainer.cpp create mode 100644 opm/simulators/flow/TracerContainer.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index f4aa0dec2..28d3fefa9 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -120,6 +120,7 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/flow/SimulatorReportBanners.cpp opm/simulators/flow/SimulatorSerializer.cpp opm/simulators/flow/SolutionContainers.cpp + opm/simulators/flow/TracerContainer.cpp opm/simulators/flow/Transmissibility.cpp opm/simulators/flow/ValidationFunctions.cpp opm/simulators/flow/equil/EquilibrationHelpers.cpp @@ -880,6 +881,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/SolutionContainers.hpp opm/simulators/flow/SubDomain.hpp opm/simulators/flow/TTagFlowProblemTPFA.hpp + opm/simulators/flow/TracerContainer.hpp opm/simulators/flow/TracerModel.hpp opm/simulators/flow/Transmissibility.hpp opm/simulators/flow/Transmissibility_impl.hpp diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.cpp b/opm/simulators/flow/GenericOutputBlackoilModule.cpp index 9c41bb916..8e9f8590a 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.cpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.cpp @@ -631,40 +631,40 @@ assignToSolution(data::Solution& sol) this->fipC_.outputRestart(sol); // Tracers - if (! this->freeTracerConcentrations_.empty()) { + if (! this->tracerC_.freeConcentrations_.empty()) { const auto& tracers = this->eclState_.tracer(); for (auto tracerIdx = 0*tracers.size(); tracerIdx < tracers.size(); ++tracerIdx) { sol.insert(tracers[tracerIdx].fname(), UnitSystem::measure::identity, - std::move(freeTracerConcentrations_[tracerIdx]), + std::move(this->tracerC_.freeConcentrations_[tracerIdx]), data::TargetType::RESTART_TRACER_SOLUTION); } // Put freeTracerConcentrations container into a valid state. Otherwise // we'll move from vectors that have already been moved from if we // get here and it's not a restart step. - this->freeTracerConcentrations_.clear(); + this->tracerC_.freeConcentrations_.clear(); } - if (! this->solTracerConcentrations_.empty()) { + if (! this->tracerC_.solConcentrations_.empty()) { const auto& tracers = this->eclState_.tracer(); for (auto tracerIdx = 0*tracers.size(); tracerIdx < tracers.size(); ++tracerIdx) { - if (solTracerConcentrations_[tracerIdx].empty()) + if (this->tracerC_.solConcentrations_[tracerIdx].empty()) continue; sol.insert(tracers[tracerIdx].sname(), UnitSystem::measure::identity, - std::move(solTracerConcentrations_[tracerIdx]), + std::move(this->tracerC_.solConcentrations_[tracerIdx]), data::TargetType::RESTART_TRACER_SOLUTION); } // Put solTracerConcentrations container into a valid state. Otherwise // we'll move from vectors that have already been moved from if we // get here and it's not a restart step. - this->solTracerConcentrations_.clear(); + this->tracerC_.solConcentrations_.clear(); } } @@ -1221,16 +1221,16 @@ doAllocBuffers(const unsigned bufferSize, // tracers if (numTracers > 0) { - freeTracerConcentrations_.resize(numTracers); + tracerC_.freeConcentrations_.resize(numTracers); for (unsigned tracerIdx = 0; tracerIdx < numTracers; ++tracerIdx) { - freeTracerConcentrations_[tracerIdx].resize(bufferSize, 0.0); + tracerC_.freeConcentrations_[tracerIdx].resize(bufferSize, 0.0); } - solTracerConcentrations_.resize(numTracers); + tracerC_.solConcentrations_.resize(numTracers); for (unsigned tracerIdx = 0; tracerIdx < numTracers; ++tracerIdx) { if (enableSolTracers[tracerIdx]) - solTracerConcentrations_[tracerIdx].resize(bufferSize, 0.0); + tracerC_.solConcentrations_[tracerIdx].resize(bufferSize, 0.0); } } diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.hpp b/opm/simulators/flow/GenericOutputBlackoilModule.hpp index 5c570803e..059f5a093 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.hpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -330,7 +331,7 @@ protected: const bool enablePCHysteresis = false, const bool enableNonWettingHysteresis = false, const bool enableWettingHysteresis = false, - unsigned numTracers = 0, + const unsigned numTracers = 0, const std::vector& enableSolTracers = {}, unsigned numOutputNnc = 0, std::map rstKeywords = {}); @@ -467,8 +468,7 @@ protected: std::array viscosity_; std::array relativePermeability_; - std::vector freeTracerConcentrations_; - std::vector solTracerConcentrations_; + TracerContainer tracerC_; std::array residual_; diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index 650cb8f3e..71d44ea29 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -647,21 +647,21 @@ public: // tracers const auto& tracerModel = simulator_.problem().tracerModel(); - if (! this->freeTracerConcentrations_.empty()) { + if (! this->tracerC_.freeConcentrations_.empty()) { for (int tracerIdx = 0; tracerIdx < tracerModel.numTracers(); ++tracerIdx) { - if (this->freeTracerConcentrations_[tracerIdx].empty()) { + if (this->tracerC_.freeConcentrations_[tracerIdx].empty()) { continue; } - this->freeTracerConcentrations_[tracerIdx][globalDofIdx] = + this->tracerC_.freeConcentrations_[tracerIdx][globalDofIdx] = tracerModel.freeTracerConcentration(tracerIdx, globalDofIdx); } } - if (! this->solTracerConcentrations_.empty()) { + if (! this->tracerC_.solConcentrations_.empty()) { for (int tracerIdx = 0; tracerIdx < tracerModel.numTracers(); ++tracerIdx) { - if (this->solTracerConcentrations_[tracerIdx].empty()) { + if (this->tracerC_.solConcentrations_[tracerIdx].empty()) { continue; } - this->solTracerConcentrations_[tracerIdx][globalDofIdx] = + this->tracerC_.solConcentrations_[tracerIdx][globalDofIdx] = tracerModel.solTracerConcentration(tracerIdx, globalDofIdx); } diff --git a/opm/simulators/flow/TracerContainer.cpp b/opm/simulators/flow/TracerContainer.cpp new file mode 100644 index 000000000..6ceacbee1 --- /dev/null +++ b/opm/simulators/flow/TracerContainer.cpp @@ -0,0 +1,28 @@ +// -*- 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/TracerContainer.hpp b/opm/simulators/flow/TracerContainer.hpp new file mode 100644 index 000000000..17f40f501 --- /dev/null +++ b/opm/simulators/flow/TracerContainer.hpp @@ -0,0 +1,46 @@ +// -*- 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_TRACER_CONTAINER_HPP +#define OPM_TRACER_CONTAINER_HPP + +#include + +namespace Opm { + +template +class TracerContainer +{ + using Scalar = typename FluidSystem::Scalar; + using ScalarBuffer = std::vector; + +public: + std::vector freeConcentrations_; + std::vector solConcentrations_; +}; + +} // namespace Opm + +#endif // OPM_TRACER_CONTAINER_HPP