From ae1a1ce57eeedf8249bd3a694d5fcf13ff92e9a4 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sun, 15 Sep 2024 21:28:52 +0200 Subject: [PATCH 01/33] blackoilnewtonmethod.hh: rename to blackoilnewtonmethod.hpp --- CMakeLists_files.cmake | 4 +- flowexperimental/FlowExpNewtonMethod.hpp | 2 +- opm/models/blackoil/blackoilmodel.hh | 10 +-- ...wtonmethod.hh => blackoilnewtonmethod.hpp} | 73 ++++++++++++------- ....hh => blackoilnewtonmethodparameters.hpp} | 0 5 files changed, 53 insertions(+), 36 deletions(-) rename opm/models/blackoil/{blackoilnewtonmethod.hh => blackoilnewtonmethod.hpp} (93%) rename opm/models/blackoil/{blackoilnewtonmethodparameters.hh => blackoilnewtonmethodparameters.hpp} (100%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 12f7ff18cfa..d36d4a9296f 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -553,8 +553,8 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/blackoil/blackoilmicpmodules.hh opm/models/blackoil/blackoilmicpparams.hpp opm/models/blackoil/blackoilmodel.hh - opm/models/blackoil/blackoilnewtonmethod.hh - opm/models/blackoil/blackoilnewtonmethodparameters.hh + opm/models/blackoil/blackoilnewtonmethod.hpp + opm/models/blackoil/blackoilnewtonmethodparameters.hpp opm/models/blackoil/blackoilonephaseindices.hh opm/models/blackoil/blackoilpolymermodules.hh opm/models/blackoil/blackoilpolymerparams.hpp diff --git a/flowexperimental/FlowExpNewtonMethod.hpp b/flowexperimental/FlowExpNewtonMethod.hpp index 6e9753d7533..53b5996224e 100644 --- a/flowexperimental/FlowExpNewtonMethod.hpp +++ b/flowexperimental/FlowExpNewtonMethod.hpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include namespace Opm::Parameters { diff --git a/opm/models/blackoil/blackoilmodel.hh b/opm/models/blackoil/blackoilmodel.hh index 36252fc57a9..ff71785b96b 100644 --- a/opm/models/blackoil/blackoilmodel.hh +++ b/opm/models/blackoil/blackoilmodel.hh @@ -25,8 +25,8 @@ * * \copydoc Opm::BlackOilModel */ -#ifndef EWOMS_BLACK_OIL_MODEL_HH -#define EWOMS_BLACK_OIL_MODEL_HH +#ifndef OPM_BLACK_OIL_MODEL_HPP +#define OPM_BLACK_OIL_MODEL_HPP #include @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -606,7 +606,6 @@ protected: } private: - std::vector eqWeights_; Implementation& asImp_() { return *static_cast(this); } @@ -623,6 +622,7 @@ private: priVars.setPvtRegionIndex(regionIdx); } }; + } // namespace Opm -#endif +#endif // OPM_BLACK_OIL_MODEL_HPP diff --git a/opm/models/blackoil/blackoilnewtonmethod.hh b/opm/models/blackoil/blackoilnewtonmethod.hpp similarity index 93% rename from opm/models/blackoil/blackoilnewtonmethod.hh rename to opm/models/blackoil/blackoilnewtonmethod.hpp index b160dc62f1f..a418064c876 100644 --- a/opm/models/blackoil/blackoilnewtonmethod.hh +++ b/opm/models/blackoil/blackoilnewtonmethod.hpp @@ -25,17 +25,18 @@ * * \copydoc Opm::BlackOilNewtonMethod */ -#ifndef EWOMS_BLACK_OIL_NEWTON_METHOD_HH -#define EWOMS_BLACK_OIL_NEWTON_METHOD_HH +#ifndef OPM_BLACK_OIL_NEWTON_METHOD_HPP +#define OPM_BLACK_OIL_NEWTON_METHOD_HPP + +#include -#include #include +#include +#include -#include +#include #include -#include -#include "blackoilmicpmodules.hh" namespace Opm::Properties { @@ -92,12 +93,11 @@ class BlackOilNewtonMethod : public GetPropTypemodel().numTotalDof()); - std::fill(wasSwitched_.begin(), wasSwitched_.end(), false); + wasSwitched_.resize(this->model().numTotalDof(), false); } /*! - * \brief Register all run-time parameters for the immiscible model. + * \brief Register all run-time parameters for the blackoil newton method. */ static void registerParameters() { @@ -193,8 +193,9 @@ class BlackOilNewtonMethod : public GetPropType dpMaxRel_*currentValue[pvIdx]) - delta = signum(delta)*dpMaxRel_*currentValue[pvIdx]; + if (std::abs(delta) > params_.dpMaxRel_ * currentValue[pvIdx]) { + delta = signum(delta) * params_.dpMaxRel_ * currentValue[pvIdx]; + } } // water saturation delta else if (pvIdx == Indices::waterSwitchIdx) - if (currentValue.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Sw) + if (currentValue.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Sw) { delta *= satAlpha; + } else { //Ensure Rvw and Rsw factor does not become negative - if (delta > currentValue[ Indices::waterSwitchIdx]) + if (delta > currentValue[ Indices::waterSwitchIdx]) { delta = currentValue[ Indices::waterSwitchIdx]; + } } else if (pvIdx == Indices::compositionSwitchIdx) { // the switching primary variable for composition is tricky because the @@ -303,8 +307,9 @@ class BlackOilNewtonMethod : public GetPropType currentValue[Indices::compositionSwitchIdx]) @@ -351,36 +356,43 @@ class BlackOilNewtonMethod : public GetPropType Date: Sun, 15 Sep 2024 22:18:58 +0200 Subject: [PATCH 02/33] BlackoilNewtonMethod: add struct holding parameters and put in blackoilnewthonmethodparameters.cpp --- CMakeLists_files.cmake | 1 + opm/models/blackoil/blackoilnewtonmethod.hpp | 98 +++++++------------ .../blackoilnewtonmethodparameters.cpp | 81 +++++++++++++++ .../blackoilnewtonmethodparameters.hpp | 30 ++++++ 4 files changed, 145 insertions(+), 65 deletions(-) create mode 100644 opm/models/blackoil/blackoilnewtonmethodparameters.cpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index d36d4a9296f..bf369a71c1c 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -59,6 +59,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/blackoil/blackoilextboparams.cpp opm/models/blackoil/blackoilfoamparams.cpp opm/models/blackoil/blackoilmicpparams.cpp + opm/models/blackoil/blackoilnewtonmethodparameters.cpp opm/models/blackoil/blackoilpolymerparams.cpp opm/models/blackoil/blackoilsolventparams.cpp opm/models/io/restart.cpp diff --git a/opm/models/blackoil/blackoilnewtonmethod.hpp b/opm/models/blackoil/blackoilnewtonmethod.hpp index a418064c876..124540f29e1 100644 --- a/opm/models/blackoil/blackoilnewtonmethod.hpp +++ b/opm/models/blackoil/blackoilnewtonmethod.hpp @@ -73,17 +73,7 @@ class BlackOilNewtonMethod : public GetPropType>(); - dpMaxRel_ = Parameters::Get>(); - dsMax_ = Parameters::Get>(); - projectSaturations_ = Parameters::Get(); - maxTempChange_ = Parameters::Get>(); - tempMax_ = Parameters::Get>(); - tempMin_ = Parameters::Get>(); - pressMax_ = Parameters::Get>(); - pressMin_ = Parameters::Get>(); - waterSaturationMax_ = Parameters::Get>(); - waterOnlyThreshold_ = Parameters::Get>(); + bparams_.read(); } /*! @@ -102,30 +92,7 @@ class BlackOilNewtonMethod : public GetPropType> - ("Maximum relative change of pressure in a single iteration"); - Parameters::Register> - ("Maximum absolute change of any saturation in a single iteration"); - Parameters::Register> - ("The threshold value for the primary variable switching conditions " - "after its meaning has switched to hinder oscilations"); - Parameters::Register - ("Option for doing saturation projection"); - Parameters::Register> - ("Maximum absolute change of temperature in a single iteration"); - Parameters::Register> - ("Maximum absolute temperature"); - Parameters::Register> - ("Minimum absolute temperature"); - Parameters::Register> - ("Maximum absolute pressure"); - Parameters::Register> - ("Minimum absolute pressure"); - Parameters::Register> - ("Maximum water saturation"); - Parameters::Register> - ("Cells with water saturation above or equal is considered one-phase water only"); + BlackoilNewtonParams::registerParameters(); } /*! @@ -272,8 +239,9 @@ class BlackOilNewtonMethod : public GetPropType dsMax_) - satAlpha = dsMax_/maxSatDelta; + if (maxSatDelta > bparams_.dsMax_) { + satAlpha = bparams_.dsMax_ / maxSatDelta; + } for (int pvIdx = 0; pvIdx < int(numEq); ++pvIdx) { // calculate the update of the current primary variable. For the black-oil @@ -286,8 +254,8 @@ class BlackOilNewtonMethod : public GetPropType params_.dpMaxRel_ * currentValue[pvIdx]) { - delta = signum(delta) * params_.dpMaxRel_ * currentValue[pvIdx]; + if (std::abs(delta) > bparams_.dpMaxRel_ * currentValue[pvIdx]) { + delta = signum(delta) * bparams_.dpMaxRel_ * currentValue[pvIdx]; } } // water saturation delta @@ -341,7 +309,7 @@ class BlackOilNewtonMethod : public GetPropType= 0. ? 1. : -1.; - delta = sign * std::min(std::abs(delta), maxTempChange_); + delta = sign * std::min(std::abs(delta), bparams_.maxTempChange_); } else if (enableBrine && pvIdx == Indices::saltConcentrationIdx && enableSaltPrecipitation && @@ -396,11 +364,12 @@ class BlackOilNewtonMethod : public GetPropTypeproblem(), globalDofIdx, waterSaturationMax_, waterOnlyThreshold_, priVarOscilationThreshold_); - else - wasSwitched_[globalDofIdx] = nextValue.adaptPrimaryVariables(this->problem(), globalDofIdx, waterSaturationMax_, waterOnlyThreshold_); - - if (wasSwitched_[globalDofIdx]) - ++ numPriVarsSwitched_; - if(projectSaturations_){ + if (wasSwitched_[globalDofIdx]) { + wasSwitched_[globalDofIdx] = nextValue.adaptPrimaryVariables(this->problem(), + globalDofIdx, + bparams_.waterSaturationMax_, + bparams_.waterOnlyThreshold_, + bparams_.priVarOscilationThreshold_); + } + else { + wasSwitched_[globalDofIdx] = nextValue.adaptPrimaryVariables(this->problem(), + globalDofIdx, + bparams_.waterSaturationMax_, + bparams_.waterOnlyThreshold_); + } + + if (wasSwitched_[globalDofIdx]) { + ++numPriVarsSwitched_; + } + if (bparams_.projectSaturations_) { nextValue.chopAndNormalizeSaturations(); } @@ -444,24 +423,13 @@ class BlackOilNewtonMethod : public GetPropType bparams_{}; // keep track of cells where the primary variable meaning has changed // to detect and hinder oscillations - std::vector wasSwitched_; + std::vector wasSwitched_{}; }; } // namespace Opm diff --git a/opm/models/blackoil/blackoilnewtonmethodparameters.cpp b/opm/models/blackoil/blackoilnewtonmethodparameters.cpp new file mode 100644 index 00000000000..444ec900f99 --- /dev/null +++ b/opm/models/blackoil/blackoilnewtonmethodparameters.cpp @@ -0,0 +1,81 @@ +// -*- 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 + +#include + +namespace Opm { + +template +void BlackoilNewtonParams::registerParameters() +{ + Parameters::Register> + ("Maximum relative change of pressure in a single iteration"); + Parameters::Register> + ("Maximum absolute change of any saturation in a single iteration"); + Parameters::Register> + ("The threshold value for the primary variable switching conditions " + "after its meaning has switched to hinder oscillations"); + Parameters::Register + ("Option for doing saturation projection"); + Parameters::Register> + ("Maximum absolute change of temperature in a single iteration"); + Parameters::Register> + ("Maximum absolute temperature"); + Parameters::Register> + ("Minimum absolute temperature"); + Parameters::Register> + ("Maximum absolute pressure"); + Parameters::Register> + ("Minimum absolute pressure"); + Parameters::Register> + ("Maximum water saturation"); + Parameters::Register> + ("Cells with water saturation above or equal is considered one-phase water only"); +} + +template +void BlackoilNewtonParams::read() +{ + priVarOscilationThreshold_ = Parameters::Get>(); + dpMaxRel_ = Parameters::Get>(); + dsMax_ = Parameters::Get>(); + projectSaturations_ = Parameters::Get(); + maxTempChange_ = Parameters::Get>(); + tempMax_ = Parameters::Get>(); + tempMin_ = Parameters::Get>(); + pressMax_ = Parameters::Get>(); + pressMin_ = Parameters::Get>(); + waterSaturationMax_ = Parameters::Get>(); + waterOnlyThreshold_ = Parameters::Get>(); +} + +template struct BlackoilNewtonParams; + +#if FLOW_INSTANTIATE_FLOAT +template struct BlackoilNewtonParams; +#endif + +} // namespace Opm diff --git a/opm/models/blackoil/blackoilnewtonmethodparameters.hpp b/opm/models/blackoil/blackoilnewtonmethodparameters.hpp index 6897083341f..7289e98a40a 100644 --- a/opm/models/blackoil/blackoilnewtonmethodparameters.hpp +++ b/opm/models/blackoil/blackoilnewtonmethodparameters.hpp @@ -64,4 +64,34 @@ struct WaterOnlyThreshold { static constexpr Scalar value = 1.0; }; } // namespace Opm::Parameters +namespace Opm { + +/*! + * \brief Struct holding the parameters for BlackoilNewtonMethod. + */ +template +struct BlackoilNewtonParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + Scalar priVarOscilationThreshold_; + Scalar waterSaturationMax_; + Scalar waterOnlyThreshold_; + + Scalar dpMaxRel_; + Scalar dsMax_; + bool projectSaturations_; + Scalar maxTempChange_; + Scalar tempMax_; + Scalar tempMin_; + Scalar pressMax_; + Scalar pressMin_; +}; + +} // namespace Opm + #endif From 44503c25e8ed4921223607a60710f2a35a57bd8b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 14:00:01 +0200 Subject: [PATCH 03/33] blackoilnewtonmethodparameters.hpp: rename to blackoilnewtonmethodparams.hpp for consistency --- CMakeLists_files.cmake | 4 ++-- opm/models/blackoil/blackoilnewtonmethod.hpp | 2 +- ...tonmethodparameters.cpp => blackoilnewtonmethodparams.cpp} | 2 +- ...tonmethodparameters.hpp => blackoilnewtonmethodparams.hpp} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename opm/models/blackoil/{blackoilnewtonmethodparameters.cpp => blackoilnewtonmethodparams.cpp} (98%) rename opm/models/blackoil/{blackoilnewtonmethodparameters.hpp => blackoilnewtonmethodparams.hpp} (100%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index bf369a71c1c..98c219d15a1 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -59,7 +59,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/blackoil/blackoilextboparams.cpp opm/models/blackoil/blackoilfoamparams.cpp opm/models/blackoil/blackoilmicpparams.cpp - opm/models/blackoil/blackoilnewtonmethodparameters.cpp + opm/models/blackoil/blackoilnewtonmethodparams.cpp opm/models/blackoil/blackoilpolymerparams.cpp opm/models/blackoil/blackoilsolventparams.cpp opm/models/io/restart.cpp @@ -555,7 +555,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/blackoil/blackoilmicpparams.hpp opm/models/blackoil/blackoilmodel.hh opm/models/blackoil/blackoilnewtonmethod.hpp - opm/models/blackoil/blackoilnewtonmethodparameters.hpp + opm/models/blackoil/blackoilnewtonmethodparams.hpp opm/models/blackoil/blackoilonephaseindices.hh opm/models/blackoil/blackoilpolymermodules.hh opm/models/blackoil/blackoilpolymerparams.hpp diff --git a/opm/models/blackoil/blackoilnewtonmethod.hpp b/opm/models/blackoil/blackoilnewtonmethod.hpp index 124540f29e1..125aedab0f4 100644 --- a/opm/models/blackoil/blackoilnewtonmethod.hpp +++ b/opm/models/blackoil/blackoilnewtonmethod.hpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include diff --git a/opm/models/blackoil/blackoilnewtonmethodparameters.cpp b/opm/models/blackoil/blackoilnewtonmethodparams.cpp similarity index 98% rename from opm/models/blackoil/blackoilnewtonmethodparameters.cpp rename to opm/models/blackoil/blackoilnewtonmethodparams.cpp index 444ec900f99..7e1fa1a5a90 100644 --- a/opm/models/blackoil/blackoilnewtonmethodparameters.cpp +++ b/opm/models/blackoil/blackoilnewtonmethodparams.cpp @@ -22,7 +22,7 @@ */ #include -#include +#include #include diff --git a/opm/models/blackoil/blackoilnewtonmethodparameters.hpp b/opm/models/blackoil/blackoilnewtonmethodparams.hpp similarity index 100% rename from opm/models/blackoil/blackoilnewtonmethodparameters.hpp rename to opm/models/blackoil/blackoilnewtonmethodparams.hpp From 6a1b33c7930904ec1455b733ea92eff0d71965e8 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sun, 15 Sep 2024 21:28:52 +0200 Subject: [PATCH 04/33] vtkblackoilmodule.hh: rename to vtkblackoilmodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/blackoil/blackoilmodel.hh | 2 +- .../{vtkblackoilmodule.hh => vtkblackoilmodule.hpp} | 12 ++++++------ opm/simulators/flow/FlowUtils.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename opm/models/io/{vtkblackoilmodule.hh => vtkblackoilmodule.hpp} (98%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 98c219d15a1..450d1fdedc6 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -651,7 +651,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/unstructuredgridvanguard.hh opm/models/io/vtkblackoilenergymodule.hh opm/models/io/vtkblackoilmicpmodule.hh - opm/models/io/vtkblackoilmodule.hh + opm/models/io/vtkblackoilmodule.hpp opm/models/io/vtkblackoilpolymermodule.hh opm/models/io/vtkblackoilsolventmodule.hh opm/models/io/vtkcompositionmodule.hh diff --git a/opm/models/blackoil/blackoilmodel.hh b/opm/models/blackoil/blackoilmodel.hh index ff71785b96b..4706c689cf3 100644 --- a/opm/models/blackoil/blackoilmodel.hh +++ b/opm/models/blackoil/blackoilmodel.hh @@ -55,7 +55,7 @@ #include -#include +#include #include #include diff --git a/opm/models/io/vtkblackoilmodule.hh b/opm/models/io/vtkblackoilmodule.hpp similarity index 98% rename from opm/models/io/vtkblackoilmodule.hh rename to opm/models/io/vtkblackoilmodule.hpp index 30b8127ad92..9c2d52b9d69 100644 --- a/opm/models/io/vtkblackoilmodule.hh +++ b/opm/models/io/vtkblackoilmodule.hpp @@ -24,11 +24,8 @@ * \file * \copydoc Opm::VtkBlackOilModule */ -#ifndef EWOMS_VTK_BLACK_OIL_MODULE_HH -#define EWOMS_VTK_BLACK_OIL_MODULE_HH - -#include "vtkmultiwriter.hh" -#include "baseoutputmodule.hh" +#ifndef OPM_VTK_BLACK_OIL_MODULE_HPP +#define OPM_VTK_BLACK_OIL_MODULE_HPP #include @@ -38,6 +35,9 @@ #include +#include +#include + #include #include @@ -389,4 +389,4 @@ class VtkBlackOilModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_BLACK_OIL_MODULE_HPP diff --git a/opm/simulators/flow/FlowUtils.cpp b/opm/simulators/flow/FlowUtils.cpp index db63cfee42f..0f86917bac8 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include From a44640bc659c5d2d0251992549deafcfa4beb996 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 05/33] vtkblackoilmodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkblackoilmodule.hpp | 268 ++++++++++------------------ opm/models/io/vtkblackoilparams.cpp | 82 +++++++++ opm/models/io/vtkblackoilparams.hpp | 75 ++++++++ 4 files changed, 254 insertions(+), 173 deletions(-) create mode 100644 opm/models/io/vtkblackoilparams.cpp create mode 100644 opm/models/io/vtkblackoilparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 450d1fdedc6..d1df4df7bda 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -62,6 +62,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/blackoil/blackoilnewtonmethodparams.cpp opm/models/blackoil/blackoilpolymerparams.cpp opm/models/blackoil/blackoilsolventparams.cpp + opm/models/io/vtkblackoilparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -652,6 +653,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkblackoilenergymodule.hh opm/models/io/vtkblackoilmicpmodule.hh opm/models/io/vtkblackoilmodule.hpp + opm/models/io/vtkblackoilparams.hpp opm/models/io/vtkblackoilpolymermodule.hh opm/models/io/vtkblackoilsolventmodule.hh opm/models/io/vtkcompositionmodule.hh diff --git a/opm/models/io/vtkblackoilmodule.hpp b/opm/models/io/vtkblackoilmodule.hpp index 9c2d52b9d69..4d23ff2f69d 100644 --- a/opm/models/io/vtkblackoilmodule.hpp +++ b/opm/models/io/vtkblackoilmodule.hpp @@ -36,28 +36,12 @@ #include #include +#include #include #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteGasDissolutionFactor { static constexpr bool value = false; }; -struct VtkWriteOilVaporizationFactor { static constexpr bool value = false; }; -struct VtkWriteOilFormationVolumeFactor { static constexpr bool value = false; }; -struct VtkWriteGasFormationVolumeFactor { static constexpr bool value = false; }; -struct VtkWriteWaterFormationVolumeFactor { static constexpr bool value = false; }; -struct VtkWriteOilSaturationPressure { static constexpr bool value = false; }; -struct VtkWriteGasSaturationPressure { static constexpr bool value = false; }; -struct VtkWriteSaturationRatios { static constexpr bool value = false; }; -struct VtkWriteSaturatedOilGasDissolutionFactor { static constexpr bool value = false; }; -struct VtkWriteSaturatedGasOilVaporizationFactor { static constexpr bool value = false; }; -struct VtkWritePrimaryVarsMeaning { static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { /*! * \ingroup Vtk @@ -93,7 +77,9 @@ class VtkBlackOilModule : public BaseOutputModule public: VtkBlackOilModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the multi-phase VTK output @@ -101,38 +87,7 @@ class VtkBlackOilModule : public BaseOutputModule */ static void registerParameters() { - Parameters::Register - ("Include the gas dissolution factor (R_s) of the observed oil " - "in the VTK output files"); - Parameters::Register - ("Include the oil vaporization factor (R_v) of the observed gas " - "in the VTK output files"); - Parameters::Register - ("Include the oil formation volume factor (B_o) in the VTK output files"); - Parameters::Register - ("Include the gas formation volume factor (B_g) in the " - "VTK output files"); - Parameters::Register - ("Include the water formation volume factor (B_w) in the " - "VTK output files"); - Parameters::Register - ("Include the saturation pressure of oil (p_o,sat) in the " - "VTK output files"); - Parameters::Register - ("Include the saturation pressure of gas (p_g,sat) in the " - "VTK output files"); - Parameters::Register - ("Include the gas dissolution factor (R_s,sat) of gas saturated " - "oil in the VTK output files"); - Parameters::Register - ("Include the oil vaporization factor (R_v,sat) of oil saturated " - "gas in the VTK output files"); - Parameters::Register - ("Write the ratio of the actually and maximum dissolved component of " - "the mixtures"); - Parameters::Register - ("Include how the primary variables should be interpreted to the " - "VTK output files"); + VtkBlackoilParams::registerParameters(); } /*! @@ -141,29 +96,38 @@ class VtkBlackOilModule : public BaseOutputModule */ void allocBuffers() { - if (gasDissolutionFactorOutput_()) + if (params_.gasDissolutionFactorOutput_) { this->resizeScalarBuffer_(gasDissolutionFactor_); - if (oilVaporizationFactorOutput_()) + } + if (params_.oilVaporizationFactorOutput_) { this->resizeScalarBuffer_(oilVaporizationFactor_); - if (oilFormationVolumeFactorOutput_()) + } + if (params_.oilFormationVolumeFactorOutput_) { this->resizeScalarBuffer_(oilFormationVolumeFactor_); - if (gasFormationVolumeFactorOutput_()) + } + if (params_.gasFormationVolumeFactorOutput_) { this->resizeScalarBuffer_(gasFormationVolumeFactor_); - if (waterFormationVolumeFactorOutput_()) + } + if (params_.waterFormationVolumeFactorOutput_) { this->resizeScalarBuffer_(waterFormationVolumeFactor_); - if (oilSaturationPressureOutput_()) + } + if (params_.oilSaturationPressureOutput_) { this->resizeScalarBuffer_(oilSaturationPressure_); - if (gasSaturationPressureOutput_()) + } + if (params_.gasSaturationPressureOutput_) { this->resizeScalarBuffer_(gasSaturationPressure_); - if (saturatedOilGasDissolutionFactorOutput_()) + } + if (params_.saturatedOilGasDissolutionFactorOutput_) { this->resizeScalarBuffer_(saturatedOilGasDissolutionFactor_); - if (saturatedGasOilVaporizationFactorOutput_()) + } + if (params_.saturatedGasOilVaporizationFactorOutput_) { this->resizeScalarBuffer_(saturatedGasOilVaporizationFactor_); - if (saturationRatiosOutput_()) { + } + if (params_.saturationRatiosOutput_) { this->resizeScalarBuffer_(oilSaturationRatio_); this->resizeScalarBuffer_(gasSaturationRatio_); } - if (primaryVarsMeaningOutput_()) { + if (params_.primaryVarsMeaningOutput_) { this->resizeScalarBuffer_(primaryVarsMeaningPressure_); this->resizeScalarBuffer_(primaryVarsMeaningWater_); this->resizeScalarBuffer_(primaryVarsMeaningGas_); @@ -216,43 +180,56 @@ class VtkBlackOilModule : public BaseOutputModule SoMax); Scalar X_gO_sat = FluidSystem::convertRvToXgO(RvSat, pvtRegionIdx); Scalar x_gO_sat = FluidSystem::convertXgOToxgO(X_gO_sat, pvtRegionIdx); - if (gasDissolutionFactorOutput_()) + if (params_.gasDissolutionFactorOutput_) { gasDissolutionFactor_[globalDofIdx] = Rs; - if (oilVaporizationFactorOutput_()) + } + if (params_.oilVaporizationFactorOutput_) { oilVaporizationFactor_[globalDofIdx] = Rv; - if (oilSaturationPressureOutput_()) + } + if (params_.oilSaturationPressureOutput_) { oilSaturationPressure_[globalDofIdx] = FluidSystem::template saturationPressure(fs, oilPhaseIdx, pvtRegionIdx); - if (gasSaturationPressureOutput_()) + } + if (params_.gasSaturationPressureOutput_) { gasSaturationPressure_[globalDofIdx] = FluidSystem::template saturationPressure(fs, gasPhaseIdx, pvtRegionIdx); - if (saturatedOilGasDissolutionFactorOutput_()) + } + if (params_.saturatedOilGasDissolutionFactorOutput_) { saturatedOilGasDissolutionFactor_[globalDofIdx] = RsSat; - if (saturatedGasOilVaporizationFactorOutput_()) + } + if (params_.saturatedGasOilVaporizationFactorOutput_) { saturatedGasOilVaporizationFactor_[globalDofIdx] = RvSat; - if (saturationRatiosOutput_()) { - if (x_oG_sat <= 0.0) + } + if (params_.saturationRatiosOutput_) { + if (x_oG_sat <= 0.0) { oilSaturationRatio_[globalDofIdx] = 1.0; - else + } + else { oilSaturationRatio_[globalDofIdx] = x_oG / x_oG_sat; + } - if (x_gO_sat <= 0.0) + if (x_gO_sat <= 0.0) { gasSaturationRatio_[globalDofIdx] = 1.0; - else + } + else { gasSaturationRatio_[globalDofIdx] = x_gO / x_gO_sat; + } } } - if (oilFormationVolumeFactorOutput_()) + if (params_.oilFormationVolumeFactorOutput_) { oilFormationVolumeFactor_[globalDofIdx] = - 1.0/FluidSystem::template inverseFormationVolumeFactor(fs, oilPhaseIdx, pvtRegionIdx); - if (gasFormationVolumeFactorOutput_()) + 1.0 / FluidSystem::template inverseFormationVolumeFactor(fs, oilPhaseIdx, pvtRegionIdx); + } + if (params_.gasFormationVolumeFactorOutput_) { gasFormationVolumeFactor_[globalDofIdx] = - 1.0/FluidSystem::template inverseFormationVolumeFactor(fs, gasPhaseIdx, pvtRegionIdx); - if (waterFormationVolumeFactorOutput_()) + 1.0 / FluidSystem::template inverseFormationVolumeFactor(fs, gasPhaseIdx, pvtRegionIdx); + } + if (params_.waterFormationVolumeFactorOutput_) { waterFormationVolumeFactor_[globalDofIdx] = - 1.0/FluidSystem::template inverseFormationVolumeFactor(fs, waterPhaseIdx, pvtRegionIdx); + 1.0 / FluidSystem::template inverseFormationVolumeFactor(fs, waterPhaseIdx, pvtRegionIdx); + } - if (primaryVarsMeaningOutput_()) { + if (params_.primaryVarsMeaningOutput_) { primaryVarsMeaningWater_[globalDofIdx] = static_cast(primaryVars.primaryVarsMeaningWater()); primaryVarsMeaningGas_[globalDofIdx] = @@ -269,33 +246,43 @@ class VtkBlackOilModule : public BaseOutputModule void commitBuffers(BaseOutputWriter& baseWriter) { VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); - if (!vtkWriter) + if (!vtkWriter) { return; + } - if (gasDissolutionFactorOutput_()) + if (params_.gasDissolutionFactorOutput_) { this->commitScalarBuffer_(baseWriter, "R_s", gasDissolutionFactor_); - if (oilVaporizationFactorOutput_()) + } + if (params_.oilVaporizationFactorOutput_) { this->commitScalarBuffer_(baseWriter, "R_v", oilVaporizationFactor_); - if (oilFormationVolumeFactorOutput_()) + } + if (params_.oilFormationVolumeFactorOutput_) { this->commitScalarBuffer_(baseWriter, "B_o", oilFormationVolumeFactor_); - if (gasFormationVolumeFactorOutput_()) + } + if (params_.gasFormationVolumeFactorOutput_) { this->commitScalarBuffer_(baseWriter, "B_g", gasFormationVolumeFactor_); - if (waterFormationVolumeFactorOutput_()) + } + if (params_.waterFormationVolumeFactorOutput_) { this->commitScalarBuffer_(baseWriter, "B_w", waterFormationVolumeFactor_); - if (oilSaturationPressureOutput_()) + } + if (params_.oilSaturationPressureOutput_) { this->commitScalarBuffer_(baseWriter, "p_o,sat", oilSaturationPressure_); - if (gasSaturationPressureOutput_()) + } + if (params_.gasSaturationPressureOutput_) { this->commitScalarBuffer_(baseWriter, "p_g,sat", gasSaturationPressure_); - if (saturatedOilGasDissolutionFactorOutput_()) + } + if (params_.saturatedOilGasDissolutionFactorOutput_) { this->commitScalarBuffer_(baseWriter, "R_s,sat", saturatedOilGasDissolutionFactor_); - if (saturatedGasOilVaporizationFactorOutput_()) + } + if (params_.saturatedGasOilVaporizationFactorOutput_) { this->commitScalarBuffer_(baseWriter, "R_v,sat", saturatedGasOilVaporizationFactor_); - if (saturationRatiosOutput_()) { + } + if (params_.saturationRatiosOutput_) { this->commitScalarBuffer_(baseWriter, "saturation ratio_oil", oilSaturationRatio_); this->commitScalarBuffer_(baseWriter, "saturation ratio_gas", gasSaturationRatio_); } - if (primaryVarsMeaningOutput_()) { + if (params_.primaryVarsMeaningOutput_) { this->commitScalarBuffer_(baseWriter, "primary vars meaning water", primaryVarsMeaningWater_); this->commitScalarBuffer_(baseWriter, "primary vars meaning gas", primaryVarsMeaningGas_); this->commitScalarBuffer_(baseWriter, "primary vars meaning pressure", primaryVarsMeaningPressure_); @@ -303,88 +290,23 @@ class VtkBlackOilModule : public BaseOutputModule } private: - static bool gasDissolutionFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool oilVaporizationFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool oilFormationVolumeFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool gasFormationVolumeFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool waterFormationVolumeFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool oilSaturationPressureOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool gasSaturationPressureOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool saturatedOilGasDissolutionFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool saturatedGasOilVaporizationFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool saturationRatiosOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool primaryVarsMeaningOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ScalarBuffer gasDissolutionFactor_; - ScalarBuffer oilVaporizationFactor_; - ScalarBuffer oilFormationVolumeFactor_; - ScalarBuffer gasFormationVolumeFactor_; - ScalarBuffer waterFormationVolumeFactor_; - ScalarBuffer oilSaturationPressure_; - ScalarBuffer gasSaturationPressure_; - - ScalarBuffer saturatedOilGasDissolutionFactor_; - ScalarBuffer saturatedGasOilVaporizationFactor_; - ScalarBuffer oilSaturationRatio_; - ScalarBuffer gasSaturationRatio_; - - ScalarBuffer primaryVarsMeaningPressure_; - ScalarBuffer primaryVarsMeaningWater_; - ScalarBuffer primaryVarsMeaningGas_; + VtkBlackoilParams params_{}; + ScalarBuffer gasDissolutionFactor_{}; + ScalarBuffer oilVaporizationFactor_{}; + ScalarBuffer oilFormationVolumeFactor_{}; + ScalarBuffer gasFormationVolumeFactor_{}; + ScalarBuffer waterFormationVolumeFactor_{}; + ScalarBuffer oilSaturationPressure_{}; + ScalarBuffer gasSaturationPressure_{}; + + ScalarBuffer saturatedOilGasDissolutionFactor_{}; + ScalarBuffer saturatedGasOilVaporizationFactor_{}; + ScalarBuffer oilSaturationRatio_{}; + ScalarBuffer gasSaturationRatio_{}; + + ScalarBuffer primaryVarsMeaningPressure_{}; + ScalarBuffer primaryVarsMeaningWater_{}; + ScalarBuffer primaryVarsMeaningGas_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilparams.cpp b/opm/models/io/vtkblackoilparams.cpp new file mode 100644 index 00000000000..90c93fbcf0f --- /dev/null +++ b/opm/models/io/vtkblackoilparams.cpp @@ -0,0 +1,82 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkBlackoilParams::registerParameters() +{ + Parameters::Register + ("Include the gas dissolution factor (R_s) of the observed oil " + "in the VTK output files"); + Parameters::Register + ("Include the oil vaporization factor (R_v) of the observed gas " + "in the VTK output files"); + Parameters::Register + ("Include the oil formation volume factor (B_o) in the VTK output files"); + Parameters::Register + ("Include the gas formation volume factor (B_g) in the " + "VTK output files"); + Parameters::Register + ("Include the water formation volume factor (B_w) in the " + "VTK output files"); + Parameters::Register + ("Include the saturation pressure of oil (p_o,sat) in the " + "VTK output files"); + Parameters::Register + ("Include the saturation pressure of gas (p_g,sat) in the " + "VTK output files"); + Parameters::Register + ("Include the gas dissolution factor (R_s,sat) of gas saturated " + "oil in the VTK output files"); + Parameters::Register + ("Include the oil vaporization factor (R_v,sat) of oil saturated " + "gas in the VTK output files"); + Parameters::Register + ("Write the ratio of the actually and maximum dissolved component of " + "the mixtures"); + Parameters::Register + ("Include how the primary variables should be interpreted to the " + "VTK output files"); +} + +void VtkBlackoilParams::read() +{ + gasDissolutionFactorOutput_ = Parameters::Get(); + oilVaporizationFactorOutput_ = Parameters::Get(); + oilFormationVolumeFactorOutput_ = Parameters::Get(); + gasFormationVolumeFactorOutput_ = Parameters::Get(); + waterFormationVolumeFactorOutput_ = Parameters::Get(); + oilSaturationPressureOutput_ = Parameters::Get(); + gasSaturationPressureOutput_ = Parameters::Get(); + saturatedOilGasDissolutionFactorOutput_ = Parameters::Get(); + saturatedGasOilVaporizationFactorOutput_ = Parameters::Get(); + saturationRatiosOutput_ = Parameters::Get(); + primaryVarsMeaningOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkblackoilparams.hpp b/opm/models/io/vtkblackoilparams.hpp new file mode 100644 index 00000000000..5fc29074b6b --- /dev/null +++ b/opm/models/io/vtkblackoilparams.hpp @@ -0,0 +1,75 @@ +// -*- 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::VtkBlackOilModule + */ +#ifndef OPM_VTK_BLACK_OIL_PARAMS_HPP +#define OPM_VTK_BLACK_OIL_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteGasDissolutionFactor { static constexpr bool value = false; }; +struct VtkWriteOilVaporizationFactor { static constexpr bool value = false; }; +struct VtkWriteOilFormationVolumeFactor { static constexpr bool value = false; }; +struct VtkWriteGasFormationVolumeFactor { static constexpr bool value = false; }; +struct VtkWriteWaterFormationVolumeFactor { static constexpr bool value = false; }; +struct VtkWriteOilSaturationPressure { static constexpr bool value = false; }; +struct VtkWriteGasSaturationPressure { static constexpr bool value = false; }; +struct VtkWriteSaturationRatios { static constexpr bool value = false; }; +struct VtkWriteSaturatedOilGasDissolutionFactor { static constexpr bool value = false; }; +struct VtkWriteSaturatedGasOilVaporizationFactor { static constexpr bool value = false; }; +struct VtkWritePrimaryVarsMeaning { static constexpr bool value = false; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkBlackoilOutputModule. + */ +struct VtkBlackoilParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool gasDissolutionFactorOutput_; + bool oilVaporizationFactorOutput_; + bool oilFormationVolumeFactorOutput_; + bool gasFormationVolumeFactorOutput_; + bool waterFormationVolumeFactorOutput_; + bool oilSaturationPressureOutput_; + bool gasSaturationPressureOutput_; + bool saturatedOilGasDissolutionFactorOutput_; + bool saturatedGasOilVaporizationFactorOutput_; + bool saturationRatiosOutput_; + bool primaryVarsMeaningOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_BLACK_OIL_PARAMS_HPP From e50cd2fb8257f3dcbd778757a45c5730f97374a4 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:51:37 +0200 Subject: [PATCH 06/33] vtkblackoilenergymodules.hh: rename to vtkblackoilenergymodules.hpp --- CMakeLists_files.cmake | 2 +- opm/models/blackoil/blackoilenergymodules.hh | 2 +- ...lackoilenergymodule.hh => vtkblackoilenergymodule.hpp} | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) rename opm/models/io/{vtkblackoilenergymodule.hh => vtkblackoilenergymodule.hpp} (98%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index d1df4df7bda..45221029125 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -650,7 +650,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/simplexvanguard.hh opm/models/io/structuredgridvanguard.hh opm/models/io/unstructuredgridvanguard.hh - opm/models/io/vtkblackoilenergymodule.hh + opm/models/io/vtkblackoilenergymodule.hpp opm/models/io/vtkblackoilmicpmodule.hh opm/models/io/vtkblackoilmodule.hpp opm/models/io/vtkblackoilparams.hpp diff --git a/opm/models/blackoil/blackoilenergymodules.hh b/opm/models/blackoil/blackoilenergymodules.hh index 9e83fc744f1..ef20fa96bce 100644 --- a/opm/models/blackoil/blackoilenergymodules.hh +++ b/opm/models/blackoil/blackoilenergymodules.hh @@ -29,7 +29,7 @@ #define EWOMS_BLACK_OIL_ENERGY_MODULE_HH #include "blackoilproperties.hh" -#include +#include #include #include diff --git a/opm/models/io/vtkblackoilenergymodule.hh b/opm/models/io/vtkblackoilenergymodule.hpp similarity index 98% rename from opm/models/io/vtkblackoilenergymodule.hh rename to opm/models/io/vtkblackoilenergymodule.hpp index 1fcfb516a5b..27b492775b3 100644 --- a/opm/models/io/vtkblackoilenergymodule.hh +++ b/opm/models/io/vtkblackoilenergymodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkBlackOilEnergyModule */ -#ifndef EWOMS_VTK_BLACK_OIL_ENERGY_MODULE_HH -#define EWOMS_VTK_BLACK_OIL_ENERGY_MODULE_HH +#ifndef OPM_VTK_BLACK_OIL_ENERGY_MODULE_HPP +#define OPM_VTK_BLACK_OIL_ENERGY_MODULE_HPP #include @@ -52,6 +52,7 @@ struct VtkWriteFluidEnthalpies { static constexpr bool value = true; }; } // namespace Opm::Parameters namespace Opm { + /*! * \ingroup Vtk * @@ -221,6 +222,7 @@ class VtkBlackOilEnergyModule : public BaseOutputModule PhaseBuffer fluidInternalEnergies_; PhaseBuffer fluidEnthalpies_; }; + } // namespace Opm -#endif +#endif // OPM_VTK_BLACKOIL_ENERGY_MODULE_HPP From 7a92006ffe8e307de40ec3ec22150aa2a80afc30 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 07/33] vtkblackoilenergymodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkblackoilenergymodule.hpp | 179 +++++++++------------- opm/models/io/vtkblackoilenergyparams.cpp | 53 +++++++ opm/models/io/vtkblackoilenergyparams.hpp | 61 ++++++++ 4 files changed, 192 insertions(+), 103 deletions(-) create mode 100644 opm/models/io/vtkblackoilenergyparams.cpp create mode 100644 opm/models/io/vtkblackoilenergyparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 45221029125..a18d8d1f11e 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -62,6 +62,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/blackoil/blackoilnewtonmethodparams.cpp opm/models/blackoil/blackoilpolymerparams.cpp opm/models/blackoil/blackoilsolventparams.cpp + opm/models/io/vtkblackoilenergyparams.cpp opm/models/io/vtkblackoilparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp @@ -651,6 +652,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/structuredgridvanguard.hh opm/models/io/unstructuredgridvanguard.hh opm/models/io/vtkblackoilenergymodule.hpp + opm/models/io/vtkblackoilenergyparams.hpp opm/models/io/vtkblackoilmicpmodule.hh opm/models/io/vtkblackoilmodule.hpp opm/models/io/vtkblackoilparams.hpp diff --git a/opm/models/io/vtkblackoilenergymodule.hpp b/opm/models/io/vtkblackoilenergymodule.hpp index 27b492775b3..589584393f6 100644 --- a/opm/models/io/vtkblackoilenergymodule.hpp +++ b/opm/models/io/vtkblackoilenergymodule.hpp @@ -36,21 +36,12 @@ #include #include +#include #include #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteRockInternalEnergy { static constexpr bool value = true; }; -struct VtkWriteTotalThermalConductivity { static constexpr bool value = true; }; -struct VtkWriteFluidInternalEnergies { static constexpr bool value = true; }; -struct VtkWriteFluidEnthalpies { static constexpr bool value = true; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -82,7 +73,11 @@ class VtkBlackOilEnergyModule : public BaseOutputModule public: VtkBlackOilEnergyModule(const Simulator& simulator) : ParentType(simulator) - { } + { + if constexpr (enableEnergy) { + params_.read(); + } + } /*! * \brief Register all run-time parameters for the multi-phase VTK output @@ -90,19 +85,9 @@ class VtkBlackOilEnergyModule : public BaseOutputModule */ static void registerParameters() { - if (!enableEnergy) - return; - - Parameters::Register - ("Include the volumetric internal energy of rock " - "in the VTK output files"); - Parameters::Register - ("Include the total thermal conductivity of the medium and the fluids " - "in the VTK output files"); - Parameters::Register - ("Include the internal energies of the fluids in the VTK output files"); - Parameters::Register - ("Include the enthalpies of the fluids in the VTK output files"); + if constexpr (enableEnergy) { + VtkBlackoilEnergyParams::registerParameters(); + } } /*! @@ -111,21 +96,24 @@ class VtkBlackOilEnergyModule : public BaseOutputModule */ void allocBuffers() { - if (!Parameters::Get()) { - return; - } + if constexpr (enableEnergy) { + if (!Parameters::Get()) { + return; + } - if (!enableEnergy) - return; - - if (rockInternalEnergyOutput_()) - this->resizeScalarBuffer_(rockInternalEnergy_); - if (totalThermalConductivityOutput_()) - this->resizeScalarBuffer_(totalThermalConductivity_); - if (fluidInternalEnergiesOutput_()) - this->resizePhaseBuffer_(fluidInternalEnergies_); - if (fluidEnthalpiesOutput_()) - this->resizePhaseBuffer_(fluidEnthalpies_); + if (params_.rockInternalEnergyOutput_) { + this->resizeScalarBuffer_(rockInternalEnergy_); + } + if (params_.totalThermalConductivityOutput_) { + this->resizeScalarBuffer_(totalThermalConductivity_); + } + if (params_.fluidInternalEnergiesOutput_) { + this->resizePhaseBuffer_(fluidInternalEnergies_); + } + if (params_.fluidEnthalpiesOutput_) { + this->resizePhaseBuffer_(fluidEnthalpies_); + } + } } /*! @@ -134,34 +122,37 @@ class VtkBlackOilEnergyModule : public BaseOutputModule */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::Get()) { - return; - } - - if (!enableEnergy) - return; - - for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) { - const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0); - unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); + if constexpr (enableEnergy) { + if (!Parameters::Get()) { + return; + } - if (rockInternalEnergyOutput_()) - rockInternalEnergy_[globalDofIdx] = - scalarValue(intQuants.rockInternalEnergy()); + for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) { + const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0); + unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); - if (totalThermalConductivityOutput_()) - totalThermalConductivity_[globalDofIdx] = - scalarValue(intQuants.totalThermalConductivity()); + if (params_.rockInternalEnergyOutput_) { + rockInternalEnergy_[globalDofIdx] = + scalarValue(intQuants.rockInternalEnergy()); + } - for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { - if (FluidSystem::phaseIsActive(phaseIdx)) { - if (fluidInternalEnergiesOutput_()) - fluidInternalEnergies_[phaseIdx][globalDofIdx] = - scalarValue(intQuants.fluidState().internalEnergy(phaseIdx)); + if (params_.totalThermalConductivityOutput_) { + totalThermalConductivity_[globalDofIdx] = + scalarValue(intQuants.totalThermalConductivity()); + } - if (fluidEnthalpiesOutput_()) - fluidEnthalpies_[phaseIdx][globalDofIdx] = - scalarValue(intQuants.fluidState().enthalpy(phaseIdx)); + for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { + if (FluidSystem::phaseIsActive(phaseIdx)) { + if (params_.fluidInternalEnergiesOutput_) { + fluidInternalEnergies_[phaseIdx][globalDofIdx] = + scalarValue(intQuants.fluidState().internalEnergy(phaseIdx)); + } + + if (params_.fluidEnthalpiesOutput_) { + fluidEnthalpies_[phaseIdx][globalDofIdx] = + scalarValue(intQuants.fluidState().enthalpy(phaseIdx)); + } + } } } } @@ -172,55 +163,37 @@ class VtkBlackOilEnergyModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); - if (!vtkWriter) - return; - - if (!enableEnergy) - return; + if constexpr (enableEnergy) { + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); + if (!vtkWriter) { + return; + } - if (rockInternalEnergyOutput_()) - this->commitScalarBuffer_(baseWriter, "volumetric internal energy rock", rockInternalEnergy_); + if (params_.rockInternalEnergyOutput_) { + this->commitScalarBuffer_(baseWriter, "volumetric internal energy rock", rockInternalEnergy_); + } - if (totalThermalConductivityOutput_()) - this->commitScalarBuffer_(baseWriter, "total thermal conductivity", totalThermalConductivity_); + if (params_.totalThermalConductivityOutput_) { + this->commitScalarBuffer_(baseWriter, "total thermal conductivity", totalThermalConductivity_); + } - if (fluidInternalEnergiesOutput_()) - this->commitPhaseBuffer_(baseWriter, "internal energy_%s", fluidInternalEnergies_); + if (params_.fluidInternalEnergiesOutput_) { + this->commitPhaseBuffer_(baseWriter, "internal energy_%s", fluidInternalEnergies_); + } - if (fluidEnthalpiesOutput_()) - this->commitPhaseBuffer_(baseWriter, "enthalpy_%s", fluidEnthalpies_); + if (params_.fluidEnthalpiesOutput_) { + this->commitPhaseBuffer_(baseWriter, "enthalpy_%s", fluidEnthalpies_); + } + } } private: - static bool rockInternalEnergyOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool totalThermalConductivityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool fluidInternalEnergiesOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool fluidEnthalpiesOutput_() - { - static bool val = Parameters::Get(); - return val; - } + VtkBlackoilEnergyParams params_{}; - ScalarBuffer rockInternalEnergy_; - ScalarBuffer totalThermalConductivity_; - PhaseBuffer fluidInternalEnergies_; - PhaseBuffer fluidEnthalpies_; + ScalarBuffer rockInternalEnergy_{}; + ScalarBuffer totalThermalConductivity_{}; + PhaseBuffer fluidInternalEnergies_{}; + PhaseBuffer fluidEnthalpies_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilenergyparams.cpp b/opm/models/io/vtkblackoilenergyparams.cpp new file mode 100644 index 00000000000..f668f6fa58b --- /dev/null +++ b/opm/models/io/vtkblackoilenergyparams.cpp @@ -0,0 +1,53 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkBlackoilEnergyParams::registerParameters() +{ + Parameters::Register + ("Include the volumetric internal energy of rock " + "in the VTK output files"); + Parameters::Register + ("Include the total thermal conductivity of the medium and the fluids " + "in the VTK output files"); + Parameters::Register + ("Include the internal energies of the fluids in the VTK output files"); + Parameters::Register + ("Include the enthalpies of the fluids in the VTK output files"); +} + +void VtkBlackoilEnergyParams::read() +{ + rockInternalEnergyOutput_ = Parameters::Get(); + totalThermalConductivityOutput_ = Parameters::Get(); + fluidInternalEnergiesOutput_ = Parameters::Get(); + fluidEnthalpiesOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkblackoilenergyparams.hpp b/opm/models/io/vtkblackoilenergyparams.hpp new file mode 100644 index 00000000000..3fceb437b93 --- /dev/null +++ b/opm/models/io/vtkblackoilenergyparams.hpp @@ -0,0 +1,61 @@ +// -*- 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::VtkBlackOilEnergyModule + */ +#ifndef OPM_VTK_BLACK_OIL_ENERGY_PARAMS_HPP +#define OPM_VTK_BLACK_OIL_ENERGY_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteRockInternalEnergy { static constexpr bool value = true; }; +struct VtkWriteTotalThermalConductivity { static constexpr bool value = true; }; +struct VtkWriteFluidInternalEnergies { static constexpr bool value = true; }; +struct VtkWriteFluidEnthalpies { static constexpr bool value = true; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkBlackoilEnergyOutputModule. + */ +struct VtkBlackoilEnergyParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool rockInternalEnergyOutput_; + bool totalThermalConductivityOutput_; + bool fluidInternalEnergiesOutput_; + bool fluidEnthalpiesOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_BLACKOIL_ENERGY_PARAMS_HPP From 28bbe60b6efa322e917995b36a5ccb9623554899 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:51:37 +0200 Subject: [PATCH 08/33] vtkblackoilmicpmodule.hh: rename to vtkblackoilmicpmodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/blackoil/blackoilmicpmodules.hh | 2 +- .../{vtkblackoilmicpmodule.hh => vtkblackoilmicpmodule.hpp} | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename opm/models/io/{vtkblackoilmicpmodule.hh => vtkblackoilmicpmodule.hpp} (98%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index a18d8d1f11e..e511bf6f661 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -653,7 +653,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/unstructuredgridvanguard.hh opm/models/io/vtkblackoilenergymodule.hpp opm/models/io/vtkblackoilenergyparams.hpp - opm/models/io/vtkblackoilmicpmodule.hh + opm/models/io/vtkblackoilmicpmodule.hpp opm/models/io/vtkblackoilmodule.hpp opm/models/io/vtkblackoilparams.hpp opm/models/io/vtkblackoilpolymermodule.hh diff --git a/opm/models/blackoil/blackoilmicpmodules.hh b/opm/models/blackoil/blackoilmicpmodules.hh index f027237f6ba..507eef35205 100644 --- a/opm/models/blackoil/blackoilmicpmodules.hh +++ b/opm/models/blackoil/blackoilmicpmodules.hh @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/io/vtkblackoilmicpmodule.hh b/opm/models/io/vtkblackoilmicpmodule.hpp similarity index 98% rename from opm/models/io/vtkblackoilmicpmodule.hh rename to opm/models/io/vtkblackoilmicpmodule.hpp index 95723b440a1..c94507f7889 100644 --- a/opm/models/io/vtkblackoilmicpmodule.hh +++ b/opm/models/io/vtkblackoilmicpmodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkBlackOilMICPModule */ -#ifndef EWOMS_VTK_BLACK_OIL_MICP_MODULE_HH -#define EWOMS_VTK_BLACK_OIL_MICP_MODULE_HH +#ifndef OPM_VTK_BLACK_OIL_MICP_MODULE_HPP +#define OPM_VTK_BLACK_OIL_MICP_MODULE_HPP #include @@ -239,4 +239,4 @@ class VtkBlackOilMICPModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_BLACKOIL_MICP_MODULE_HPP From ce4e57dab329d740ed8c3682eaff53193bd44475 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 09/33] vtkblackoilmicpmodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkblackoilmicpmodule.hpp | 227 ++++++++++-------------- opm/models/io/vtkblackoilmicpparams.cpp | 57 ++++++ opm/models/io/vtkblackoilmicpparams.hpp | 63 +++++++ 4 files changed, 217 insertions(+), 132 deletions(-) create mode 100644 opm/models/io/vtkblackoilmicpparams.cpp create mode 100644 opm/models/io/vtkblackoilmicpparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index e511bf6f661..b60b8116c69 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -63,6 +63,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/blackoil/blackoilpolymerparams.cpp opm/models/blackoil/blackoilsolventparams.cpp opm/models/io/vtkblackoilenergyparams.cpp + opm/models/io/vtkblackoilmicpparams.cpp opm/models/io/vtkblackoilparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp @@ -654,6 +655,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkblackoilenergymodule.hpp opm/models/io/vtkblackoilenergyparams.hpp opm/models/io/vtkblackoilmicpmodule.hpp + opm/models/io/vtkblackoilmicpparams.hpp opm/models/io/vtkblackoilmodule.hpp opm/models/io/vtkblackoilparams.hpp opm/models/io/vtkblackoilpolymermodule.hh diff --git a/opm/models/io/vtkblackoilmicpmodule.hpp b/opm/models/io/vtkblackoilmicpmodule.hpp index c94507f7889..6c862c5e912 100644 --- a/opm/models/io/vtkblackoilmicpmodule.hpp +++ b/opm/models/io/vtkblackoilmicpmodule.hpp @@ -36,22 +36,12 @@ #include #include +#include #include #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteMicrobialConcentration { static constexpr bool value = true; }; -struct VtkWriteOxygenConcentration { static constexpr bool value = true; }; -struct VtkWriteUreaConcentration { static constexpr bool value = true; }; -struct VtkWriteBiofilmConcentration { static constexpr bool value = true; }; -struct VtkWriteCalciteConcentration { static constexpr bool value = true; }; - -} // namespace Opm::Parameters - namespace Opm { /*! * \ingroup Vtk @@ -79,7 +69,11 @@ class VtkBlackOilMICPModule : public BaseOutputModule public: VtkBlackOilMICPModule(const Simulator& simulator) : ParentType(simulator) - { } + { + if constexpr (enableMICP) { + params_.read(); + } + } /*! * \brief Register all run-time parameters for the multi-phase VTK output @@ -87,22 +81,9 @@ class VtkBlackOilMICPModule : public BaseOutputModule */ static void registerParameters() { - if (!enableMICP) - return; - - Parameters::Register - ("Include the concentration of the microbial component in the water phase " - "in the VTK output files"); - Parameters::Register - ("Include the concentration of the oxygen component in the water phase " - "in the VTK output files"); - Parameters::Register - ("Include the concentration of the urea component in the water phase " - "in the VTK output files"); - Parameters::Register - ("Include the biofilm volume fraction in the VTK output files"); - Parameters::Register - ("Include the calcite volume fraction in the VTK output files"); + if constexpr (enableMICP) { + VtkBlackoilMICPParams::registerParameters(); + } } /*! @@ -111,23 +92,27 @@ class VtkBlackOilMICPModule : public BaseOutputModule */ void allocBuffers() { - if (!Parameters::Get()) { - return; + if constexpr (enableMICP) { + if (!Parameters::Get()) { + return; + } + + if (params_.microbialConcentrationOutput_) { + this->resizeScalarBuffer_(microbialConcentration_); + } + if (params_.oxygenConcentrationOutput_) { + this->resizeScalarBuffer_(oxygenConcentration_); + } + if (params_.ureaConcentrationOutput_) { + this->resizeScalarBuffer_(ureaConcentration_); + } + if (params_.biofilmConcentrationOutput_) { + this->resizeScalarBuffer_(biofilmConcentration_); + } + if (params_.calciteConcentrationOutput_) { + this->resizeScalarBuffer_(calciteConcentration_); + } } - - if (!enableMICP) - return; - - if (microbialConcentrationOutput_()) - this->resizeScalarBuffer_(microbialConcentration_); - if (oxygenConcentrationOutput_()) - this->resizeScalarBuffer_(oxygenConcentration_); - if (ureaConcentrationOutput_()) - this->resizeScalarBuffer_(ureaConcentration_); - if (biofilmConcentrationOutput_()) - this->resizeScalarBuffer_(biofilmConcentration_); - if (calciteConcentrationOutput_()) - this->resizeScalarBuffer_(calciteConcentration_); } /*! @@ -136,37 +121,40 @@ class VtkBlackOilMICPModule : public BaseOutputModule */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::Get()) { - return; - } - - if (!enableMICP) - return; - - for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) { - const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0); - unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); - - if (microbialConcentrationOutput_()) - microbialConcentration_[globalDofIdx] = - scalarValue(intQuants.microbialConcentration()); - - if (oxygenConcentrationOutput_()) - oxygenConcentration_[globalDofIdx] = - scalarValue(intQuants.oxygenConcentration()); - - if (ureaConcentrationOutput_()) - ureaConcentration_[globalDofIdx] = - 10 * scalarValue(intQuants.ureaConcentration());//Multypliging by scaling factor 10 (see WellInterface_impl.hpp) - - if (biofilmConcentrationOutput_()) - biofilmConcentration_[globalDofIdx] = - scalarValue(intQuants.biofilmConcentration()); - - if (calciteConcentrationOutput_()) - calciteConcentration_[globalDofIdx] = - scalarValue(intQuants.calciteConcentration()); - + if constexpr (enableMICP) { + if (!Parameters::Get()) { + return; + } + + for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) { + const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0); + unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); + + if (params_.microbialConcentrationOutput_) { + microbialConcentration_[globalDofIdx] = + scalarValue(intQuants.microbialConcentration()); + } + + if (params_.oxygenConcentrationOutput_) { + oxygenConcentration_[globalDofIdx] = + scalarValue(intQuants.oxygenConcentration()); + } + + if (params_.ureaConcentrationOutput_) { + ureaConcentration_[globalDofIdx] = + 10 * scalarValue(intQuants.ureaConcentration());//Multypliging by scaling factor 10 (see WellInterface_impl.hpp) + } + + if (params_.biofilmConcentrationOutput_) { + biofilmConcentration_[globalDofIdx] = + scalarValue(intQuants.biofilmConcentration()); + } + + if (params_.calciteConcentrationOutput_) { + calciteConcentration_[globalDofIdx] = + scalarValue(intQuants.calciteConcentration()); + } + } } } @@ -175,66 +163,41 @@ class VtkBlackOilMICPModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); - if (!vtkWriter) - return; - - if (!enableMICP) - return; - - if (microbialConcentrationOutput_()) - this->commitScalarBuffer_(baseWriter, "microbial concentration", microbialConcentration_); - - if (oxygenConcentrationOutput_()) - this->commitScalarBuffer_(baseWriter, "oxygen concentration", oxygenConcentration_); - - if (ureaConcentrationOutput_()) - this->commitScalarBuffer_(baseWriter, "urea concentration", ureaConcentration_); - - if (biofilmConcentrationOutput_()) - this->commitScalarBuffer_(baseWriter, "biofilm fraction", biofilmConcentration_); - - if (calciteConcentrationOutput_()) - this->commitScalarBuffer_(baseWriter, "calcite fraction", calciteConcentration_); - + if constexpr (enableMICP) { + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); + if (!vtkWriter) { + return; + } + + if (params_.microbialConcentrationOutput_) { + this->commitScalarBuffer_(baseWriter, "microbial concentration", microbialConcentration_); + } + + if (params_.oxygenConcentrationOutput_) { + this->commitScalarBuffer_(baseWriter, "oxygen concentration", oxygenConcentration_); + } + + if (params_.ureaConcentrationOutput_) { + this->commitScalarBuffer_(baseWriter, "urea concentration", ureaConcentration_); + } + + if (params_.biofilmConcentrationOutput_) { + this->commitScalarBuffer_(baseWriter, "biofilm fraction", biofilmConcentration_); + } + + if (params_.calciteConcentrationOutput_) { + this->commitScalarBuffer_(baseWriter, "calcite fraction", calciteConcentration_); + } + } } private: - static bool microbialConcentrationOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool oxygenConcentrationOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool ureaConcentrationOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool biofilmConcentrationOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool calciteConcentrationOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ScalarBuffer microbialConcentration_; - ScalarBuffer oxygenConcentration_; - ScalarBuffer ureaConcentration_; - ScalarBuffer biofilmConcentration_; - ScalarBuffer calciteConcentration_; + VtkBlackoilMICPParams params_{}; + ScalarBuffer microbialConcentration_{}; + ScalarBuffer oxygenConcentration_{}; + ScalarBuffer ureaConcentration_{}; + ScalarBuffer biofilmConcentration_{}; + ScalarBuffer calciteConcentration_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilmicpparams.cpp b/opm/models/io/vtkblackoilmicpparams.cpp new file mode 100644 index 00000000000..ca67f2b187b --- /dev/null +++ b/opm/models/io/vtkblackoilmicpparams.cpp @@ -0,0 +1,57 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkBlackoilMICPParams::registerParameters() +{ + Parameters::Register + ("Include the concentration of the microbial component in the water phase " + "in the VTK output files"); + Parameters::Register + ("Include the concentration of the oxygen component in the water phase " + "in the VTK output files"); + Parameters::Register + ("Include the concentration of the urea component in the water phase " + "in the VTK output files"); + Parameters::Register + ("Include the biofilm volume fraction in the VTK output files"); + Parameters::Register + ("Include the calcite volume fraction in the VTK output files"); +} + +void VtkBlackoilMICPParams::read() +{ + microbialConcentrationOutput_ = Parameters::Get(); + oxygenConcentrationOutput_ = Parameters::Get(); + ureaConcentrationOutput_ = Parameters::Get(); + biofilmConcentrationOutput_ = Parameters::Get(); + calciteConcentrationOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkblackoilmicpparams.hpp b/opm/models/io/vtkblackoilmicpparams.hpp new file mode 100644 index 00000000000..71f6ae308e3 --- /dev/null +++ b/opm/models/io/vtkblackoilmicpparams.hpp @@ -0,0 +1,63 @@ +// -*- 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::VtkBlackOilMICPModule + */ +#ifndef OPM_VTK_BLACK_OIL_MICP_PARAMS_HPP +#define OPM_VTK_BLACK_OIL_MICP_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteMicrobialConcentration { static constexpr bool value = true; }; +struct VtkWriteOxygenConcentration { static constexpr bool value = true; }; +struct VtkWriteUreaConcentration { static constexpr bool value = true; }; +struct VtkWriteBiofilmConcentration { static constexpr bool value = true; }; +struct VtkWriteCalciteConcentration { static constexpr bool value = true; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkBlackoilMICPModule. + */ +struct VtkBlackoilMICPParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool microbialConcentrationOutput_; + bool oxygenConcentrationOutput_; + bool ureaConcentrationOutput_; + bool biofilmConcentrationOutput_; + bool calciteConcentrationOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_BLACKOIL_MICP_PARAMS_HPP From 18ddfc8fb232290d8663c4f773ea2598a4f9d51f Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:51:37 +0200 Subject: [PATCH 10/33] vtkblackoilpolymermodule.hh: rename to vtkblackoilpolymermodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/blackoil/blackoilpolymermodules.hh | 2 +- ...ckoilpolymermodule.hh => vtkblackoilpolymermodule.hpp} | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) rename opm/models/io/{vtkblackoilpolymermodule.hh => vtkblackoilpolymermodule.hpp} (98%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index b60b8116c69..99ceda1d869 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -658,7 +658,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkblackoilmicpparams.hpp opm/models/io/vtkblackoilmodule.hpp opm/models/io/vtkblackoilparams.hpp - opm/models/io/vtkblackoilpolymermodule.hh + opm/models/io/vtkblackoilpolymermodule.hpp opm/models/io/vtkblackoilsolventmodule.hh opm/models/io/vtkcompositionmodule.hh opm/models/io/vtkdiffusionmodule.hh diff --git a/opm/models/blackoil/blackoilpolymermodules.hh b/opm/models/blackoil/blackoilpolymermodules.hh index bf21eb4f854..7ebd31acf25 100644 --- a/opm/models/blackoil/blackoilpolymermodules.hh +++ b/opm/models/blackoil/blackoilpolymermodules.hh @@ -35,7 +35,7 @@ #include #include -#include +#include #include diff --git a/opm/models/io/vtkblackoilpolymermodule.hh b/opm/models/io/vtkblackoilpolymermodule.hpp similarity index 98% rename from opm/models/io/vtkblackoilpolymermodule.hh rename to opm/models/io/vtkblackoilpolymermodule.hpp index 0f012069ba0..ab23d7f2a85 100644 --- a/opm/models/io/vtkblackoilpolymermodule.hh +++ b/opm/models/io/vtkblackoilpolymermodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkBlackOilPolymerModule */ -#ifndef EWOMS_VTK_BLACK_OIL_POLYMER_MODULE_HH -#define EWOMS_VTK_BLACK_OIL_POLYMER_MODULE_HH +#ifndef OPM_VTK_BLACK_OIL_POLYMER_MODULE_HPP +#define OPM_VTK_BLACK_OIL_POLYMER_MODULE_HPP #include @@ -61,6 +61,7 @@ struct VtkWritePolymerAdsorption { static constexpr bool value = true; }; } // namespace Opm::Parameters namespace Opm { + /*! * \ingroup Vtk * @@ -263,6 +264,7 @@ class VtkBlackOilPolymerModule : public BaseOutputModule ScalarBuffer polymerViscosityCorrection_; ScalarBuffer waterViscosityCorrection_; }; + } // namespace Opm -#endif +#endif // OPM_VTK_BLACK_OIL_POLYMER_MODULE_HPP From 3733e548bb4c38e0c76c5c40524356898969241d Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 11/33] vtkblackoilpolymermodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkblackoilpolymermodule.hpp | 260 +++++++++------------ opm/models/io/vtkblackoilpolymerparams.cpp | 63 +++++ opm/models/io/vtkblackoilpolymerparams.hpp | 65 ++++++ 4 files changed, 238 insertions(+), 152 deletions(-) create mode 100644 opm/models/io/vtkblackoilpolymerparams.cpp create mode 100644 opm/models/io/vtkblackoilpolymerparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 99ceda1d869..f76b65c750d 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -64,6 +64,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/blackoil/blackoilsolventparams.cpp opm/models/io/vtkblackoilenergyparams.cpp opm/models/io/vtkblackoilmicpparams.cpp + opm/models/io/vtkblackoilpolymerparams.cpp opm/models/io/vtkblackoilparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp @@ -659,6 +660,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkblackoilmodule.hpp opm/models/io/vtkblackoilparams.hpp opm/models/io/vtkblackoilpolymermodule.hpp + opm/models/io/vtkblackoilpolymerparams.hpp opm/models/io/vtkblackoilsolventmodule.hh opm/models/io/vtkcompositionmodule.hh opm/models/io/vtkdiffusionmodule.hh diff --git a/opm/models/io/vtkblackoilpolymermodule.hpp b/opm/models/io/vtkblackoilpolymermodule.hpp index ab23d7f2a85..ac6d9f43eb0 100644 --- a/opm/models/io/vtkblackoilpolymermodule.hpp +++ b/opm/models/io/vtkblackoilpolymermodule.hpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -48,18 +49,6 @@ struct VtkBlackOilPolymer {}; } // namespace Opm::Properties::TTag -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWritePolymerConcentration { static constexpr bool value = true; }; -struct VtkWritePolymerDeadPoreVolume { static constexpr bool value = true; }; -struct VtkWritePolymerViscosityCorrection { static constexpr bool value = true; }; -struct VtkWriteWaterViscosityCorrection { static constexpr bool value = true; }; -struct VtkWritePolymerRockDensity { static constexpr bool value = true; }; -struct VtkWritePolymerAdsorption { static constexpr bool value = true; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -88,7 +77,11 @@ class VtkBlackOilPolymerModule : public BaseOutputModule public: VtkBlackOilPolymerModule(const Simulator& simulator) : ParentType(simulator) - { } + { + if constexpr (enablePolymer) { + params_.read(); + } + } /*! * \brief Register all run-time parameters for the multi-phase VTK output @@ -96,27 +89,9 @@ class VtkBlackOilPolymerModule : public BaseOutputModule */ static void registerParameters() { - if (!enablePolymer) - return; - - Parameters::Register - ("Include the concentration of the polymer component in the water phase " - "in the VTK output files"); - Parameters::Register - ("Include the fraction of the \"dead\" pore volume " - "in the VTK output files"); - Parameters::Register - ("Include the amount of already adsorbed polymer component" - "in the VTK output files"); - Parameters::Register - ("Include the adsorption rate of the polymer component" - "in the VTK output files"); - Parameters::Register - ("Include the viscosity correction of the polymer component " - "in the VTK output files"); - Parameters::Register - ("Include the viscosity correction of the water component " - "due to polymers in the VTK output files"); + if constexpr (enablePolymer) { + VtkBlackoilPolymerParams::registerParameters(); + } } /*! @@ -125,25 +100,30 @@ class VtkBlackOilPolymerModule : public BaseOutputModule */ void allocBuffers() { - if (!Parameters::Get()) { - return; + if constexpr (enablePolymer) { + if (!Parameters::Get()) { + return; + } + + if (params_.polymerConcentrationOutput_) { + this->resizeScalarBuffer_(polymerConcentration_); + } + if (params_.polymerDeadPoreVolumeOutput_) { + this->resizeScalarBuffer_(polymerDeadPoreVolume_); + } + if (params_.polymerRockDensityOutput_) { + this->resizeScalarBuffer_(polymerRockDensity_); + } + if (params_.polymerAdsorptionOutput_) { + this->resizeScalarBuffer_(polymerAdsorption_); + } + if (params_.polymerViscosityCorrectionOutput_) { + this->resizeScalarBuffer_(polymerViscosityCorrection_); + } + if (params_.waterViscosityCorrectionOutput_) { + this->resizeScalarBuffer_(waterViscosityCorrection_); + } } - - if (!enablePolymer) - return; - - if (polymerConcentrationOutput_()) - this->resizeScalarBuffer_(polymerConcentration_); - if (polymerDeadPoreVolumeOutput_()) - this->resizeScalarBuffer_(polymerDeadPoreVolume_); - if (polymerRockDensityOutput_()) - this->resizeScalarBuffer_(polymerRockDensity_); - if (polymerAdsorptionOutput_()) - this->resizeScalarBuffer_(polymerAdsorption_); - if (polymerViscosityCorrectionOutput_()) - this->resizeScalarBuffer_(polymerViscosityCorrection_); - if (waterViscosityCorrectionOutput_()) - this->resizeScalarBuffer_(waterViscosityCorrection_); } /*! @@ -152,40 +132,45 @@ class VtkBlackOilPolymerModule : public BaseOutputModule */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::Get()) { - return; - } - - if (!enablePolymer) - return; - - for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) { - const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0); - unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); - - if (polymerConcentrationOutput_()) - polymerConcentration_[globalDofIdx] = - scalarValue(intQuants.polymerConcentration()); - - if (polymerDeadPoreVolumeOutput_()) - polymerDeadPoreVolume_[globalDofIdx] = - scalarValue(intQuants.polymerDeadPoreVolume()); - - if (polymerRockDensityOutput_()) - polymerRockDensity_[globalDofIdx] = - scalarValue(intQuants.polymerRockDensity()); - - if (polymerAdsorptionOutput_()) - polymerAdsorption_[globalDofIdx] = - scalarValue(intQuants.polymerAdsorption()); - - if (polymerViscosityCorrectionOutput_()) - polymerViscosityCorrection_[globalDofIdx] = - scalarValue(intQuants.polymerViscosityCorrection()); - - if (waterViscosityCorrectionOutput_()) - waterViscosityCorrection_[globalDofIdx] = - scalarValue(intQuants.waterViscosityCorrection()); + if constexpr (enablePolymer) { + if (!Parameters::Get()) { + return; + } + + for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) { + const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0); + unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); + + if (params_.polymerConcentrationOutput_) { + polymerConcentration_[globalDofIdx] = + scalarValue(intQuants.polymerConcentration()); + } + + if (params_.polymerDeadPoreVolumeOutput_) { + polymerDeadPoreVolume_[globalDofIdx] = + scalarValue(intQuants.polymerDeadPoreVolume()); + } + + if (params_.polymerRockDensityOutput_) { + polymerRockDensity_[globalDofIdx] = + scalarValue(intQuants.polymerRockDensity()); + } + + if (params_.polymerAdsorptionOutput_) { + polymerAdsorption_[globalDofIdx] = + scalarValue(intQuants.polymerAdsorption()); + } + + if (params_.polymerViscosityCorrectionOutput_) { + polymerViscosityCorrection_[globalDofIdx] = + scalarValue(intQuants.polymerViscosityCorrection()); + } + + if (params_.waterViscosityCorrectionOutput_) { + waterViscosityCorrection_[globalDofIdx] = + scalarValue(intQuants.waterViscosityCorrection()); + } + } } } @@ -194,75 +179,46 @@ class VtkBlackOilPolymerModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); - if (!vtkWriter) - return; - - if (!enablePolymer) - return; - - if (polymerConcentrationOutput_()) - this->commitScalarBuffer_(baseWriter, "polymer concentration", polymerConcentration_); - - if (polymerDeadPoreVolumeOutput_()) - this->commitScalarBuffer_(baseWriter, "dead pore volume fraction", polymerDeadPoreVolume_); - - if (polymerRockDensityOutput_()) - this->commitScalarBuffer_(baseWriter, "polymer rock density", polymerRockDensity_); - - if (polymerAdsorptionOutput_()) - this->commitScalarBuffer_(baseWriter, "polymer adsorption", polymerAdsorption_); - - if (polymerViscosityCorrectionOutput_()) - this->commitScalarBuffer_(baseWriter, "polymer viscosity correction", polymerViscosityCorrection_); - - if (waterViscosityCorrectionOutput_()) - this->commitScalarBuffer_(baseWriter, "water viscosity correction", waterViscosityCorrection_); + if constexpr (enablePolymer) { + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); + if (!vtkWriter) { + return; + } + + if (params_.polymerConcentrationOutput_) { + this->commitScalarBuffer_(baseWriter, "polymer concentration", polymerConcentration_); + } + + if (params_.polymerDeadPoreVolumeOutput_) { + this->commitScalarBuffer_(baseWriter, "dead pore volume fraction", polymerDeadPoreVolume_); + } + + if (params_.polymerRockDensityOutput_) { + this->commitScalarBuffer_(baseWriter, "polymer rock density", polymerRockDensity_); + } + + if (params_.polymerAdsorptionOutput_) { + this->commitScalarBuffer_(baseWriter, "polymer adsorption", polymerAdsorption_); + } + + if (params_.polymerViscosityCorrectionOutput_) { + this->commitScalarBuffer_(baseWriter, "polymer viscosity correction", polymerViscosityCorrection_); + } + + if (params_.waterViscosityCorrectionOutput_) { + this->commitScalarBuffer_(baseWriter, "water viscosity correction", waterViscosityCorrection_); + } + } } private: - static bool polymerConcentrationOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool polymerDeadPoreVolumeOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool polymerRockDensityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool polymerAdsorptionOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool polymerViscosityCorrectionOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool waterViscosityCorrectionOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ScalarBuffer polymerConcentration_; - ScalarBuffer polymerDeadPoreVolume_; - ScalarBuffer polymerRockDensity_; - ScalarBuffer polymerAdsorption_; - ScalarBuffer polymerViscosityCorrection_; - ScalarBuffer waterViscosityCorrection_; + VtkBlackoilPolymerParams params_{}; + ScalarBuffer polymerConcentration_{}; + ScalarBuffer polymerDeadPoreVolume_{}; + ScalarBuffer polymerRockDensity_{}; + ScalarBuffer polymerAdsorption_{}; + ScalarBuffer polymerViscosityCorrection_{}; + ScalarBuffer waterViscosityCorrection_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilpolymerparams.cpp b/opm/models/io/vtkblackoilpolymerparams.cpp new file mode 100644 index 00000000000..f33830e9752 --- /dev/null +++ b/opm/models/io/vtkblackoilpolymerparams.cpp @@ -0,0 +1,63 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkBlackoilPolymerParams::registerParameters() +{ + Parameters::Register + ("Include the concentration of the polymer component in the water phase " + "in the VTK output files"); + Parameters::Register + ("Include the fraction of the \"dead\" pore volume " + "in the VTK output files"); + Parameters::Register + ("Include the amount of already adsorbed polymer component" + "in the VTK output files"); + Parameters::Register + ("Include the adsorption rate of the polymer component" + "in the VTK output files"); + Parameters::Register + ("Include the viscosity correction of the polymer component " + "in the VTK output files"); + Parameters::Register + ("Include the viscosity correction of the water component " + "due to polymers in the VTK output files"); +} + +void VtkBlackoilPolymerParams::read() +{ + polymerConcentrationOutput_ = Parameters::Get(); + polymerDeadPoreVolumeOutput_ = Parameters::Get(); + polymerRockDensityOutput_ = Parameters::Get(); + polymerAdsorptionOutput_ = Parameters::Get(); + polymerViscosityCorrectionOutput_ = Parameters::Get(); + waterViscosityCorrectionOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkblackoilpolymerparams.hpp b/opm/models/io/vtkblackoilpolymerparams.hpp new file mode 100644 index 00000000000..df866b29ac1 --- /dev/null +++ b/opm/models/io/vtkblackoilpolymerparams.hpp @@ -0,0 +1,65 @@ +// -*- 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::VtkBlackOilPolymerModule + */ +#ifndef OPM_VTK_BLACK_OIL_POLYMER_PARAMS_HPP +#define OPM_VTK_BLACK_OIL_POLYMER_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWritePolymerConcentration { static constexpr bool value = true; }; +struct VtkWritePolymerDeadPoreVolume { static constexpr bool value = true; }; +struct VtkWritePolymerViscosityCorrection { static constexpr bool value = true; }; +struct VtkWriteWaterViscosityCorrection { static constexpr bool value = true; }; +struct VtkWritePolymerRockDensity { static constexpr bool value = true; }; +struct VtkWritePolymerAdsorption { static constexpr bool value = true; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkBlackoilPolymerModule. + */ +struct VtkBlackoilPolymerParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool polymerConcentrationOutput_; + bool polymerDeadPoreVolumeOutput_; + bool polymerRockDensityOutput_; + bool polymerAdsorptionOutput_; + bool polymerViscosityCorrectionOutput_; + bool waterViscosityCorrectionOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_BLACK_OIL_POLYMER_MODULE_HPP From 3af8ed8994688f03fb640ba21afdf0f81d0991d4 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:51:37 +0200 Subject: [PATCH 12/33] vtkblackoilsolventmodule.hh: rename to vtkblackoilsolventmodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/blackoil/blackoilsolventmodules.hh | 2 +- ...ackoilsolventmodule.hh => vtkblackoilsolventmodule.hpp} | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) rename opm/models/io/{vtkblackoilsolventmodule.hh => vtkblackoilsolventmodule.hpp} (98%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index f76b65c750d..712d988f758 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -661,7 +661,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkblackoilparams.hpp opm/models/io/vtkblackoilpolymermodule.hpp opm/models/io/vtkblackoilpolymerparams.hpp - opm/models/io/vtkblackoilsolventmodule.hh + opm/models/io/vtkblackoilsolventmodule.hpp opm/models/io/vtkcompositionmodule.hh opm/models/io/vtkdiffusionmodule.hh opm/models/io/vtkdiscretefracturemodule.hh diff --git a/opm/models/blackoil/blackoilsolventmodules.hh b/opm/models/blackoil/blackoilsolventmodules.hh index 4964f20434f..a7ebce0670e 100644 --- a/opm/models/blackoil/blackoilsolventmodules.hh +++ b/opm/models/blackoil/blackoilsolventmodules.hh @@ -38,7 +38,7 @@ #include #include -#include +#include #include diff --git a/opm/models/io/vtkblackoilsolventmodule.hh b/opm/models/io/vtkblackoilsolventmodule.hpp similarity index 98% rename from opm/models/io/vtkblackoilsolventmodule.hh rename to opm/models/io/vtkblackoilsolventmodule.hpp index 3dda896e9c9..084ecf8d53f 100644 --- a/opm/models/io/vtkblackoilsolventmodule.hh +++ b/opm/models/io/vtkblackoilsolventmodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkBlackOilSolventModule */ -#ifndef EWOMS_VTK_BLACK_OIL_SOLVENT_MODULE_HH -#define EWOMS_VTK_BLACK_OIL_SOLVENT_MODULE_HH +#ifndef OPM_VTK_BLACK_OIL_SOLVENT_MODULE_HPP +#define OPM_VTK_BLACK_OIL_SOLVENT_MODULE_HPP #include @@ -53,6 +53,7 @@ struct VtkWriteSolventMobility { static constexpr bool value = true; }; } // namespace Opm::Properties namespace Opm { + /*! * \ingroup Vtk * @@ -240,4 +241,4 @@ class VtkBlackOilSolventModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_BLACK_OIL_SOLVENT_MODULE_HPP From 72d3395e510824e02c93c841b76522c489ff2267 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 13/33] vtkblackoilsolventmodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkblackoilsolventmodule.hpp | 229 +++++++++------------ opm/models/io/vtkblackoilsolventparams.cpp | 59 ++++++ opm/models/io/vtkblackoilsolventparams.hpp | 63 ++++++ 4 files changed, 220 insertions(+), 133 deletions(-) create mode 100644 opm/models/io/vtkblackoilsolventparams.cpp create mode 100644 opm/models/io/vtkblackoilsolventparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 712d988f758..22b7a0bcb08 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -66,6 +66,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkblackoilmicpparams.cpp opm/models/io/vtkblackoilpolymerparams.cpp opm/models/io/vtkblackoilparams.cpp + opm/models/io/vtkblackoilsolventparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -662,6 +663,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkblackoilpolymermodule.hpp opm/models/io/vtkblackoilpolymerparams.hpp opm/models/io/vtkblackoilsolventmodule.hpp + opm/models/io/vtkblackoilsolventparams.hpp opm/models/io/vtkcompositionmodule.hh opm/models/io/vtkdiffusionmodule.hh opm/models/io/vtkdiscretefracturemodule.hh diff --git a/opm/models/io/vtkblackoilsolventmodule.hpp b/opm/models/io/vtkblackoilsolventmodule.hpp index 084ecf8d53f..0fdb69a7c80 100644 --- a/opm/models/io/vtkblackoilsolventmodule.hpp +++ b/opm/models/io/vtkblackoilsolventmodule.hpp @@ -36,22 +36,12 @@ #include #include +#include #include #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteSolventSaturation { static constexpr bool value = true; }; -struct VtkWriteSolventRsw { static constexpr bool value = true; }; -struct VtkWriteSolventDensity { static constexpr bool value = true; }; -struct VtkWriteSolventViscosity { static constexpr bool value = true; }; -struct VtkWriteSolventMobility { static constexpr bool value = true; }; - -} // namespace Opm::Properties - namespace Opm { /*! @@ -80,7 +70,11 @@ class VtkBlackOilSolventModule : public BaseOutputModule public: VtkBlackOilSolventModule(const Simulator& simulator) : ParentType(simulator) - { } + { + if constexpr (enableSolvent) { + params_.read(); + } + } /*! * \brief Register all run-time parameters for the multi-phase VTK output @@ -88,24 +82,9 @@ class VtkBlackOilSolventModule : public BaseOutputModule */ static void registerParameters() { - if (!enableSolvent) - return; - - Parameters::Register - ("Include the \"saturation\" of the solvent component " - "in the VTK output files"); - Parameters::Register - ("Include the \"dissolved volume in water\" of the solvent component " - "in the VTK output files"); - Parameters::Register - ("Include the \"density\" of the solvent component " - "in the VTK output files"); - Parameters::Register - ("Include the \"viscosity\" of the solvent component " - "in the VTK output files"); - Parameters::Register - ("Include the \"mobility\" of the solvent component " - "in the VTK output files"); + if constexpr (enableSolvent) { + VtkBlackOilSolventParams::registerParameters(); + } } /*! @@ -114,23 +93,27 @@ class VtkBlackOilSolventModule : public BaseOutputModule */ void allocBuffers() { - if (!Parameters::Get()) { - return; + if constexpr (enableSolvent) { + if (!Parameters::Get()) { + return; + } + + if (params_.solventSaturationOutput_) { + this->resizeScalarBuffer_(solventSaturation_); + } + if (params_.solventRswOutput_) { + this->resizeScalarBuffer_(solventRsw_); + } + if (params_.solventDensityOutput_) { + this->resizeScalarBuffer_(solventDensity_); + } + if (params_.solventViscosityOutput_) { + this->resizeScalarBuffer_(solventViscosity_); + } + if (params_.solventMobilityOutput_) { + this->resizeScalarBuffer_(solventMobility_); + } } - - if (!enableSolvent) - return; - - if (solventSaturationOutput_()) - this->resizeScalarBuffer_(solventSaturation_); - if (solventRswOutput_()) - this->resizeScalarBuffer_(solventRsw_); - if (solventDensityOutput_()) - this->resizeScalarBuffer_(solventDensity_); - if (solventViscosityOutput_()) - this->resizeScalarBuffer_(solventViscosity_); - if (solventMobilityOutput_()) - this->resizeScalarBuffer_(solventMobility_); } /*! @@ -139,37 +122,41 @@ class VtkBlackOilSolventModule : public BaseOutputModule */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::Get()) { - return; - } - - if (!enableSolvent) - return; - - using Toolbox = MathToolbox; - for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) { - const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0); - unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); - - if (solventSaturationOutput_()) - solventSaturation_[globalDofIdx] = - Toolbox::scalarValue(intQuants.solventSaturation()); - - if (solventRswOutput_()) - solventRsw_[globalDofIdx] = - Toolbox::scalarValue(intQuants.rsSolw()); - - if (solventDensityOutput_()) - solventDensity_[globalDofIdx] = - Toolbox::scalarValue(intQuants.solventDensity()); - - if (solventViscosityOutput_()) - solventViscosity_[globalDofIdx] = - Toolbox::scalarValue(intQuants.solventViscosity()); - - if (solventMobilityOutput_()) - solventMobility_[globalDofIdx] = - Toolbox::scalarValue(intQuants.solventMobility()); + if constexpr (enableSolvent) { + if (!Parameters::Get()) { + return; + } + + using Toolbox = MathToolbox; + for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) { + const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0); + unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); + + if (params_.solventSaturationOutput_) { + solventSaturation_[globalDofIdx] = + Toolbox::scalarValue(intQuants.solventSaturation()); + } + + if (params_.solventRswOutput_) { + solventRsw_[globalDofIdx] = + Toolbox::scalarValue(intQuants.rsSolw()); + } + + if (params_.solventDensityOutput_) { + solventDensity_[globalDofIdx] = + Toolbox::scalarValue(intQuants.solventDensity()); + } + + if (params_.solventViscosityOutput_) { + solventViscosity_[globalDofIdx] = + Toolbox::scalarValue(intQuants.solventViscosity()); + } + + if (params_.solventMobilityOutput_) { + solventMobility_[globalDofIdx] = + Toolbox::scalarValue(intQuants.solventMobility()); + } + } } } @@ -178,65 +165,41 @@ class VtkBlackOilSolventModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); - if (!vtkWriter) - return; - - if (!enableSolvent) - return; - - if (solventSaturationOutput_()) - this->commitScalarBuffer_(baseWriter, "saturation_solvent", solventSaturation_); - - if (solventRswOutput_()) - this->commitScalarBuffer_(baseWriter, "dissolved_solvent", solventRsw_); - - if (solventDensityOutput_()) - this->commitScalarBuffer_(baseWriter, "density_solvent", solventDensity_); - - if (solventViscosityOutput_()) - this->commitScalarBuffer_(baseWriter, "viscosity_solvent", solventViscosity_); - - if (solventMobilityOutput_()) - this->commitScalarBuffer_(baseWriter, "mobility_solvent", solventMobility_); + if constexpr (enableSolvent) { + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); + if (!vtkWriter) { + return; + } + + if (params_.solventSaturationOutput_) { + this->commitScalarBuffer_(baseWriter, "saturation_solvent", solventSaturation_); + } + + if (params_.solventRswOutput_) { + this->commitScalarBuffer_(baseWriter, "dissolved_solvent", solventRsw_); + } + + if (params_.solventDensityOutput_) { + this->commitScalarBuffer_(baseWriter, "density_solvent", solventDensity_); + } + + if (params_.solventViscosityOutput_) { + this->commitScalarBuffer_(baseWriter, "viscosity_solvent", solventViscosity_); + } + + if (params_.solventMobilityOutput_) { + this->commitScalarBuffer_(baseWriter, "mobility_solvent", solventMobility_); + } + } } private: - static bool solventSaturationOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool solventRswOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool solventDensityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool solventViscosityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool solventMobilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ScalarBuffer solventSaturation_; - ScalarBuffer solventRsw_; - ScalarBuffer solventDensity_; - ScalarBuffer solventViscosity_; - ScalarBuffer solventMobility_; + VtkBlackOilSolventParams params_{}; + ScalarBuffer solventSaturation_{}; + ScalarBuffer solventRsw_{}; + ScalarBuffer solventDensity_{}; + ScalarBuffer solventViscosity_{}; + ScalarBuffer solventMobility_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilsolventparams.cpp b/opm/models/io/vtkblackoilsolventparams.cpp new file mode 100644 index 00000000000..a3ef8cd822c --- /dev/null +++ b/opm/models/io/vtkblackoilsolventparams.cpp @@ -0,0 +1,59 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkBlackOilSolventParams::registerParameters() +{ + Parameters::Register + ("Include the \"saturation\" of the solvent component " + "in the VTK output files"); + Parameters::Register + ("Include the \"dissolved volume in water\" of the solvent component " + "in the VTK output files"); + Parameters::Register + ("Include the \"density\" of the solvent component " + "in the VTK output files"); + Parameters::Register + ("Include the \"viscosity\" of the solvent component " + "in the VTK output files"); + Parameters::Register + ("Include the \"mobility\" of the solvent component " + "in the VTK output files"); +} + +void VtkBlackOilSolventParams::read() +{ + solventSaturationOutput_ = Parameters::Get(); + solventRswOutput_ = Parameters::Get(); + solventDensityOutput_ = Parameters::Get(); + solventViscosityOutput_ = Parameters::Get(); + solventMobilityOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkblackoilsolventparams.hpp b/opm/models/io/vtkblackoilsolventparams.hpp new file mode 100644 index 00000000000..7637e546c31 --- /dev/null +++ b/opm/models/io/vtkblackoilsolventparams.hpp @@ -0,0 +1,63 @@ +// -*- 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::VtkBlackOilSolventModule + */ +#ifndef OPM_VTK_BLACK_OIL_SOLVENT_PARAMS_HPP +#define OPM_VTK_BLACK_OIL_SOLVENT_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteSolventSaturation { static constexpr bool value = true; }; +struct VtkWriteSolventRsw { static constexpr bool value = true; }; +struct VtkWriteSolventDensity { static constexpr bool value = true; }; +struct VtkWriteSolventViscosity { static constexpr bool value = true; }; +struct VtkWriteSolventMobility { static constexpr bool value = true; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkBlackoilPolymerModule. + */ +struct VtkBlackOilSolventParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool solventSaturationOutput_; + bool solventRswOutput_; + bool solventDensityOutput_; + bool solventViscosityOutput_; + bool solventMobilityOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_BLACK_OIL_SOLVENT_PARAMS_HPP From c7c15fbe23a5926cd296c9ff6c6ddd654c9ca6c9 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:51:37 +0200 Subject: [PATCH 14/33] vtkcompositionmodule.hh: rename to vtkcompositionmodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/blackoil/blackoilmodel.hh | 2 +- opm/models/flash/flashmodel.hh | 2 +- .../{vtkcompositionmodule.hh => vtkcompositionmodule.hpp} | 6 +++--- opm/models/ncp/ncpmodel.hh | 3 +-- opm/models/ncp/ncpproperties.hh | 2 +- opm/models/ptflash/flashmodel.hh | 2 +- opm/models/pvs/pvsmodel.hh | 2 +- opm/models/pvs/pvsproperties.hh | 2 +- opm/simulators/flow/FlowUtils.cpp | 2 +- 10 files changed, 12 insertions(+), 13 deletions(-) rename opm/models/io/{vtkcompositionmodule.hh => vtkcompositionmodule.hpp} (98%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 22b7a0bcb08..fb60511a631 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -664,7 +664,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkblackoilpolymerparams.hpp opm/models/io/vtkblackoilsolventmodule.hpp opm/models/io/vtkblackoilsolventparams.hpp - opm/models/io/vtkcompositionmodule.hh + opm/models/io/vtkcompositionmodule.hpp opm/models/io/vtkdiffusionmodule.hh opm/models/io/vtkdiscretefracturemodule.hh opm/models/io/vtkenergymodule.hh diff --git a/opm/models/blackoil/blackoilmodel.hh b/opm/models/blackoil/blackoilmodel.hh index 4706c689cf3..b28417d68ed 100644 --- a/opm/models/blackoil/blackoilmodel.hh +++ b/opm/models/blackoil/blackoilmodel.hh @@ -56,7 +56,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/flash/flashmodel.hh b/opm/models/flash/flashmodel.hh index 070bae6136c..8475d44a2fc 100644 --- a/opm/models/flash/flashmodel.hh +++ b/opm/models/flash/flashmodel.hh @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/io/vtkcompositionmodule.hh b/opm/models/io/vtkcompositionmodule.hpp similarity index 98% rename from opm/models/io/vtkcompositionmodule.hh rename to opm/models/io/vtkcompositionmodule.hpp index 984add073fa..3487e6251bc 100644 --- a/opm/models/io/vtkcompositionmodule.hh +++ b/opm/models/io/vtkcompositionmodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkCompositionModule */ -#ifndef EWOMS_VTK_COMPOSITION_MODULE_HH -#define EWOMS_VTK_COMPOSITION_MODULE_HH +#ifndef OPM_VTK_COMPOSITION_MODULE_HPP +#define OPM_VTK_COMPOSITION_MODULE_HPP #include @@ -281,4 +281,4 @@ class VtkCompositionModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_COMPOSITION_MODULE_HPP diff --git a/opm/models/ncp/ncpmodel.hh b/opm/models/ncp/ncpmodel.hh index 4dbaefd4dbd..6a1c1320615 100644 --- a/opm/models/ncp/ncpmodel.hh +++ b/opm/models/ncp/ncpmodel.hh @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include @@ -56,7 +56,6 @@ #include #include #include -#include namespace Opm { template diff --git a/opm/models/ncp/ncpproperties.hh b/opm/models/ncp/ncpproperties.hh index afc7bf8e439..1576b28f038 100644 --- a/opm/models/ncp/ncpproperties.hh +++ b/opm/models/ncp/ncpproperties.hh @@ -31,7 +31,7 @@ #define EWOMS_NCP_PROPERTIES_HH #include -#include +#include #include #include diff --git a/opm/models/ptflash/flashmodel.hh b/opm/models/ptflash/flashmodel.hh index 3d87ba36593..a7d4c944a6b 100644 --- a/opm/models/ptflash/flashmodel.hh +++ b/opm/models/ptflash/flashmodel.hh @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include #include diff --git a/opm/models/pvs/pvsmodel.hh b/opm/models/pvs/pvsmodel.hh index ec165efe2e4..3466cd23352 100644 --- a/opm/models/pvs/pvsmodel.hh +++ b/opm/models/pvs/pvsmodel.hh @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/pvs/pvsproperties.hh b/opm/models/pvs/pvsproperties.hh index b6ef7031850..1ba75d2255d 100644 --- a/opm/models/pvs/pvsproperties.hh +++ b/opm/models/pvs/pvsproperties.hh @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/opm/simulators/flow/FlowUtils.cpp b/opm/simulators/flow/FlowUtils.cpp index 0f86917bac8..b94e7e6e20e 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include From 2d000835a78f76aeb734c3d027cf7a085e5b3d8e Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 15/33] vtkcompositionmodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkcompositionmodule.hpp | 155 +++++++++---------------- opm/models/io/vtkcompositionparams.cpp | 60 ++++++++++ opm/models/io/vtkcompositionparams.hpp | 67 +++++++++++ 4 files changed, 184 insertions(+), 100 deletions(-) create mode 100644 opm/models/io/vtkcompositionparams.cpp create mode 100644 opm/models/io/vtkcompositionparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index fb60511a631..43245d150c2 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -67,6 +67,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkblackoilpolymerparams.cpp opm/models/io/vtkblackoilparams.cpp opm/models/io/vtkblackoilsolventparams.cpp + opm/models/io/vtkcompositionparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -665,6 +666,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkblackoilsolventmodule.hpp opm/models/io/vtkblackoilsolventparams.hpp opm/models/io/vtkcompositionmodule.hpp + opm/models/io/vtkcompositionparams.hpp opm/models/io/vtkdiffusionmodule.hh opm/models/io/vtkdiscretefracturemodule.hh opm/models/io/vtkenergymodule.hh diff --git a/opm/models/io/vtkcompositionmodule.hpp b/opm/models/io/vtkcompositionmodule.hpp index 3487e6251bc..962bfdb7c6f 100644 --- a/opm/models/io/vtkcompositionmodule.hpp +++ b/opm/models/io/vtkcompositionmodule.hpp @@ -32,24 +32,12 @@ #include #include +#include #include #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteMassFractions { static constexpr bool value = false; }; -struct VtkWriteMoleFractions { static constexpr bool value = true; }; -struct VtkWriteTotalMassFractions { static constexpr bool value = false; }; -struct VtkWriteTotalMoleFractions { static constexpr bool value = false; }; -struct VtkWriteMolarities { static constexpr bool value = false; }; -struct VtkWriteFugacities { static constexpr bool value = false; }; -struct VtkWriteFugacityCoeffs { static constexpr bool value = false; }; - -} // namespace Opm::Properties - namespace Opm { /*! @@ -88,27 +76,16 @@ class VtkCompositionModule : public BaseOutputModule public: VtkCompositionModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the Vtk output module. */ static void registerParameters() { - Parameters::Register - ("Include mass fractions in the VTK output files"); - Parameters::Register - ("Include mole fractions in the VTK output files"); - Parameters::Register - ("Include total mass fractions in the VTK output files"); - Parameters::Register - ("Include total mole fractions in the VTK output files"); - Parameters::Register - ("Include component molarities in the VTK output files"); - Parameters::Register - ("Include component fugacities in the VTK output files"); - Parameters::Register - ("Include component fugacity coefficients in the VTK output files"); + VtkCompositionParams::registerParameters(); } /*! @@ -117,21 +94,28 @@ class VtkCompositionModule : public BaseOutputModule */ void allocBuffers() { - if (moleFracOutput_()) + if (params_.moleFracOutput_) { this->resizePhaseComponentBuffer_(moleFrac_); - if (massFracOutput_()) + } + if (params_.massFracOutput_) { this->resizePhaseComponentBuffer_(massFrac_); - if (totalMassFracOutput_()) + } + if (params_.totalMassFracOutput_) { this->resizeComponentBuffer_(totalMassFrac_); - if (totalMoleFracOutput_()) + } + if (params_.totalMoleFracOutput_) { this->resizeComponentBuffer_(totalMoleFrac_); - if (molarityOutput_()) + } + if (params_.molarityOutput_) { this->resizePhaseComponentBuffer_(molarity_); + } - if (fugacityOutput_()) + if (params_.fugacityOutput_) { this->resizeComponentBuffer_(fugacity_); - if (fugacityCoeffOutput_()) + } + if (params_.fugacityCoeffOutput_) { this->resizePhaseComponentBuffer_(fugacityCoeff_); + } } /*! @@ -153,21 +137,25 @@ class VtkCompositionModule : public BaseOutputModule for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { - if (moleFracOutput_()) + if (params_.moleFracOutput_) { moleFrac_[phaseIdx][compIdx][I] = Toolbox::value(fs.moleFraction(phaseIdx, compIdx)); - if (massFracOutput_()) + } + if (params_.massFracOutput_) { massFrac_[phaseIdx][compIdx][I] = Toolbox::value(fs.massFraction(phaseIdx, compIdx)); - if (molarityOutput_()) + } + if (params_.molarityOutput_) { molarity_[phaseIdx][compIdx][I] = Toolbox::value(fs.molarity(phaseIdx, compIdx)); + } - if (fugacityCoeffOutput_()) + if (params_.fugacityCoeffOutput_) { fugacityCoeff_[phaseIdx][compIdx][I] = Toolbox::value(fs.fugacityCoefficient(phaseIdx, compIdx)); + } } } for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { - if (totalMassFracOutput_()) { + if (params_.totalMassFracOutput_) { Scalar compMass = 0; Scalar totalMass = 0; for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { @@ -179,7 +167,7 @@ class VtkCompositionModule : public BaseOutputModule } totalMassFrac_[compIdx][I] = compMass / totalMass; } - if (totalMoleFracOutput_()) { + if (params_.totalMoleFracOutput_) { Scalar compMoles = 0; Scalar totalMoles = 0; for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { @@ -193,8 +181,9 @@ class VtkCompositionModule : public BaseOutputModule } totalMoleFrac_[compIdx][I] = compMoles / totalMoles; } - if (fugacityOutput_()) + if (params_.fugacityOutput_) { fugacity_[compIdx][I] = Toolbox::value(intQuants.fluidState().fugacity(/*phaseIdx=*/0, compIdx)); + } } } } @@ -204,79 +193,45 @@ class VtkCompositionModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (moleFracOutput_()) + if (params_.moleFracOutput_) { this->commitPhaseComponentBuffer_(baseWriter, "moleFrac_%s^%s", moleFrac_); - if (massFracOutput_()) + } + if (params_.massFracOutput_) { this->commitPhaseComponentBuffer_(baseWriter, "massFrac_%s^%s", massFrac_); - if (molarityOutput_()) + } + if (params_.molarityOutput_) { this->commitPhaseComponentBuffer_(baseWriter, "molarity_%s^%s", molarity_); - if (totalMassFracOutput_()) + } + if (params_.totalMassFracOutput_) { this->commitComponentBuffer_(baseWriter, "totalMassFrac^%s", totalMassFrac_); - if (totalMoleFracOutput_()) + } + if (params_.totalMoleFracOutput_) { this->commitComponentBuffer_(baseWriter, "totalMoleFrac^%s", totalMoleFrac_); + } - if (fugacityOutput_()) + if (params_.fugacityOutput_) { this->commitComponentBuffer_(baseWriter, "fugacity^%s", fugacity_); - if (fugacityCoeffOutput_()) + } + if (params_.fugacityCoeffOutput_) { this->commitPhaseComponentBuffer_(baseWriter, "fugacityCoeff_%s^%s", fugacityCoeff_); + } } private: - static bool massFracOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool moleFracOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool totalMassFracOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool totalMoleFracOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool molarityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool fugacityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool fugacityCoeffOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - PhaseComponentBuffer moleFrac_; - PhaseComponentBuffer massFrac_; - PhaseComponentBuffer molarity_; - ComponentBuffer totalMassFrac_; - ComponentBuffer totalMoleFrac_; - - ComponentBuffer fugacity_; - PhaseComponentBuffer fugacityCoeff_; + VtkCompositionParams params_{}; + PhaseComponentBuffer moleFrac_{}; + PhaseComponentBuffer massFrac_{}; + PhaseComponentBuffer molarity_{}; + ComponentBuffer totalMassFrac_{}; + ComponentBuffer totalMoleFrac_{}; + + ComponentBuffer fugacity_{}; + PhaseComponentBuffer fugacityCoeff_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkcompositionparams.cpp b/opm/models/io/vtkcompositionparams.cpp new file mode 100644 index 00000000000..0da6dc51f25 --- /dev/null +++ b/opm/models/io/vtkcompositionparams.cpp @@ -0,0 +1,60 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkCompositionParams::registerParameters() +{ + Parameters::Register + ("Include mass fractions in the VTK output files"); + Parameters::Register + ("Include mole fractions in the VTK output files"); + Parameters::Register + ("Include total mass fractions in the VTK output files"); + Parameters::Register + ("Include total mole fractions in the VTK output files"); + Parameters::Register + ("Include component molarities in the VTK output files"); + Parameters::Register + ("Include component fugacities in the VTK output files"); + Parameters::Register + ("Include component fugacity coefficients in the VTK output files"); +} + +void VtkCompositionParams::read() +{ + massFracOutput_ = Parameters::Get(); + moleFracOutput_ = Parameters::Get(); + totalMassFracOutput_ = Parameters::Get(); + totalMoleFracOutput_ = Parameters::Get(); + molarityOutput_ = Parameters::Get(); + fugacityOutput_ = Parameters::Get(); + fugacityCoeffOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkcompositionparams.hpp b/opm/models/io/vtkcompositionparams.hpp new file mode 100644 index 00000000000..c16b23fdb68 --- /dev/null +++ b/opm/models/io/vtkcompositionparams.hpp @@ -0,0 +1,67 @@ +// -*- 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::VtkCompositionModule + */ +#ifndef OPM_VTK_COMPOSITION_PARAMS_HPP +#define OPM_VTK_COMPOSITION_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteMassFractions { static constexpr bool value = false; }; +struct VtkWriteMoleFractions { static constexpr bool value = true; }; +struct VtkWriteTotalMassFractions { static constexpr bool value = false; }; +struct VtkWriteTotalMoleFractions { static constexpr bool value = false; }; +struct VtkWriteMolarities { static constexpr bool value = false; }; +struct VtkWriteFugacities { static constexpr bool value = false; }; +struct VtkWriteFugacityCoeffs { static constexpr bool value = false; }; + +} // namespace Opm::Properties + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkCompositionModule. + */ +struct VtkCompositionParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool massFracOutput_; + bool moleFracOutput_; + bool totalMassFracOutput_; + bool totalMoleFracOutput_; + bool molarityOutput_; + bool fugacityOutput_; + bool fugacityCoeffOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_COMPOSITION_PARAMS_HPP From 6ab0fbe6c203ab40ed601d9467d3fe27681a2981 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:51:37 +0200 Subject: [PATCH 16/33] vtkdiffusionmodule.hh: rename to vtkdiffusionmodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/blackoil/blackoilmodel.hh | 2 +- opm/models/flash/flashmodel.hh | 2 +- .../io/{vtkdiffusionmodule.hh => vtkdiffusionmodule.hpp} | 7 ++++--- opm/models/ncp/ncpmodel.hh | 2 +- opm/models/ncp/ncpproperties.hh | 2 +- opm/models/ptflash/flashmodel.hh | 2 +- opm/models/pvs/pvsmodel.hh | 2 +- opm/models/pvs/pvsproperties.hh | 2 +- opm/simulators/flow/FlowUtils.cpp | 2 +- 10 files changed, 13 insertions(+), 12 deletions(-) rename opm/models/io/{vtkdiffusionmodule.hh => vtkdiffusionmodule.hpp} (98%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 43245d150c2..840c3d25b6e 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -667,7 +667,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkblackoilsolventparams.hpp opm/models/io/vtkcompositionmodule.hpp opm/models/io/vtkcompositionparams.hpp - opm/models/io/vtkdiffusionmodule.hh + opm/models/io/vtkdiffusionmodule.hpp opm/models/io/vtkdiscretefracturemodule.hh opm/models/io/vtkenergymodule.hh opm/models/io/vtkmultiphasemodule.hh diff --git a/opm/models/blackoil/blackoilmodel.hh b/opm/models/blackoil/blackoilmodel.hh index b28417d68ed..c469ebcabf7 100644 --- a/opm/models/blackoil/blackoilmodel.hh +++ b/opm/models/blackoil/blackoilmodel.hh @@ -57,7 +57,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/flash/flashmodel.hh b/opm/models/flash/flashmodel.hh index 8475d44a2fc..f0bb6fe7cc0 100644 --- a/opm/models/flash/flashmodel.hh +++ b/opm/models/flash/flashmodel.hh @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/io/vtkdiffusionmodule.hh b/opm/models/io/vtkdiffusionmodule.hpp similarity index 98% rename from opm/models/io/vtkdiffusionmodule.hh rename to opm/models/io/vtkdiffusionmodule.hpp index f8f12a403d1..cab4f2a9b67 100644 --- a/opm/models/io/vtkdiffusionmodule.hh +++ b/opm/models/io/vtkdiffusionmodule.hpp @@ -25,8 +25,8 @@ * * \copydoc Opm::VtkDiffusionModule */ -#ifndef EWOMS_VTK_DIFFUSION_MODULE_HH -#define EWOMS_VTK_DIFFUSION_MODULE_HH +#ifndef OPM_VTK_DIFFUSION_MODULE_HPP +#define OPM_VTK_DIFFUSION_MODULE_HPP #include #include @@ -49,6 +49,7 @@ struct VtkWriteEffectiveDiffusionCoefficients { static constexpr bool value = fa } // namespace Opm::Parameters namespace Opm { + /*! * \ingroup Vtk * @@ -191,4 +192,4 @@ class VtkDiffusionModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_DIFFUSION_MODULE_HPP diff --git a/opm/models/ncp/ncpmodel.hh b/opm/models/ncp/ncpmodel.hh index 6a1c1320615..1fc89e6807d 100644 --- a/opm/models/ncp/ncpmodel.hh +++ b/opm/models/ncp/ncpmodel.hh @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include diff --git a/opm/models/ncp/ncpproperties.hh b/opm/models/ncp/ncpproperties.hh index 1576b28f038..bae42c7f46d 100644 --- a/opm/models/ncp/ncpproperties.hh +++ b/opm/models/ncp/ncpproperties.hh @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace Opm::Properties { diff --git a/opm/models/ptflash/flashmodel.hh b/opm/models/ptflash/flashmodel.hh index a7d4c944a6b..d6562097645 100644 --- a/opm/models/ptflash/flashmodel.hh +++ b/opm/models/ptflash/flashmodel.hh @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/pvs/pvsmodel.hh b/opm/models/pvs/pvsmodel.hh index 3466cd23352..02ba8ba7a3f 100644 --- a/opm/models/pvs/pvsmodel.hh +++ b/opm/models/pvs/pvsmodel.hh @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/pvs/pvsproperties.hh b/opm/models/pvs/pvsproperties.hh index 1ba75d2255d..b121096a4e7 100644 --- a/opm/models/pvs/pvsproperties.hh +++ b/opm/models/pvs/pvsproperties.hh @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include namespace Opm::Properties { diff --git a/opm/simulators/flow/FlowUtils.cpp b/opm/simulators/flow/FlowUtils.cpp index b94e7e6e20e..a1e39d46a8e 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include From 28995d3624983b47d09b6d248d963ff5a2fefccf Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 17/33] vtkdiffusionmodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkdiffusionmodule.hpp | 77 ++++++++++------------------ opm/models/io/vtkdiffusionparams.cpp | 50 ++++++++++++++++++ opm/models/io/vtkdiffusionparams.hpp | 60 ++++++++++++++++++++++ 4 files changed, 140 insertions(+), 49 deletions(-) create mode 100644 opm/models/io/vtkdiffusionparams.cpp create mode 100644 opm/models/io/vtkdiffusionparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 840c3d25b6e..d60420b9452 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -68,6 +68,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkblackoilparams.cpp opm/models/io/vtkblackoilsolventparams.cpp opm/models/io/vtkcompositionparams.cpp + opm/models/io/vtkdiffusionparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -668,6 +669,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkcompositionmodule.hpp opm/models/io/vtkcompositionparams.hpp opm/models/io/vtkdiffusionmodule.hpp + opm/models/io/vtkdiffusionparams.hpp opm/models/io/vtkdiscretefracturemodule.hh opm/models/io/vtkenergymodule.hh opm/models/io/vtkmultiphasemodule.hh diff --git a/opm/models/io/vtkdiffusionmodule.hpp b/opm/models/io/vtkdiffusionmodule.hpp index cab4f2a9b67..3d02fa0690e 100644 --- a/opm/models/io/vtkdiffusionmodule.hpp +++ b/opm/models/io/vtkdiffusionmodule.hpp @@ -34,20 +34,12 @@ #include #include +#include #include #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteTortuosities { static constexpr bool value = false; }; -struct VtkWriteDiffusionCoefficients { static constexpr bool value = false; }; -struct VtkWriteEffectiveDiffusionCoefficients { static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -85,21 +77,16 @@ class VtkDiffusionModule : public BaseOutputModule public: VtkDiffusionModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the Vtk output module. */ static void registerParameters() { - Parameters::Register - ("Include the tortuosity for each phase in the VTK output files"); - Parameters::Register - ("Include the molecular diffusion coefficients in " - "the VTK output files"); - Parameters::Register - ("Include the effective molecular diffusion " - "coefficients the medium in the VTK output files"); + VtkDiffusionParams::registerParameters(); } /*! @@ -108,12 +95,15 @@ class VtkDiffusionModule : public BaseOutputModule */ void allocBuffers() { - if (tortuosityOutput_()) + if (params_.tortuosityOutput_) { this->resizePhaseBuffer_(tortuosity_); - if (diffusionCoefficientOutput_()) + } + if (params_.diffusionCoefficientOutput_) { this->resizePhaseComponentBuffer_(diffusionCoefficient_); - if (effectiveDiffusionCoefficientOutput_()) + } + if (params_.effectiveDiffusionCoefficientOutput_) { this->resizePhaseComponentBuffer_(effectiveDiffusionCoefficient_); + } } /*! @@ -131,15 +121,18 @@ class VtkDiffusionModule : public BaseOutputModule const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - if (tortuosityOutput_()) + if (params_.tortuosityOutput_) { tortuosity_[phaseIdx][I] = Toolbox::value(intQuants.tortuosity(phaseIdx)); + } for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { - if (diffusionCoefficientOutput_()) + if (params_.diffusionCoefficientOutput_) { diffusionCoefficient_[phaseIdx][compIdx][I] = Toolbox::value(intQuants.diffusionCoefficient(phaseIdx, compIdx)); - if (effectiveDiffusionCoefficientOutput_()) + } + if (params_.effectiveDiffusionCoefficientOutput_) { effectiveDiffusionCoefficient_[phaseIdx][compIdx][I] = Toolbox::value(intQuants.effectiveDiffusionCoefficient(phaseIdx, compIdx)); + } } } } @@ -150,44 +143,30 @@ class VtkDiffusionModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (tortuosityOutput_()) + if (params_.tortuosityOutput_) { this->commitPhaseBuffer_(baseWriter, "tortuosity", tortuosity_); - if (diffusionCoefficientOutput_()) + } + if (params_.diffusionCoefficientOutput_) { this->commitPhaseComponentBuffer_(baseWriter, "diffusionCoefficient", diffusionCoefficient_); - if (effectiveDiffusionCoefficientOutput_()) + } + if (params_.effectiveDiffusionCoefficientOutput_) { this->commitPhaseComponentBuffer_(baseWriter, "effectiveDiffusionCoefficient", effectiveDiffusionCoefficient_); + } } private: - static bool tortuosityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool diffusionCoefficientOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool effectiveDiffusionCoefficientOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - PhaseBuffer tortuosity_; - PhaseComponentBuffer diffusionCoefficient_; - PhaseComponentBuffer effectiveDiffusionCoefficient_; + VtkDiffusionParams params_{}; + PhaseBuffer tortuosity_{}; + PhaseComponentBuffer diffusionCoefficient_{}; + PhaseComponentBuffer effectiveDiffusionCoefficient_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkdiffusionparams.cpp b/opm/models/io/vtkdiffusionparams.cpp new file mode 100644 index 00000000000..da78bc43107 --- /dev/null +++ b/opm/models/io/vtkdiffusionparams.cpp @@ -0,0 +1,50 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkDiffusionParams::registerParameters() +{ + Parameters::Register + ("Include the tortuosity for each phase in the VTK output files"); + Parameters::Register + ("Include the molecular diffusion coefficients in " + "the VTK output files"); + Parameters::Register + ("Include the effective molecular diffusion " + "coefficients the medium in the VTK output files"); +} + +void VtkDiffusionParams::read() +{ + tortuosityOutput_ = Parameters::Get(); + diffusionCoefficientOutput_ = Parameters::Get(); + effectiveDiffusionCoefficientOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkdiffusionparams.hpp b/opm/models/io/vtkdiffusionparams.hpp new file mode 100644 index 00000000000..4347321a276 --- /dev/null +++ b/opm/models/io/vtkdiffusionparams.hpp @@ -0,0 +1,60 @@ +// -*- 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::VtkDiffusionModule + */ +#ifndef OPM_VTK_DIFFUSION_PARAMS_HPP +#define OPM_VTK_DIFFUSION_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteTortuosities { static constexpr bool value = false; }; +struct VtkWriteDiffusionCoefficients { static constexpr bool value = false; }; +struct VtkWriteEffectiveDiffusionCoefficients { static constexpr bool value = false; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkDiffusionModule. + */ +struct VtkDiffusionParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool tortuosityOutput_; + bool diffusionCoefficientOutput_; + bool effectiveDiffusionCoefficientOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_DIFFUSION_PARAMS_HPP From ca56913816497008018bb75d3eddf84c98272828 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:51:37 +0200 Subject: [PATCH 18/33] vtkdiscretefracturemodule.hh: rename to vtkdiscretefracuremodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/discretefracture/discretefracturemodel.hh | 2 +- opm/models/discretefracture/discretefractureproperties.hh | 2 +- ...retefracturemodule.hh => vtkdiscretefracturemodule.hpp} | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) rename opm/models/io/{vtkdiscretefracturemodule.hh => vtkdiscretefracturemodule.hpp} (99%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index d60420b9452..e4999942154 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -670,7 +670,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkcompositionparams.hpp opm/models/io/vtkdiffusionmodule.hpp opm/models/io/vtkdiffusionparams.hpp - opm/models/io/vtkdiscretefracturemodule.hh + opm/models/io/vtkdiscretefracturemodule.hpp opm/models/io/vtkenergymodule.hh opm/models/io/vtkmultiphasemodule.hh opm/models/io/vtkmultiwriter.hh diff --git a/opm/models/discretefracture/discretefracturemodel.hh b/opm/models/discretefracture/discretefracturemodel.hh index b8a839ac854..ac7bcc2ebb1 100644 --- a/opm/models/discretefracture/discretefracturemodel.hh +++ b/opm/models/discretefracture/discretefracturemodel.hh @@ -38,7 +38,7 @@ #include "discretefractureproblem.hh" #include -#include +#include #include #include diff --git a/opm/models/discretefracture/discretefractureproperties.hh b/opm/models/discretefracture/discretefractureproperties.hh index 7d2b929ea93..22d356c5a00 100644 --- a/opm/models/discretefracture/discretefractureproperties.hh +++ b/opm/models/discretefracture/discretefractureproperties.hh @@ -32,7 +32,7 @@ #include -#include +#include namespace Opm::Properties { diff --git a/opm/models/io/vtkdiscretefracturemodule.hh b/opm/models/io/vtkdiscretefracturemodule.hpp similarity index 99% rename from opm/models/io/vtkdiscretefracturemodule.hh rename to opm/models/io/vtkdiscretefracturemodule.hpp index 14251282fd8..ae70de96a7f 100644 --- a/opm/models/io/vtkdiscretefracturemodule.hh +++ b/opm/models/io/vtkdiscretefracturemodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkDiscreteFractureModule */ -#ifndef EWOMS_VTK_DISCRETE_FRACTURE_MODULE_HH -#define EWOMS_VTK_DISCRETE_FRACTURE_MODULE_HH +#ifndef OPM_VTK_DISCRETE_FRACTURE_MODULE_HPP +#define OPM_VTK_DISCRETE_FRACTURE_MODULE_HPP #include @@ -55,6 +55,7 @@ struct VtkWriteFractureVolumeFraction { static constexpr bool value = true; }; } // namespace Opm::Parameters namespace Opm { + /*! * \ingroup Vtk * @@ -347,4 +348,4 @@ class VtkDiscreteFractureModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_DISCRETE_FRACTURE_MODULE_HPP From b1afd79cd9b3e7e9723c91b9d38f4160acd7dff6 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 19/33] vtkdiscretefracturemodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkdiscretefracturemodule.hpp | 165 +++++++------------- opm/models/io/vtkdiscretefractureparams.cpp | 62 ++++++++ opm/models/io/vtkdiscretefractureparams.hpp | 67 ++++++++ 4 files changed, 188 insertions(+), 108 deletions(-) create mode 100644 opm/models/io/vtkdiscretefractureparams.cpp create mode 100644 opm/models/io/vtkdiscretefractureparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index e4999942154..3eb385e1f4d 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -69,6 +69,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkblackoilsolventparams.cpp opm/models/io/vtkcompositionparams.cpp opm/models/io/vtkdiffusionparams.cpp + opm/models/io/vtkdiscretefractureparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -671,6 +672,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkdiffusionmodule.hpp opm/models/io/vtkdiffusionparams.hpp opm/models/io/vtkdiscretefracturemodule.hpp + opm/models/io/vtkdiscretefractureparams.hpp opm/models/io/vtkenergymodule.hh opm/models/io/vtkmultiphasemodule.hh opm/models/io/vtkmultiwriter.hh diff --git a/opm/models/io/vtkdiscretefracturemodule.hpp b/opm/models/io/vtkdiscretefracturemodule.hpp index ae70de96a7f..0a2718e9c31 100644 --- a/opm/models/io/vtkdiscretefracturemodule.hpp +++ b/opm/models/io/vtkdiscretefracturemodule.hpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -41,19 +42,6 @@ #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteFractureSaturations { static constexpr bool value = true; }; -struct VtkWriteFractureMobilities { static constexpr bool value = false; }; -struct VtkWriteFractureRelativePermeabilities { static constexpr bool value = true; }; -struct VtkWriteFracturePorosity { static constexpr bool value = true; }; -struct VtkWriteFractureIntrinsicPermeabilities { static constexpr bool value = false; }; -struct VtkWriteFractureFilterVelocities { static constexpr bool value = false; }; -struct VtkWriteFractureVolumeFraction { static constexpr bool value = true; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -98,29 +86,16 @@ class VtkDiscreteFractureModule : public BaseOutputModule public: VtkDiscreteFractureModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the multi-phase VTK output module. */ static void registerParameters() { - Parameters::Register - ("Include the phase saturations in the VTK output files"); - Parameters::Register - ("Include the phase mobilities in the VTK output files"); - Parameters::Register - ("Include the phase relative permeabilities in the " - "VTK output files"); - Parameters::Register - ("Include the porosity in the VTK output files"); - Parameters::Register - ("Include the intrinsic permeability in the VTK output files"); - Parameters::Register - ("Include in the filter velocities of the phases in the VTK output files"); - Parameters::Register - ("Add the fraction of the total volume which is " - "occupied by fractures in the VTK output"); + VtkDiscreteFractureParams::registerParameters(); } /*! @@ -129,21 +104,27 @@ class VtkDiscreteFractureModule : public BaseOutputModule */ void allocBuffers() { - if (saturationOutput_()) + if (params_.saturationOutput_) { this->resizePhaseBuffer_(fractureSaturation_); - if (mobilityOutput_()) + } + if (params_.mobilityOutput_) { this->resizePhaseBuffer_(fractureMobility_); - if (relativePermeabilityOutput_()) + } + if (params_.relativePermeabilityOutput_) { this->resizePhaseBuffer_(fractureRelativePermeability_); + } - if (porosityOutput_()) + if (params_.porosityOutput_) { this->resizeScalarBuffer_(fracturePorosity_); - if (intrinsicPermeabilityOutput_()) + } + if (params_.intrinsicPermeabilityOutput_) { this->resizeScalarBuffer_(fractureIntrinsicPermeability_); - if (volumeFractionOutput_()) + } + if (params_.volumeFractionOutput_) { this->resizeScalarBuffer_(fractureVolumeFraction_); + } - if (velocityOutput_()) { + if (params_.velocityOutput_) { size_t nDof = this->simulator_.model().numGridDof(); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { fractureVelocity_[phaseIdx].resize(nDof); @@ -170,43 +151,44 @@ class VtkDiscreteFractureModule : public BaseOutputModule for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); - if (!fractureMapper.isFractureVertex(I)) + if (!fractureMapper.isFractureVertex(I)) { continue; + } const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0); const auto& fs = intQuants.fractureFluidState(); - if (porosityOutput_()) { + if (params_.porosityOutput_) { Opm::Valgrind::CheckDefined(intQuants.fracturePorosity()); fracturePorosity_[I] = intQuants.fracturePorosity(); } - if (intrinsicPermeabilityOutput_()) { + if (params_.intrinsicPermeabilityOutput_) { const auto& K = intQuants.fractureIntrinsicPermeability(); fractureIntrinsicPermeability_[I] = K[0][0]; } for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - if (saturationOutput_()) { + if (params_.saturationOutput_) { Opm::Valgrind::CheckDefined(fs.saturation(phaseIdx)); fractureSaturation_[phaseIdx][I] = fs.saturation(phaseIdx); } - if (mobilityOutput_()) { + if (params_.mobilityOutput_) { Opm::Valgrind::CheckDefined(intQuants.fractureMobility(phaseIdx)); fractureMobility_[phaseIdx][I] = intQuants.fractureMobility(phaseIdx); } - if (relativePermeabilityOutput_()) { + if (params_.relativePermeabilityOutput_) { Opm::Valgrind::CheckDefined(intQuants.fractureRelativePermeability(phaseIdx)); fractureRelativePermeability_[phaseIdx][I] = intQuants.fractureRelativePermeability(phaseIdx); } - if (volumeFractionOutput_()) { + if (params_.volumeFractionOutput_) { Opm::Valgrind::CheckDefined(intQuants.fractureVolume()); fractureVolumeFraction_[I] += intQuants.fractureVolume(); } } } - if (velocityOutput_()) { + if (params_.velocityOutput_) { // calculate velocities if requested by the simulator for (unsigned scvfIdx = 0; scvfIdx < elemCtx.numInteriorFaces(/*timeIdx=*/0); ++ scvfIdx) { const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, /*timeIdx=*/0); @@ -217,8 +199,9 @@ class VtkDiscreteFractureModule : public BaseOutputModule unsigned j = extQuants.exteriorIndex(); unsigned J = elemCtx.globalSpaceIndex(j, /*timeIdx=*/0); - if (!fractureMapper.isFractureEdge(I, J)) + if (!fractureMapper.isFractureEdge(I, J)) { continue; + } for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { Scalar weight = @@ -247,38 +230,45 @@ class VtkDiscreteFractureModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (saturationOutput_()) + if (params_.saturationOutput_) { this->commitPhaseBuffer_(baseWriter, "fractureSaturation_%s", fractureSaturation_); - if (mobilityOutput_()) + } + if (params_.mobilityOutput_) { this->commitPhaseBuffer_(baseWriter, "fractureMobility_%s", fractureMobility_); - if (relativePermeabilityOutput_()) + } + if (params_.relativePermeabilityOutput_) { this->commitPhaseBuffer_(baseWriter, "fractureRelativePerm_%s", fractureRelativePermeability_); + } - if (porosityOutput_()) + if (params_.porosityOutput_) { this->commitScalarBuffer_(baseWriter, "fracturePorosity", fracturePorosity_); - if (intrinsicPermeabilityOutput_()) + } + if (params_.intrinsicPermeabilityOutput_) { this->commitScalarBuffer_(baseWriter, "fractureIntrinsicPerm", fractureIntrinsicPermeability_); - if (volumeFractionOutput_()) { + } + if (params_.volumeFractionOutput_) { // divide the fracture volume by the total volume of the finite volumes - for (unsigned I = 0; I < fractureVolumeFraction_.size(); ++I) + for (unsigned I = 0; I < fractureVolumeFraction_.size(); ++I) { fractureVolumeFraction_[I] /= this->simulator_.model().dofTotalVolume(I); + } this->commitScalarBuffer_(baseWriter, "fractureVolumeFraction", fractureVolumeFraction_); } - if (velocityOutput_()) { + if (params_.velocityOutput_) { size_t nDof = this->simulator_.model().numGridDof(); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { // first, divide the velocity field by the // respective finite volume's surface area - for (unsigned dofIdx = 0; dofIdx < nDof; ++dofIdx) + for (unsigned dofIdx = 0; dofIdx < nDof; ++dofIdx) { fractureVelocity_[phaseIdx][dofIdx] /= std::max(1e-20, fractureVelocityWeight_[phaseIdx][dofIdx]); + } // commit the phase velocity char name[512]; snprintf(name, 512, "fractureFilterVelocity_%s", FluidSystem::phaseName(phaseIdx).data()); @@ -289,61 +279,20 @@ class VtkDiscreteFractureModule : public BaseOutputModule } private: - static bool saturationOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool mobilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool relativePermeabilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool porosityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool intrinsicPermeabilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool volumeFractionOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool velocityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - PhaseBuffer fractureSaturation_; - PhaseBuffer fractureMobility_; - PhaseBuffer fractureRelativePermeability_; + VtkDiscreteFractureParams params_{}; + PhaseBuffer fractureSaturation_{}; + PhaseBuffer fractureMobility_{}; + PhaseBuffer fractureRelativePermeability_{}; - ScalarBuffer fracturePorosity_; - ScalarBuffer fractureVolumeFraction_; - ScalarBuffer fractureIntrinsicPermeability_; + ScalarBuffer fracturePorosity_{}; + ScalarBuffer fractureVolumeFraction_{}; + ScalarBuffer fractureIntrinsicPermeability_{}; - PhaseVectorBuffer fractureVelocity_; - PhaseBuffer fractureVelocityWeight_; + PhaseVectorBuffer fractureVelocity_{}; + PhaseBuffer fractureVelocityWeight_{}; - PhaseVectorBuffer potentialGradient_; - PhaseBuffer potentialWeight_; + PhaseVectorBuffer potentialGradient_{}; + PhaseBuffer potentialWeight_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkdiscretefractureparams.cpp b/opm/models/io/vtkdiscretefractureparams.cpp new file mode 100644 index 00000000000..9f1c075ec89 --- /dev/null +++ b/opm/models/io/vtkdiscretefractureparams.cpp @@ -0,0 +1,62 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkDiscreteFractureParams::registerParameters() +{ + Parameters::Register + ("Include the phase saturations in the VTK output files"); + Parameters::Register + ("Include the phase mobilities in the VTK output files"); + Parameters::Register + ("Include the phase relative permeabilities in the " + "VTK output files"); + Parameters::Register + ("Include the porosity in the VTK output files"); + Parameters::Register + ("Include the intrinsic permeability in the VTK output files"); + Parameters::Register + ("Include in the filter velocities of the phases in the VTK output files"); + Parameters::Register + ("Add the fraction of the total volume which is " + "occupied by fractures in the VTK output"); +} + +void VtkDiscreteFractureParams::read() +{ + saturationOutput_ = Parameters::Get(); + mobilityOutput_ = Parameters::Get(); + relativePermeabilityOutput_ = Parameters::Get(); + porosityOutput_ = Parameters::Get(); + intrinsicPermeabilityOutput_ = Parameters::Get(); + volumeFractionOutput_ = Parameters::Get(); + velocityOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkdiscretefractureparams.hpp b/opm/models/io/vtkdiscretefractureparams.hpp new file mode 100644 index 00000000000..7afdedff7bb --- /dev/null +++ b/opm/models/io/vtkdiscretefractureparams.hpp @@ -0,0 +1,67 @@ +// -*- 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::VtkDiscreteFractureModule + */ +#ifndef OPM_VTK_DISCRETE_FRACTURE_PARAMS_HPP +#define OPM_VTK_DISCRETE_FRACTURE_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteFractureSaturations { static constexpr bool value = true; }; +struct VtkWriteFractureMobilities { static constexpr bool value = false; }; +struct VtkWriteFractureRelativePermeabilities { static constexpr bool value = true; }; +struct VtkWriteFracturePorosity { static constexpr bool value = true; }; +struct VtkWriteFractureIntrinsicPermeabilities { static constexpr bool value = false; }; +struct VtkWriteFractureFilterVelocities { static constexpr bool value = false; }; +struct VtkWriteFractureVolumeFraction { static constexpr bool value = true; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkDiscreteFractureModule. + */ +struct VtkDiscreteFractureParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool saturationOutput_; + bool mobilityOutput_; + bool relativePermeabilityOutput_; + bool porosityOutput_; + bool intrinsicPermeabilityOutput_; + bool volumeFractionOutput_; + bool velocityOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_DISCRETE_FRACTURE_MODULE_HPP From 85bbba93fa6752a3f12b637e3b1b984f48765644 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:51:37 +0200 Subject: [PATCH 20/33] vtkenergymodule.hh: rename to vtkenergymodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/flash/flashmodel.hh | 2 +- opm/models/immiscible/immisciblemodel.hh | 2 +- opm/models/immiscible/immiscibleproperties.hh | 2 +- opm/models/io/{vtkenergymodule.hh => vtkenergymodule.hpp} | 7 ++++--- opm/models/ncp/ncpmodel.hh | 2 +- opm/models/ncp/ncpproperties.hh | 2 +- opm/models/ptflash/flashmodel.hh | 2 +- opm/models/pvs/pvsmodel.hh | 2 +- opm/models/pvs/pvsproperties.hh | 2 +- 10 files changed, 13 insertions(+), 12 deletions(-) rename opm/models/io/{vtkenergymodule.hh => vtkenergymodule.hpp} (98%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 3eb385e1f4d..afbb8d471e6 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -673,7 +673,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkdiffusionparams.hpp opm/models/io/vtkdiscretefracturemodule.hpp opm/models/io/vtkdiscretefractureparams.hpp - opm/models/io/vtkenergymodule.hh + opm/models/io/vtkenergymodule.hpp opm/models/io/vtkmultiphasemodule.hh opm/models/io/vtkmultiwriter.hh opm/models/io/vtkphasepresencemodule.hh diff --git a/opm/models/flash/flashmodel.hh b/opm/models/flash/flashmodel.hh index f0bb6fe7cc0..e21b7957646 100644 --- a/opm/models/flash/flashmodel.hh +++ b/opm/models/flash/flashmodel.hh @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/immiscible/immisciblemodel.hh b/opm/models/immiscible/immisciblemodel.hh index c6a1401f225..65349002c22 100644 --- a/opm/models/immiscible/immisciblemodel.hh +++ b/opm/models/immiscible/immisciblemodel.hh @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include #include diff --git a/opm/models/immiscible/immiscibleproperties.hh b/opm/models/immiscible/immiscibleproperties.hh index 4dce4c4cd41..c1272df1e15 100644 --- a/opm/models/immiscible/immiscibleproperties.hh +++ b/opm/models/immiscible/immiscibleproperties.hh @@ -31,7 +31,7 @@ #define EWOMS_IMMISCIBLE_PROPERTIES_HH #include -#include +#include namespace Opm::Properties { diff --git a/opm/models/io/vtkenergymodule.hh b/opm/models/io/vtkenergymodule.hpp similarity index 98% rename from opm/models/io/vtkenergymodule.hh rename to opm/models/io/vtkenergymodule.hpp index 06cc4dad49f..5ac7b329308 100644 --- a/opm/models/io/vtkenergymodule.hh +++ b/opm/models/io/vtkenergymodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkEnergyModule */ -#ifndef EWOMS_VTK_ENERGY_MODULE_HH -#define EWOMS_VTK_ENERGY_MODULE_HH +#ifndef OPM_VTK_ENERGY_MODULE_HPP +#define OPM_VTK_ENERGY_MODULE_HPP #include @@ -48,6 +48,7 @@ struct VtkWriteEnthalpies { static constexpr bool value = false; }; } // namespace Opm::Parameters namespace Opm { + /*! * \ingroup Vtk * @@ -207,4 +208,4 @@ class VtkEnergyModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_ENERGY_MODULE_HPP diff --git a/opm/models/ncp/ncpmodel.hh b/opm/models/ncp/ncpmodel.hh index 1fc89e6807d..d0459ecdb05 100644 --- a/opm/models/ncp/ncpmodel.hh +++ b/opm/models/ncp/ncpmodel.hh @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include diff --git a/opm/models/ncp/ncpproperties.hh b/opm/models/ncp/ncpproperties.hh index bae42c7f46d..2120b8d8c16 100644 --- a/opm/models/ncp/ncpproperties.hh +++ b/opm/models/ncp/ncpproperties.hh @@ -32,7 +32,7 @@ #include #include -#include +#include #include namespace Opm::Properties { diff --git a/opm/models/ptflash/flashmodel.hh b/opm/models/ptflash/flashmodel.hh index d6562097645..ce7efcec4b8 100644 --- a/opm/models/ptflash/flashmodel.hh +++ b/opm/models/ptflash/flashmodel.hh @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/pvs/pvsmodel.hh b/opm/models/pvs/pvsmodel.hh index 02ba8ba7a3f..f5c600d76fa 100644 --- a/opm/models/pvs/pvsmodel.hh +++ b/opm/models/pvs/pvsmodel.hh @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/pvs/pvsproperties.hh b/opm/models/pvs/pvsproperties.hh index b121096a4e7..2a857fbc707 100644 --- a/opm/models/pvs/pvsproperties.hh +++ b/opm/models/pvs/pvsproperties.hh @@ -36,7 +36,7 @@ #include #include #include -#include +#include namespace Opm::Properties { From 924da68d0274bd49c401706624af06d324cd3acf Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 21/33] vtkenergymodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkenergymodule.hpp | 96 +++++++++++-------------------- opm/models/io/vtkenergyparams.cpp | 55 ++++++++++++++++++ opm/models/io/vtkenergyparams.hpp | 61 ++++++++++++++++++++ 4 files changed, 151 insertions(+), 63 deletions(-) create mode 100644 opm/models/io/vtkenergyparams.cpp create mode 100644 opm/models/io/vtkenergyparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index afbb8d471e6..6c195cc35e6 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -70,6 +70,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkcompositionparams.cpp opm/models/io/vtkdiffusionparams.cpp opm/models/io/vtkdiscretefractureparams.cpp + opm/models/io/vtkenergyparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -674,6 +675,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkdiscretefracturemodule.hpp opm/models/io/vtkdiscretefractureparams.hpp opm/models/io/vtkenergymodule.hpp + opm/models/io/vtkenergyparams.hpp opm/models/io/vtkmultiphasemodule.hh opm/models/io/vtkmultiwriter.hh opm/models/io/vtkphasepresencemodule.hh diff --git a/opm/models/io/vtkenergymodule.hpp b/opm/models/io/vtkenergymodule.hpp index 5ac7b329308..394d3af6b01 100644 --- a/opm/models/io/vtkenergymodule.hpp +++ b/opm/models/io/vtkenergymodule.hpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -37,16 +38,6 @@ #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteSolidInternalEnergy { static constexpr bool value = false; }; -struct VtkWriteThermalConductivity { static constexpr bool value = false; }; -struct VtkWriteInternalEnergies { static constexpr bool value = false; }; -struct VtkWriteEnthalpies { static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -86,6 +77,7 @@ class VtkEnergyModule : public BaseOutputModule VtkEnergyModule(const Simulator& simulator) : ParentType(simulator) { + params_.read(); } /*! @@ -93,18 +85,7 @@ class VtkEnergyModule : public BaseOutputModule */ static void registerParameters() { - Parameters::Register - ("Include the volumetric internal energy of solid" - "matrix in the VTK output files"); - Parameters::Register - ("Include the total thermal conductivity of the" - "medium in the VTK output files"); - Parameters::Register - ("Include the specific enthalpy of the phases in " - "the VTK output files"); - Parameters::Register - ("Include the specific internal energy of the " - "phases in the VTK output files"); + VtkEnergyParams::registerParameters(); } /*! @@ -113,15 +94,19 @@ class VtkEnergyModule : public BaseOutputModule */ void allocBuffers() { - if (enthalpyOutput_()) + if (params_.enthalpyOutput_) { this->resizePhaseBuffer_(enthalpy_); - if (internalEnergyOutput_()) + } + if (params_.internalEnergyOutput_) { this->resizePhaseBuffer_(internalEnergy_); + } - if (solidInternalEnergyOutput_()) + if (params_.solidInternalEnergyOutput_) { this->resizeScalarBuffer_(solidInternalEnergy_); - if (thermalConductivityOutput_()) + } + if (params_.thermalConductivityOutput_) { this->resizeScalarBuffer_(thermalConductivity_); + } } /*! @@ -139,16 +124,20 @@ class VtkEnergyModule : public BaseOutputModule const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0); const auto& fs = intQuants.fluidState(); - if (solidInternalEnergyOutput_()) + if (params_.solidInternalEnergyOutput_) { solidInternalEnergy_[I] = Toolbox::value(intQuants.solidInternalEnergy()); - if (thermalConductivityOutput_()) + } + if (params_.thermalConductivityOutput_) { thermalConductivity_[I] = Toolbox::value(intQuants.thermalConductivity()); + } for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - if (enthalpyOutput_()) + if (params_.enthalpyOutput_) { enthalpy_[phaseIdx][I] = Toolbox::value(fs.enthalpy(phaseIdx)); - if (internalEnergyOutput_()) + } + if (params_.internalEnergyOutput_) { internalEnergy_[phaseIdx][I] = Toolbox::value(fs.internalEnergy(phaseIdx)); + } } } } @@ -158,52 +147,33 @@ class VtkEnergyModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (solidInternalEnergyOutput_()) + if (params_.solidInternalEnergyOutput_) { this->commitScalarBuffer_(baseWriter, "internalEnergySolid", solidInternalEnergy_); - if (thermalConductivityOutput_()) + } + if (params_.thermalConductivityOutput_) { this->commitScalarBuffer_(baseWriter, "thermalConductivity", thermalConductivity_); + } - if (enthalpyOutput_()) + if (params_.enthalpyOutput_) { this->commitPhaseBuffer_(baseWriter, "enthalpy_%s", enthalpy_); - if (internalEnergyOutput_()) + } + if (params_.internalEnergyOutput_) { this->commitPhaseBuffer_(baseWriter, "internalEnergy_%s", internalEnergy_); + } } private: - static bool solidInternalEnergyOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool thermalConductivityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool enthalpyOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool internalEnergyOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - PhaseBuffer enthalpy_; - PhaseBuffer internalEnergy_; + VtkEnergyParams params_{}; + PhaseBuffer enthalpy_{}; + PhaseBuffer internalEnergy_{}; - ScalarBuffer thermalConductivity_; - ScalarBuffer solidInternalEnergy_; + ScalarBuffer thermalConductivity_{}; + ScalarBuffer solidInternalEnergy_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkenergyparams.cpp b/opm/models/io/vtkenergyparams.cpp new file mode 100644 index 00000000000..4cc297ee185 --- /dev/null +++ b/opm/models/io/vtkenergyparams.cpp @@ -0,0 +1,55 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkEnergyParams::registerParameters() +{ + Parameters::Register + ("Include the volumetric internal energy of solid" + "matrix in the VTK output files"); + Parameters::Register + ("Include the total thermal conductivity of the" + "medium in the VTK output files"); + Parameters::Register + ("Include the specific enthalpy of the phases in " + "the VTK output files"); + Parameters::Register + ("Include the specific internal energy of the " + "phases in the VTK output files"); +} + +void VtkEnergyParams::read() +{ + solidInternalEnergyOutput_ = Parameters::Get(); + thermalConductivityOutput_ = Parameters::Get(); + enthalpyOutput_ = Parameters::Get(); + internalEnergyOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkenergyparams.hpp b/opm/models/io/vtkenergyparams.hpp new file mode 100644 index 00000000000..5590fbdf4be --- /dev/null +++ b/opm/models/io/vtkenergyparams.hpp @@ -0,0 +1,61 @@ +// -*- 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::VtkEnergyModule + */ +#ifndef OPM_VTK_ENERGY_PARAMS_HPP +#define OPM_VTK_ENERGY_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteSolidInternalEnergy { static constexpr bool value = false; }; +struct VtkWriteThermalConductivity { static constexpr bool value = false; }; +struct VtkWriteInternalEnergies { static constexpr bool value = false; }; +struct VtkWriteEnthalpies { static constexpr bool value = false; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkEnergyModule. + */ +struct VtkEnergyParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool solidInternalEnergyOutput_; + bool thermalConductivityOutput_; + bool enthalpyOutput_; + bool internalEnergyOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_ENERGY_PARAMS_HPP From a895678c3084181d5f6307b5081633b9c547c457 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 22/33] vtkmultiphasemodule.hh: rename to vtkmultiphasemodule.hpp --- CMakeLists_files.cmake | 2 +- examples/problems/lensproblem.hh | 2 +- opm/models/common/multiphasebasemodel.hh | 2 +- .../io/{vtkmultiphasemodule.hh => vtkmultiphasemodule.hpp} | 6 +++--- opm/simulators/flow/FlowUtils.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename opm/models/io/{vtkmultiphasemodule.hh => vtkmultiphasemodule.hpp} (99%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 6c195cc35e6..2a828c7b9c8 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -676,7 +676,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkdiscretefractureparams.hpp opm/models/io/vtkenergymodule.hpp opm/models/io/vtkenergyparams.hpp - opm/models/io/vtkmultiphasemodule.hh + opm/models/io/vtkmultiphasemodule.hpp opm/models/io/vtkmultiwriter.hh opm/models/io/vtkphasepresencemodule.hh opm/models/io/vtkprimaryvarsmodule.hh diff --git a/examples/problems/lensproblem.hh b/examples/problems/lensproblem.hh index 3517005c2d6..542546e5c72 100644 --- a/examples/problems/lensproblem.hh +++ b/examples/problems/lensproblem.hh @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include diff --git a/opm/models/common/multiphasebasemodel.hh b/opm/models/common/multiphasebasemodel.hh index 1d251ac7396..e2bb8cb5f0f 100644 --- a/opm/models/common/multiphasebasemodel.hh +++ b/opm/models/common/multiphasebasemodel.hh @@ -44,7 +44,7 @@ #include -#include +#include #include namespace Opm { diff --git a/opm/models/io/vtkmultiphasemodule.hh b/opm/models/io/vtkmultiphasemodule.hpp similarity index 99% rename from opm/models/io/vtkmultiphasemodule.hh rename to opm/models/io/vtkmultiphasemodule.hpp index bf8e1e7a298..6d864eee3dc 100644 --- a/opm/models/io/vtkmultiphasemodule.hh +++ b/opm/models/io/vtkmultiphasemodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkMultiPhaseModule */ -#ifndef EWOMS_VTK_MULTI_PHASE_MODULE_HH -#define EWOMS_VTK_MULTI_PHASE_MODULE_HH +#ifndef OPM_VTK_MULTI_PHASE_MODULE_HPP +#define OPM_VTK_MULTI_PHASE_MODULE_HPP #include @@ -466,4 +466,4 @@ class VtkMultiPhaseModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_MULTI_PHASE_MODULE_HPP diff --git a/opm/simulators/flow/FlowUtils.cpp b/opm/simulators/flow/FlowUtils.cpp index a1e39d46a8e..e16247ea711 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include From f5e2b46c37e708c1e5b90696f8884baaa9f79923 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 23/33] vtkmultiphasemodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkmultiphasemodule.hpp | 302 +++++++++++--------------- opm/models/io/vtkmultiphaseparams.cpp | 75 +++++++ opm/models/io/vtkmultiphaseparams.hpp | 77 +++++++ 4 files changed, 275 insertions(+), 181 deletions(-) create mode 100644 opm/models/io/vtkmultiphaseparams.cpp create mode 100644 opm/models/io/vtkmultiphaseparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 2a828c7b9c8..71161dda28a 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -71,6 +71,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkdiffusionparams.cpp opm/models/io/vtkdiscretefractureparams.cpp opm/models/io/vtkenergyparams.cpp + opm/models/io/vtkmultiphaseparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -677,6 +678,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkenergymodule.hpp opm/models/io/vtkenergyparams.hpp opm/models/io/vtkmultiphasemodule.hpp + opm/models/io/vtkmultiphaseparams.hpp opm/models/io/vtkmultiwriter.hh opm/models/io/vtkphasepresencemodule.hh opm/models/io/vtkprimaryvarsmodule.hh diff --git a/opm/models/io/vtkmultiphasemodule.hpp b/opm/models/io/vtkmultiphasemodule.hpp index 6d864eee3dc..c8342ae0410 100644 --- a/opm/models/io/vtkmultiphasemodule.hpp +++ b/opm/models/io/vtkmultiphasemodule.hpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -42,24 +43,6 @@ #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteExtrusionFactor { static constexpr bool value = false; }; -struct VtkWritePressures { static constexpr bool value = true; }; -struct VtkWriteDensities { static constexpr bool value = true; }; -struct VtkWriteSaturations { static constexpr bool value = true; }; -struct VtkWriteMobilities { static constexpr bool value = false; }; -struct VtkWriteRelativePermeabilities { static constexpr bool value = true; }; -struct VtkWriteViscosities { static constexpr bool value = false; }; -struct VtkWriteAverageMolarMasses { static constexpr bool value = false; }; -struct VtkWritePorosity { static constexpr bool value = true; }; -struct VtkWriteIntrinsicPermeabilities { static constexpr bool value = false; }; -struct VtkWritePotentialGradients { static constexpr bool value = false; }; -struct VtkWriteFilterVelocities { static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -111,37 +94,16 @@ class VtkMultiPhaseModule : public BaseOutputModule public: VtkMultiPhaseModule(const Simulator& simulator) : ParentType(simulator) - {} + { + params_.read(); + } /*! * \brief Register all run-time parameters for the multi-phase VTK output module. */ static void registerParameters() { - Parameters::Register - ("Include the extrusion factor of the degrees of freedom into the VTK output files"); - Parameters::Register - ("Include the phase pressures in the VTK output files"); - Parameters::Register - ("Include the phase densities in the VTK output files"); - Parameters::Register - ("Include the phase saturations in the VTK output files"); - Parameters::Register - ("Include the phase mobilities in the VTK output files"); - Parameters::Register - ("Include the phase relative permeabilities in the VTK output files"); - Parameters::Register - ("Include component phase viscosities in the VTK output files"); - Parameters::Register - ("Include the average phase mass in the VTK output files"); - Parameters::Register - ("Include the porosity in the VTK output files"); - Parameters::Register - ("Include the intrinsic permeability in the VTK output files"); - Parameters::Register - ("Include in the filter velocities of the phases the VTK output files"); - Parameters::Register - ("Include the phase pressure potential gradients in the VTK output files"); + VtkMultiPhaseParams::registerParameters(); } /*! @@ -150,19 +112,39 @@ class VtkMultiPhaseModule : public BaseOutputModule */ void allocBuffers() { - if (extrusionFactorOutput_()) this->resizeScalarBuffer_(extrusionFactor_); - if (pressureOutput_()) this->resizePhaseBuffer_(pressure_); - if (densityOutput_()) this->resizePhaseBuffer_(density_); - if (saturationOutput_()) this->resizePhaseBuffer_(saturation_); - if (mobilityOutput_()) this->resizePhaseBuffer_(mobility_); - if (relativePermeabilityOutput_()) this->resizePhaseBuffer_(relativePermeability_); - if (viscosityOutput_()) this->resizePhaseBuffer_(viscosity_); - if (averageMolarMassOutput_()) this->resizePhaseBuffer_(averageMolarMass_); - - if (porosityOutput_()) this->resizeScalarBuffer_(porosity_); - if (intrinsicPermeabilityOutput_()) this->resizeTensorBuffer_(intrinsicPermeability_); - - if (velocityOutput_()) { + if (params_.extrusionFactorOutput_) { + this->resizeScalarBuffer_(extrusionFactor_); + } + if (params_.pressureOutput_) { + this->resizePhaseBuffer_(pressure_); + } + if (params_.densityOutput_) { + this->resizePhaseBuffer_(density_); + } + if (params_.saturationOutput_) { + this->resizePhaseBuffer_(saturation_); + } + if (params_.mobilityOutput_) { + this->resizePhaseBuffer_(mobility_); + } + if (params_.relativePermeabilityOutput_) { + this->resizePhaseBuffer_(relativePermeability_); + } + if (params_.viscosityOutput_) { + this->resizePhaseBuffer_(viscosity_); + } + if (params_.averageMolarMassOutput_) { + this->resizePhaseBuffer_(averageMolarMass_); + } + + if (params_.porosityOutput_) { + this->resizeScalarBuffer_(porosity_); + } + if (params_.intrinsicPermeabilityOutput_) { + this->resizeTensorBuffer_(intrinsicPermeability_); + } + + if (params_.velocityOutput_) { size_t nDof = this->simulator_.model().numGridDof(); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { velocity_[phaseIdx].resize(nDof); @@ -174,7 +156,7 @@ class VtkMultiPhaseModule : public BaseOutputModule this->resizePhaseBuffer_(velocityWeight_); } - if (potentialGradientOutput_()) { + if (params_.potentialGradientOutput_) { size_t nDof = this->simulator_.model().numGridDof(); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { potentialGradient_[phaseIdx].resize(nDof); @@ -204,38 +186,51 @@ class VtkMultiPhaseModule : public BaseOutputModule const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0); const auto& fs = intQuants.fluidState(); - if (extrusionFactorOutput_()) extrusionFactor_[I] = intQuants.extrusionFactor(); - if (porosityOutput_()) porosity_[I] = getValue(intQuants.porosity()); + if (params_.extrusionFactorOutput_) { + extrusionFactor_[I] = intQuants.extrusionFactor(); + } + if (params_.porosityOutput_) { + porosity_[I] = getValue(intQuants.porosity()); + } - if (intrinsicPermeabilityOutput_()) { + if (params_.intrinsicPermeabilityOutput_) { const auto& K = problem.intrinsicPermeability(elemCtx, i, /*timeIdx=*/0); - for (unsigned rowIdx = 0; rowIdx < K.rows; ++rowIdx) - for (unsigned colIdx = 0; colIdx < K.cols; ++colIdx) + for (unsigned rowIdx = 0; rowIdx < K.rows; ++rowIdx) { + for (unsigned colIdx = 0; colIdx < K.cols; ++colIdx) { intrinsicPermeability_[I][rowIdx][colIdx] = K[rowIdx][colIdx]; + } + } } for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { if (!FluidSystem::phaseIsActive(phaseIdx)) { continue; } - if (pressureOutput_()) + if (params_.pressureOutput_) { pressure_[phaseIdx][I] = getValue(fs.pressure(phaseIdx)); - if (densityOutput_()) + } + if (params_.densityOutput_) { density_[phaseIdx][I] = getValue(fs.density(phaseIdx)); - if (saturationOutput_()) + } + if (params_.saturationOutput_) { saturation_[phaseIdx][I] = getValue(fs.saturation(phaseIdx)); - if (mobilityOutput_()) + } + if (params_.mobilityOutput_) { mobility_[phaseIdx][I] = getValue(intQuants.mobility(phaseIdx)); - if (relativePermeabilityOutput_()) + } + if (params_.relativePermeabilityOutput_) { relativePermeability_[phaseIdx][I] = getValue(intQuants.relativePermeability(phaseIdx)); - if (viscosityOutput_()) + } + if (params_.viscosityOutput_) { viscosity_[phaseIdx][I] = getValue(fs.viscosity(phaseIdx)); - if (averageMolarMassOutput_()) + } + if (params_.averageMolarMassOutput_) { averageMolarMass_[phaseIdx][I] = getValue(fs.averageMolarMass(phaseIdx)); + } } } - if (potentialGradientOutput_()) { + if (params_.potentialGradientOutput_) { // calculate velocities if requested for (unsigned faceIdx = 0; faceIdx < elemCtx.numInteriorFaces(/*timeIdx=*/0); ++ faceIdx) { const auto& extQuants = elemCtx.extensiveQuantities(faceIdx, /*timeIdx=*/0); @@ -250,14 +245,15 @@ class VtkMultiPhaseModule : public BaseOutputModule const auto& inputPGrad = extQuants.potentialGrad(phaseIdx); DimVector pGrad; - for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx) + for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx) { pGrad[dimIdx] = getValue(inputPGrad[dimIdx])*weight; + } potentialGradient_[phaseIdx][I] += pGrad; } // end for all phases } // end for all faces } - if (velocityOutput_()) { + if (params_.velocityOutput_) { // calculate velocities if requested for (unsigned faceIdx = 0; faceIdx < elemCtx.numInteriorFaces(/*timeIdx=*/0); ++ faceIdx) { const auto& extQuants = elemCtx.extensiveQuantities(faceIdx, /*timeIdx=*/0); @@ -277,10 +273,12 @@ class VtkMultiPhaseModule : public BaseOutputModule const auto& inputV = extQuants.filterVelocity(phaseIdx); DimVector v; - for (unsigned k = 0; k < dimWorld; ++k) + for (unsigned k = 0; k < dimWorld; ++k) { v[k] = getValue(inputV[k]); - if (v.two_norm() > 1e-20) + } + if (v.two_norm() > 1e-20) { weight /= v.two_norm(); + } v *= weight; velocity_[phaseIdx][I] += v; @@ -298,40 +296,52 @@ class VtkMultiPhaseModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); - if (!vtkWriter) + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); + if (!vtkWriter) { return; + } - if (extrusionFactorOutput_()) + if (params_.extrusionFactorOutput_) { this->commitScalarBuffer_(baseWriter, "extrusionFactor", extrusionFactor_); - if (pressureOutput_()) + } + if (params_.pressureOutput_) { this->commitPhaseBuffer_(baseWriter, "pressure_%s", pressure_); - if (densityOutput_()) + } + if (params_.densityOutput_) { this->commitPhaseBuffer_(baseWriter, "density_%s", density_); - if (saturationOutput_()) + } + if (params_.saturationOutput_) { this->commitPhaseBuffer_(baseWriter, "saturation_%s", saturation_); - if (mobilityOutput_()) + } + if (params_.mobilityOutput_) { this->commitPhaseBuffer_(baseWriter, "mobility_%s", mobility_); - if (relativePermeabilityOutput_()) + } + if (params_.relativePermeabilityOutput_) { this->commitPhaseBuffer_(baseWriter, "relativePerm_%s", relativePermeability_); - if (viscosityOutput_()) + } + if (params_.viscosityOutput_) { this->commitPhaseBuffer_(baseWriter, "viscosity_%s", viscosity_); - if (averageMolarMassOutput_()) + } + if (params_.averageMolarMassOutput_) { this->commitPhaseBuffer_(baseWriter, "averageMolarMass_%s", averageMolarMass_); + } - if (porosityOutput_()) + if (params_.porosityOutput_) { this->commitScalarBuffer_(baseWriter, "porosity", porosity_); - if (intrinsicPermeabilityOutput_()) + } + if (params_.intrinsicPermeabilityOutput_) { this->commitTensorBuffer_(baseWriter, "intrinsicPerm", intrinsicPermeability_); + } - if (velocityOutput_()) { + if (params_.velocityOutput_) { size_t numDof = this->simulator_.model().numGridDof(); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { // first, divide the velocity field by the // respective finite volume's surface area - for (unsigned i = 0; i < numDof; ++i) + for (unsigned i = 0; i < numDof; ++i) { velocity_[phaseIdx][i] /= velocityWeight_[phaseIdx][i]; + } // commit the phase velocity char name[512]; snprintf(name, 512, "filterVelocity_%s", FluidSystem::phaseName(phaseIdx).data()); @@ -340,14 +350,15 @@ class VtkMultiPhaseModule : public BaseOutputModule } } - if (potentialGradientOutput_()) { + if (params_.potentialGradientOutput_) { size_t numDof = this->simulator_.model().numGridDof(); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { // first, divide the velocity field by the // respective finite volume's surface area - for (unsigned i = 0; i < numDof; ++i) + for (unsigned i = 0; i < numDof; ++i) { potentialGradient_[phaseIdx][i] /= potentialWeight_[phaseIdx][i]; + } // commit the phase velocity char name[512]; snprintf(name, 512, "gradP_%s", FluidSystem::phaseName(phaseIdx).data()); @@ -367,101 +378,30 @@ class VtkMultiPhaseModule : public BaseOutputModule * returning true here does not do any harm from the correctness perspective, but it * slows down writing the output fields. */ - virtual bool needExtensiveQuantities() const final + bool needExtensiveQuantities() const final { - return velocityOutput_() || potentialGradientOutput_(); + return params_.velocityOutput_ || params_.potentialGradientOutput_; } private: - static bool extrusionFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool pressureOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool densityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool saturationOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool mobilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool relativePermeabilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool viscosityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool averageMolarMassOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool porosityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool intrinsicPermeabilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool velocityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool potentialGradientOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ScalarBuffer extrusionFactor_; - PhaseBuffer pressure_; - PhaseBuffer density_; - PhaseBuffer saturation_; - PhaseBuffer mobility_; - PhaseBuffer relativePermeability_; - PhaseBuffer viscosity_; - PhaseBuffer averageMolarMass_; - - ScalarBuffer porosity_; - TensorBuffer intrinsicPermeability_; - - PhaseVectorBuffer velocity_; - PhaseBuffer velocityWeight_; - - PhaseVectorBuffer potentialGradient_; - PhaseBuffer potentialWeight_; + VtkMultiPhaseParams params_{}; + ScalarBuffer extrusionFactor_{}; + PhaseBuffer pressure_{}; + PhaseBuffer density_{}; + PhaseBuffer saturation_{}; + PhaseBuffer mobility_{}; + PhaseBuffer relativePermeability_{}; + PhaseBuffer viscosity_{}; + PhaseBuffer averageMolarMass_{}; + + ScalarBuffer porosity_{}; + TensorBuffer intrinsicPermeability_{}; + + PhaseVectorBuffer velocity_{}; + PhaseBuffer velocityWeight_{}; + + PhaseVectorBuffer potentialGradient_{}; + PhaseBuffer potentialWeight_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkmultiphaseparams.cpp b/opm/models/io/vtkmultiphaseparams.cpp new file mode 100644 index 00000000000..ed2ae98bce4 --- /dev/null +++ b/opm/models/io/vtkmultiphaseparams.cpp @@ -0,0 +1,75 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkMultiPhaseParams::registerParameters() +{ + Parameters::Register + ("Include the extrusion factor of the degrees of freedom into the VTK output files"); + Parameters::Register + ("Include the phase pressures in the VTK output files"); + Parameters::Register + ("Include the phase densities in the VTK output files"); + Parameters::Register + ("Include the phase saturations in the VTK output files"); + Parameters::Register + ("Include the phase mobilities in the VTK output files"); + Parameters::Register + ("Include the phase relative permeabilities in the VTK output files"); + Parameters::Register + ("Include component phase viscosities in the VTK output files"); + Parameters::Register + ("Include the average phase mass in the VTK output files"); + Parameters::Register + ("Include the porosity in the VTK output files"); + Parameters::Register + ("Include the intrinsic permeability in the VTK output files"); + Parameters::Register + ("Include in the filter velocities of the phases the VTK output files"); + Parameters::Register + ("Include the phase pressure potential gradients in the VTK output files"); +} + +void VtkMultiPhaseParams::read() +{ + extrusionFactorOutput_ = Parameters::Get(); + pressureOutput_ = Parameters::Get(); + densityOutput_ = Parameters::Get(); + saturationOutput_ = Parameters::Get(); + mobilityOutput_ = Parameters::Get(); + relativePermeabilityOutput_ = Parameters::Get(); + viscosityOutput_ = Parameters::Get(); + averageMolarMassOutput_ = Parameters::Get(); + porosityOutput_ = Parameters::Get(); + intrinsicPermeabilityOutput_ = Parameters::Get(); + velocityOutput_ = Parameters::Get(); + potentialGradientOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkmultiphaseparams.hpp b/opm/models/io/vtkmultiphaseparams.hpp new file mode 100644 index 00000000000..d9089e73e2d --- /dev/null +++ b/opm/models/io/vtkmultiphaseparams.hpp @@ -0,0 +1,77 @@ +// -*- 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::VtkMultiPhaseModule + */ +#ifndef OPM_VTK_MULTI_PHASE_PARAMS_HPP +#define OPM_VTK_MULTI_PHASE_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteExtrusionFactor { static constexpr bool value = false; }; +struct VtkWritePressures { static constexpr bool value = true; }; +struct VtkWriteDensities { static constexpr bool value = true; }; +struct VtkWriteSaturations { static constexpr bool value = true; }; +struct VtkWriteMobilities { static constexpr bool value = false; }; +struct VtkWriteRelativePermeabilities { static constexpr bool value = true; }; +struct VtkWriteViscosities { static constexpr bool value = false; }; +struct VtkWriteAverageMolarMasses { static constexpr bool value = false; }; +struct VtkWritePorosity { static constexpr bool value = true; }; +struct VtkWriteIntrinsicPermeabilities { static constexpr bool value = false; }; +struct VtkWritePotentialGradients { static constexpr bool value = false; }; +struct VtkWriteFilterVelocities { static constexpr bool value = false; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkMultiPhaseModule. + */ +struct VtkMultiPhaseParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool extrusionFactorOutput_; + bool pressureOutput_; + bool densityOutput_; + bool saturationOutput_; + bool mobilityOutput_; + bool relativePermeabilityOutput_; + bool viscosityOutput_; + bool averageMolarMassOutput_; + bool porosityOutput_; + bool intrinsicPermeabilityOutput_; + bool velocityOutput_; + bool potentialGradientOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_MULTI_PHASE_MODULE_HPP From 08b9c78ddd3c920c8d42f14cbc3d66c81120f153 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 24/33] vtkphasepresencemodule.hh: rename to vtkphasepresencemodule.hpp --- CMakeLists_files.cmake | 2 +- ...vtkphasepresencemodule.hh => vtkphasepresencemodule.hpp} | 6 +++--- opm/models/pvs/pvsproperties.hh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename opm/models/io/{vtkphasepresencemodule.hh => vtkphasepresencemodule.hpp} (96%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 71161dda28a..06469885978 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -680,7 +680,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkmultiphasemodule.hpp opm/models/io/vtkmultiphaseparams.hpp opm/models/io/vtkmultiwriter.hh - opm/models/io/vtkphasepresencemodule.hh + opm/models/io/vtkphasepresencemodule.hpp opm/models/io/vtkprimaryvarsmodule.hh opm/models/io/vtkptflashmodule.hh opm/models/io/vtkscalarfunction.hh diff --git a/opm/models/io/vtkphasepresencemodule.hh b/opm/models/io/vtkphasepresencemodule.hpp similarity index 96% rename from opm/models/io/vtkphasepresencemodule.hh rename to opm/models/io/vtkphasepresencemodule.hpp index c66429c4aa7..862ce9301aa 100644 --- a/opm/models/io/vtkphasepresencemodule.hh +++ b/opm/models/io/vtkphasepresencemodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkPhasePresenceModule */ -#ifndef EWOMS_VTK_PHASE_PRESENCE_MODULE_HH -#define EWOMS_VTK_PHASE_PRESENCE_MODULE_HH +#ifndef OPM_VTK_PHASE_PRESENCE_MODULE_HPP +#define OPM_VTK_PHASE_PRESENCE_MODULE_HPP #include @@ -133,4 +133,4 @@ class VtkPhasePresenceModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_PHASE_PRESENCE_MODULE_HPP diff --git a/opm/models/pvs/pvsproperties.hh b/opm/models/pvs/pvsproperties.hh index 2a857fbc707..0408de9fbed 100644 --- a/opm/models/pvs/pvsproperties.hh +++ b/opm/models/pvs/pvsproperties.hh @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include From adb6438d8499c0405f12b7784c0a79efb9da30c6 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 25/33] vtkphasepresencemodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkphasepresencemodule.hpp | 37 +++++++--------- opm/models/io/vtkphasepresenceparams.cpp | 43 +++++++++++++++++++ opm/models/io/vtkphasepresenceparams.hpp | 54 ++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 21 deletions(-) create mode 100644 opm/models/io/vtkphasepresenceparams.cpp create mode 100644 opm/models/io/vtkphasepresenceparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 06469885978..70dab1e52c8 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -72,6 +72,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkdiscretefractureparams.cpp opm/models/io/vtkenergyparams.cpp opm/models/io/vtkmultiphaseparams.cpp + opm/models/io/vtkphasepresenceparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -681,6 +682,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkmultiphaseparams.hpp opm/models/io/vtkmultiwriter.hh opm/models/io/vtkphasepresencemodule.hpp + opm/models/io/vtkphasepresenceparams.hpp opm/models/io/vtkprimaryvarsmodule.hh opm/models/io/vtkptflashmodule.hh opm/models/io/vtkscalarfunction.hh diff --git a/opm/models/io/vtkphasepresencemodule.hpp b/opm/models/io/vtkphasepresencemodule.hpp index 862ce9301aa..2de0e401067 100644 --- a/opm/models/io/vtkphasepresencemodule.hpp +++ b/opm/models/io/vtkphasepresencemodule.hpp @@ -30,18 +30,14 @@ #include #include +#include #include #include #include -namespace Opm::Parameters { - -struct VtkWritePhasePresence { static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { + /*! * \ingroup Vtk * @@ -66,16 +62,16 @@ class VtkPhasePresenceModule : public BaseOutputModule public: VtkPhasePresenceModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the Vtk output module. */ static void registerParameters() { - Parameters::Register - ("Include the phase presence pseudo primary " - "variable in the VTK output files"); + VtkPhasePresenceParams::registerParameters(); } /*! @@ -84,7 +80,9 @@ class VtkPhasePresenceModule : public BaseOutputModule */ void allocBuffers() { - if (phasePresenceOutput_()) this->resizeScalarBuffer_(phasePresence_); + if (params_.phasePresenceOutput_) { + this->resizeScalarBuffer_(phasePresence_); + } } /*! @@ -102,8 +100,9 @@ class VtkPhasePresenceModule : public BaseOutputModule int phasePresence = elemCtx.primaryVars(i, /*timeIdx=*/0).phasePresence(); unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); - if (phasePresenceOutput_()) + if (params_.phasePresenceOutput_) { phasePresence_[I] = phasePresence; + } } } @@ -112,23 +111,19 @@ class VtkPhasePresenceModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (phasePresenceOutput_()) + if (params_.phasePresenceOutput_) { this->commitScalarBuffer_(baseWriter, "phase presence", phasePresence_); + } } private: - static bool phasePresenceOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ScalarBuffer phasePresence_; + VtkPhasePresenceParams params_{}; + ScalarBuffer phasePresence_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkphasepresenceparams.cpp b/opm/models/io/vtkphasepresenceparams.cpp new file mode 100644 index 00000000000..7a8c6f6bcf9 --- /dev/null +++ b/opm/models/io/vtkphasepresenceparams.cpp @@ -0,0 +1,43 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkPhasePresenceParams::registerParameters() +{ + Parameters::Register + ("Include the phase presence pseudo primary " + "variable in the VTK output files"); +} + +void VtkPhasePresenceParams::read() +{ + phasePresenceOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkphasepresenceparams.hpp b/opm/models/io/vtkphasepresenceparams.hpp new file mode 100644 index 00000000000..2a66e0d3613 --- /dev/null +++ b/opm/models/io/vtkphasepresenceparams.hpp @@ -0,0 +1,54 @@ +// -*- 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::VtkPhasePresenceModule + */ +#ifndef OPM_VTK_PHASE_PRESENCE_PARAMS_HPP +#define OPM_VTK_PHASE_PRESENCE_PARAMS_HPP + +namespace Opm::Parameters { + +struct VtkWritePhasePresence { static constexpr bool value = false; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkPhasePresenceModule. + */ +struct VtkPhasePresenceParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool phasePresenceOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_PHASE_PRESENCE_PARAMS_HPP From be4026eccece00cb653217a86b3a39ea197c7eef Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 26/33] vtkprimaryvarsmodule.hh: rename to vtkprimaryvarsmodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/discretization/common/fvbasediscretization.hh | 3 +-- .../{vtkprimaryvarsmodule.hh => vtkprimaryvarsmodule.hpp} | 6 +++--- opm/simulators/flow/FlowUtils.cpp | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) rename opm/models/io/{vtkprimaryvarsmodule.hh => vtkprimaryvarsmodule.hpp} (97%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 70dab1e52c8..78e64803249 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -683,7 +683,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkmultiwriter.hh opm/models/io/vtkphasepresencemodule.hpp opm/models/io/vtkphasepresenceparams.hpp - opm/models/io/vtkprimaryvarsmodule.hh + opm/models/io/vtkprimaryvarsmodule.hpp opm/models/io/vtkptflashmodule.hh opm/models/io/vtkscalarfunction.hh opm/models/io/vtktemperaturemodule.hh diff --git a/opm/models/discretization/common/fvbasediscretization.hh b/opm/models/discretization/common/fvbasediscretization.hh index cd0d3b5e495..362f1078c6a 100644 --- a/opm/models/discretization/common/fvbasediscretization.hh +++ b/opm/models/discretization/common/fvbasediscretization.hh @@ -53,7 +53,7 @@ #include #include -#include +#include #include #include @@ -68,7 +68,6 @@ #include #include -#include #include #include #include diff --git a/opm/models/io/vtkprimaryvarsmodule.hh b/opm/models/io/vtkprimaryvarsmodule.hpp similarity index 97% rename from opm/models/io/vtkprimaryvarsmodule.hh rename to opm/models/io/vtkprimaryvarsmodule.hpp index 5bbbcdc3bf2..edd7e449099 100644 --- a/opm/models/io/vtkprimaryvarsmodule.hh +++ b/opm/models/io/vtkprimaryvarsmodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkPrimaryVarsModule */ -#ifndef EWOMS_VTK_PRIMARY_VARS_MODULE_HH -#define EWOMS_VTK_PRIMARY_VARS_MODULE_HH +#ifndef OPM_VTK_PRIMARY_VARS_MODULE_HPP +#define OPM_VTK_PRIMARY_VARS_MODULE_HPP #include @@ -174,4 +174,4 @@ class VtkPrimaryVarsModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_PRIMARY_VARS_MODULE_HPP diff --git a/opm/simulators/flow/FlowUtils.cpp b/opm/simulators/flow/FlowUtils.cpp index e16247ea711..4f2ac9684ab 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include From 023328bed22b18d4bdc3fb1808a692275ab81fec Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 27/33] vtkprimaryvarsparams: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtkprimaryvarsmodule.hpp | 72 ++++++++++---------------- opm/models/io/vtkprimaryvarsparams.cpp | 48 +++++++++++++++++ opm/models/io/vtkprimaryvarsparams.hpp | 58 +++++++++++++++++++++ 4 files changed, 136 insertions(+), 44 deletions(-) create mode 100644 opm/models/io/vtkprimaryvarsparams.cpp create mode 100644 opm/models/io/vtkprimaryvarsparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 78e64803249..4e79a8b383a 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -73,6 +73,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkenergyparams.cpp opm/models/io/vtkmultiphaseparams.cpp opm/models/io/vtkphasepresenceparams.cpp + opm/models/io/vtkprimaryvarsparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -684,6 +685,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkphasepresencemodule.hpp opm/models/io/vtkphasepresenceparams.hpp opm/models/io/vtkprimaryvarsmodule.hpp + opm/models/io/vtkprimaryvarsparams.hpp opm/models/io/vtkptflashmodule.hh opm/models/io/vtkscalarfunction.hh opm/models/io/vtktemperaturemodule.hh diff --git a/opm/models/io/vtkprimaryvarsmodule.hpp b/opm/models/io/vtkprimaryvarsmodule.hpp index edd7e449099..830e1300bc5 100644 --- a/opm/models/io/vtkprimaryvarsmodule.hpp +++ b/opm/models/io/vtkprimaryvarsmodule.hpp @@ -31,18 +31,11 @@ #include #include +#include #include #include -namespace Opm::Parameters { - -struct VtkWritePrimaryVars { static constexpr bool value = false; }; -struct VtkWriteProcessRank { static constexpr bool value = false; }; -struct VtkWriteDofIndex { static constexpr bool value = false; }; - -} // namespace Opm::Properties - namespace Opm { /*! @@ -70,19 +63,16 @@ class VtkPrimaryVarsModule : public BaseOutputModule public: VtkPrimaryVarsModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the Vtk output module. */ static void registerParameters() { - Parameters::Register - ("Include the primary variables into the VTK output files"); - Parameters::Register - ("Include the MPI process rank into the VTK output files"); - Parameters::Register - ("Include the index of the degrees of freedom into the VTK output files"); + VtkPrimaryVarsParams::registerParameters(); } /*! @@ -91,13 +81,16 @@ class VtkPrimaryVarsModule : public BaseOutputModule */ void allocBuffers() { - if (primaryVarsOutput_()) + if (params_.primaryVarsOutput_) { this->resizeEqBuffer_(primaryVars_); - if (processRankOutput_()) + } + if (params_.processRankOutput_) { this->resizeScalarBuffer_(processRank_, /*bufferType=*/ParentType::ElementBuffer); - if (dofIndexOutput_()) + } + if (params_.dofIndexOutput_) { this->resizeScalarBuffer_(dofIndex_); + } } /*! @@ -112,19 +105,22 @@ class VtkPrimaryVarsModule : public BaseOutputModule const auto& elementMapper = elemCtx.model().elementMapper(); unsigned elemIdx = static_cast(elementMapper.index(elemCtx.element())); - if (processRankOutput_() && !processRank_.empty()) + if (params_.processRankOutput_ && !processRank_.empty()) { processRank_[elemIdx] = static_cast(this->simulator_.gridView().comm().rank()); + } for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); const auto& priVars = elemCtx.primaryVars(i, /*timeIdx=*/0); - if (dofIndexOutput_()) + if (params_.dofIndexOutput_) { dofIndex_[I] = I; + } for (unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) { - if (primaryVarsOutput_() && !primaryVars_[eqIdx].empty()) + if (params_.primaryVarsOutput_ && !primaryVars_[eqIdx].empty()) { primaryVars_[eqIdx][I] = priVars[eqIdx]; + } } } } @@ -134,42 +130,30 @@ class VtkPrimaryVarsModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (primaryVarsOutput_()) + if (params_.primaryVarsOutput_) { this->commitPriVarsBuffer_(baseWriter, "PV_%s", primaryVars_); - if (processRankOutput_()) + } + if (params_.processRankOutput_) { this->commitScalarBuffer_(baseWriter, "process rank", processRank_, /*bufferType=*/ParentType::ElementBuffer); - if (dofIndexOutput_()) + } + if (params_.dofIndexOutput_) { this->commitScalarBuffer_(baseWriter, "DOF index", dofIndex_); + } } private: - static bool primaryVarsOutput_() - { - static bool val = Parameters::Get(); - return val; - } - static bool processRankOutput_() - { - static bool val = Parameters::Get(); - return val; - } - static bool dofIndexOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - EqBuffer primaryVars_; - ScalarBuffer processRank_; - ScalarBuffer dofIndex_; + VtkPrimaryVarsParams params_{}; + EqBuffer primaryVars_{}; + ScalarBuffer processRank_{}; + ScalarBuffer dofIndex_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkprimaryvarsparams.cpp b/opm/models/io/vtkprimaryvarsparams.cpp new file mode 100644 index 00000000000..f3ebfe36660 --- /dev/null +++ b/opm/models/io/vtkprimaryvarsparams.cpp @@ -0,0 +1,48 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkPrimaryVarsParams::registerParameters() +{ + Parameters::Register + ("Include the primary variables into the VTK output files"); + Parameters::Register + ("Include the MPI process rank into the VTK output files"); + Parameters::Register + ("Include the index of the degrees of freedom into the VTK output files"); +} + +void VtkPrimaryVarsParams::read() +{ + primaryVarsOutput_ = Parameters::Get(); + processRankOutput_ = Parameters::Get(); + dofIndexOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkprimaryvarsparams.hpp b/opm/models/io/vtkprimaryvarsparams.hpp new file mode 100644 index 00000000000..94519ec19b6 --- /dev/null +++ b/opm/models/io/vtkprimaryvarsparams.hpp @@ -0,0 +1,58 @@ +// -*- 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::VtkPrimaryVarsModule + */ +#ifndef OPM_VTK_PRIMARY_VARS_PARAMS_HPP +#define OPM_VTK_PRIMARY_VARS_PARAMS_HPP + +namespace Opm::Parameters { + +struct VtkWritePrimaryVars { static constexpr bool value = false; }; +struct VtkWriteProcessRank { static constexpr bool value = false; }; +struct VtkWriteDofIndex { static constexpr bool value = false; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkPrimaryPhaseModule. + */ +struct VtkPrimaryVarsParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool primaryVarsOutput_; + bool processRankOutput_; + bool dofIndexOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_PRIMARY_VARS_PARAMS_HPP From 29f2a356941699aedc0b57dd87fd6adce659cb62 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 28/33] vtkptflashmodule.hh: rename to vtkptflashmodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/io/{vtkptflashmodule.hh => vtkptflashmodule.hpp} | 6 +++--- opm/models/ptflash/flashmodel.hh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename opm/models/io/{vtkptflashmodule.hh => vtkptflashmodule.hpp} (98%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 4e79a8b383a..ebfcde1a06c 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -686,7 +686,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkphasepresenceparams.hpp opm/models/io/vtkprimaryvarsmodule.hpp opm/models/io/vtkprimaryvarsparams.hpp - opm/models/io/vtkptflashmodule.hh + opm/models/io/vtkptflashmodule.hpp opm/models/io/vtkscalarfunction.hh opm/models/io/vtktemperaturemodule.hh opm/models/io/vtktensorfunction.hh diff --git a/opm/models/io/vtkptflashmodule.hh b/opm/models/io/vtkptflashmodule.hpp similarity index 98% rename from opm/models/io/vtkptflashmodule.hh rename to opm/models/io/vtkptflashmodule.hpp index a7509f8dec1..2581186b1db 100644 --- a/opm/models/io/vtkptflashmodule.hh +++ b/opm/models/io/vtkptflashmodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkPTFlashModule */ -#ifndef OPM_VTK_PTFLASH_MODULE_HH -#define OPM_VTK_PTFLASH_MODULE_HH +#ifndef OPM_VTK_PTFLASH_MODULE_HPP +#define OPM_VTK_PTFLASH_MODULE_HPP #include @@ -166,4 +166,4 @@ class VtkPTFlashModule: public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_PTFLASH_MODULE_HPP diff --git a/opm/models/ptflash/flashmodel.hh b/opm/models/ptflash/flashmodel.hh index ce7efcec4b8..83644c11379 100644 --- a/opm/models/ptflash/flashmodel.hh +++ b/opm/models/ptflash/flashmodel.hh @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include From 4eb70830cff892d52f41f756e0c13f803b3a4279 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 29/33] vtkptflashmodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 ++ opm/models/io/vtkptflashmodule.hpp | 55 +++++++++++----------------- opm/models/io/vtkptflashparams.cpp | 45 +++++++++++++++++++++++ opm/models/io/vtkptflashparams.hpp | 57 ++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 34 deletions(-) create mode 100644 opm/models/io/vtkptflashparams.cpp create mode 100644 opm/models/io/vtkptflashparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index ebfcde1a06c..efb48cac883 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -74,6 +74,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkmultiphaseparams.cpp opm/models/io/vtkphasepresenceparams.cpp opm/models/io/vtkprimaryvarsparams.cpp + opm/models/io/vtkptflashparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -687,6 +688,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkprimaryvarsmodule.hpp opm/models/io/vtkprimaryvarsparams.hpp opm/models/io/vtkptflashmodule.hpp + opm/models/io/vtkptflashparams.hpp opm/models/io/vtkscalarfunction.hh opm/models/io/vtktemperaturemodule.hh opm/models/io/vtktensorfunction.hh diff --git a/opm/models/io/vtkptflashmodule.hpp b/opm/models/io/vtkptflashmodule.hpp index 2581186b1db..4b531afda94 100644 --- a/opm/models/io/vtkptflashmodule.hpp +++ b/opm/models/io/vtkptflashmodule.hpp @@ -33,18 +33,11 @@ #include #include +#include #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteLiquidMoleFractions { static constexpr bool value = false; }; -struct VtkWriteEquilibriumConstants { static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -79,17 +72,16 @@ class VtkPTFlashModule: public BaseOutputModule public: explicit VtkPTFlashModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the Vtk output module. */ static void registerParameters() { - Parameters::Register - ("Include liquid mole fractions (L) in the VTK output files"); - Parameters::Register - ("Include equilibrium constants (K) in the VTK output files"); + VtkPtFlashParams::registerParameters(); } /*! @@ -98,10 +90,12 @@ class VtkPTFlashModule: public BaseOutputModule */ void allocBuffers() { - if (LOutput_()) + if (params_.LOutput_) { this->resizeScalarBuffer_(L_); - if (equilConstOutput_()) + } + if (params_.equilConstOutput_) { this->resizeComponentBuffer_(K_); + } } /*! @@ -121,12 +115,14 @@ class VtkPTFlashModule: public BaseOutputModule const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0); const auto& fs = intQuants.fluidState(); - if (LOutput_()) + if (params_.LOutput_) { L_[I] = Toolbox::value(fs.L()); + } for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { - if (equilConstOutput_()) + if (params_.equilConstOutput_) { K_[compIdx][I] = Toolbox::value(fs.K(compIdx)); + } } } } @@ -136,32 +132,23 @@ class VtkPTFlashModule: public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - auto *vtkWriter = dynamic_cast(&baseWriter); + auto* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (equilConstOutput_()) + if (params_.equilConstOutput_) { this->commitComponentBuffer_(baseWriter, "K^%s", K_); - if (LOutput_()) + } + if (params_.LOutput_) { this->commitScalarBuffer_(baseWriter, "L", L_); + } } private: - static bool LOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool equilConstOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ComponentBuffer K_; - ScalarBuffer L_; + VtkPtFlashParams params_{}; + ComponentBuffer K_{}; + ScalarBuffer L_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkptflashparams.cpp b/opm/models/io/vtkptflashparams.cpp new file mode 100644 index 00000000000..38ef51f044d --- /dev/null +++ b/opm/models/io/vtkptflashparams.cpp @@ -0,0 +1,45 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkPtFlashParams::registerParameters() +{ + Parameters::Register + ("Include liquid mole fractions (L) in the VTK output files"); + Parameters::Register + ("Include equilibrium constants (K) in the VTK output files"); +} + +void VtkPtFlashParams::read() +{ + LOutput_ = Parameters::Get(); + equilConstOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkptflashparams.hpp b/opm/models/io/vtkptflashparams.hpp new file mode 100644 index 00000000000..96c587ad696 --- /dev/null +++ b/opm/models/io/vtkptflashparams.hpp @@ -0,0 +1,57 @@ +// -*- 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::VtkPTFlashModule + */ +#ifndef OPM_VTK_PTFLASH_PARAMS_HPP +#define OPM_VTK_PTFLASH_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteLiquidMoleFractions { static constexpr bool value = false; }; +struct VtkWriteEquilibriumConstants { static constexpr bool value = false; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkPtFlashModule. + */ +struct VtkPtFlashParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool LOutput_; + bool equilConstOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_PTFLASH_MODULE_HPP From e093101d1cd0aebe8aa39dc26d58e834a5b42eac Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 30/33] vtktemperaturemodule.hh: rename to vtktemperaturemodule.hpp --- CMakeLists_files.cmake | 2 +- opm/models/common/multiphasebasemodel.hh | 2 +- .../{vtktemperaturemodule.hh => vtktemperaturemodule.hpp} | 6 +++--- opm/simulators/flow/FlowUtils.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename opm/models/io/{vtktemperaturemodule.hh => vtktemperaturemodule.hpp} (97%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index efb48cac883..ca85884accb 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -690,7 +690,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkptflashmodule.hpp opm/models/io/vtkptflashparams.hpp opm/models/io/vtkscalarfunction.hh - opm/models/io/vtktemperaturemodule.hh + opm/models/io/vtktemperaturemodule.hpp opm/models/io/vtktensorfunction.hh opm/models/io/vtkvectorfunction.hh opm/models/ncp/ncpboundaryratevector.hh diff --git a/opm/models/common/multiphasebasemodel.hh b/opm/models/common/multiphasebasemodel.hh index e2bb8cb5f0f..885e96d1fd5 100644 --- a/opm/models/common/multiphasebasemodel.hh +++ b/opm/models/common/multiphasebasemodel.hh @@ -45,7 +45,7 @@ #include #include -#include +#include namespace Opm { template diff --git a/opm/models/io/vtktemperaturemodule.hh b/opm/models/io/vtktemperaturemodule.hpp similarity index 97% rename from opm/models/io/vtktemperaturemodule.hh rename to opm/models/io/vtktemperaturemodule.hpp index 0cdd62c2763..2146c08bb0e 100644 --- a/opm/models/io/vtktemperaturemodule.hh +++ b/opm/models/io/vtktemperaturemodule.hpp @@ -24,8 +24,8 @@ * \file * \copydoc Opm::VtkTemperatureModule */ -#ifndef EWOMS_VTK_TEMPERATURE_MODULE_HH -#define EWOMS_VTK_TEMPERATURE_MODULE_HH +#ifndef OPM_VTK_TEMPERATURE_MODULE_HPP +#define OPM_VTK_TEMPERATURE_MODULE_HPP #include @@ -139,4 +139,4 @@ class VtkTemperatureModule : public BaseOutputModule } // namespace Opm -#endif +#endif // OPM_VTK_TEMPERATURE_MODULE_HPP diff --git a/opm/simulators/flow/FlowUtils.cpp b/opm/simulators/flow/FlowUtils.cpp index 4f2ac9684ab..ec8cb09190d 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include From e0af58a7cf2e4605876ce08d949236ec566a860e Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 31/33] vtktemperaturemodule: move parameters to dedicated struct with a translation unit --- CMakeLists_files.cmake | 2 + opm/models/io/vtktemperaturemodule.hpp | 36 +++++++---------- opm/models/io/vtktemperatureparams.cpp | 42 ++++++++++++++++++++ opm/models/io/vtktemperatureparams.hpp | 55 ++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 21 deletions(-) create mode 100644 opm/models/io/vtktemperatureparams.cpp create mode 100644 opm/models/io/vtktemperatureparams.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index ca85884accb..f53225eb39f 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -75,6 +75,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkphasepresenceparams.cpp opm/models/io/vtkprimaryvarsparams.cpp opm/models/io/vtkptflashparams.cpp + opm/models/io/vtktemperatureparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -691,6 +692,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkptflashparams.hpp opm/models/io/vtkscalarfunction.hh opm/models/io/vtktemperaturemodule.hpp + opm/models/io/vtktemperatureparams.hpp opm/models/io/vtktensorfunction.hh opm/models/io/vtkvectorfunction.hh opm/models/ncp/ncpboundaryratevector.hh diff --git a/opm/models/io/vtktemperaturemodule.hpp b/opm/models/io/vtktemperaturemodule.hpp index 2146c08bb0e..34242a39ea4 100644 --- a/opm/models/io/vtktemperaturemodule.hpp +++ b/opm/models/io/vtktemperaturemodule.hpp @@ -33,17 +33,11 @@ #include #include +#include #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteTemperature { static constexpr bool value = true; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -71,15 +65,16 @@ class VtkTemperatureModule : public BaseOutputModule public: VtkTemperatureModule(const Simulator& simulator) : ParentType(simulator) - {} + { + params_.read(); + } /*! * \brief Register all run-time parameters for the Vtk output module. */ static void registerParameters() { - Parameters::Register - ("Include the temperature in the VTK output files"); + VtkTemperatureParams::registerParameters(); } /*! @@ -88,7 +83,9 @@ class VtkTemperatureModule : public BaseOutputModule */ void allocBuffers() { - if (temperatureOutput_()) this->resizeScalarBuffer_(temperature_); + if (params_.temperatureOutput_) { + this->resizeScalarBuffer_(temperature_); + } } /*! @@ -108,8 +105,9 @@ class VtkTemperatureModule : public BaseOutputModule const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0); const auto& fs = intQuants.fluidState(); - if (temperatureOutput_()) + if (params_.temperatureOutput_) { temperature_[I] = Toolbox::value(fs.temperature(/*phaseIdx=*/0)); + } } } @@ -118,23 +116,19 @@ class VtkTemperatureModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (temperatureOutput_()) + if (params_.temperatureOutput_) { this->commitScalarBuffer_(baseWriter, "temperature", temperature_); + } } private: - static bool temperatureOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ScalarBuffer temperature_; + VtkTemperatureParams params_{}; + ScalarBuffer temperature_{}; }; } // namespace Opm diff --git a/opm/models/io/vtktemperatureparams.cpp b/opm/models/io/vtktemperatureparams.cpp new file mode 100644 index 00000000000..62be2a67915 --- /dev/null +++ b/opm/models/io/vtktemperatureparams.cpp @@ -0,0 +1,42 @@ +// -*- 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 + +#include + +namespace Opm { + +void VtkTemperatureParams::registerParameters() +{ + Parameters::Register + ("Include the temperature in the VTK output files"); +} + +void VtkTemperatureParams::read() +{ + temperatureOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtktemperatureparams.hpp b/opm/models/io/vtktemperatureparams.hpp new file mode 100644 index 00000000000..3a9a138b2e1 --- /dev/null +++ b/opm/models/io/vtktemperatureparams.hpp @@ -0,0 +1,55 @@ +// -*- 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::VtkTemperatureModule + */ +#ifndef OPM_VTK_TEMPERATURE_PARAMS_HPP +#define OPM_VTK_TEMPERATURE_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteTemperature { static constexpr bool value = true; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkTemperatureModule. + */ +struct VtkTemperatureParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool temperatureOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_TEMPERATURE_PARAMS_HPP From 1b19fa02f4d5c8afe5d38b7fc3f469fcc493c8af Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 32/33] newtonmethodparameters.hh: rename to newtonmethodparams.hpp --- CMakeLists_files.cmake | 2 +- examples/problems/reservoirproblem.hh | 2 +- opm/models/nonlinear/newtonmethod.hh | 2 +- .../{newtonmethodparameters.hh => newtonmethodparams.hpp} | 6 +++--- opm/simulators/flow/FlowProblemParameters.cpp | 2 +- opm/simulators/flow/FlowUtils.cpp | 2 +- opm/simulators/flow/NonlinearSolver.hpp | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) rename opm/models/nonlinear/{newtonmethodparameters.hh => newtonmethodparams.hpp} (95%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index f53225eb39f..967c98f76a1 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -706,7 +706,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/ncp/ncpproperties.hh opm/models/ncp/ncpratevector.hh opm/models/nonlinear/newtonmethod.hh - opm/models/nonlinear/newtonmethodparameters.hh + opm/models/nonlinear/newtonmethodparams.hpp opm/models/nonlinear/newtonmethodproperties.hh opm/models/nonlinear/nullconvergencewriter.hh opm/models/parallel/gridcommhandles.hh diff --git a/examples/problems/reservoirproblem.hh b/examples/problems/reservoirproblem.hh index 5180093d42a..0f5fd9537c1 100644 --- a/examples/problems/reservoirproblem.hh +++ b/examples/problems/reservoirproblem.hh @@ -51,7 +51,7 @@ #include #include -#include +#include #include diff --git a/opm/models/nonlinear/newtonmethod.hh b/opm/models/nonlinear/newtonmethod.hh index 744d90349f8..588d23da8c2 100644 --- a/opm/models/nonlinear/newtonmethod.hh +++ b/opm/models/nonlinear/newtonmethod.hh @@ -37,7 +37,7 @@ #include -#include +#include #include #include diff --git a/opm/models/nonlinear/newtonmethodparameters.hh b/opm/models/nonlinear/newtonmethodparams.hpp similarity index 95% rename from opm/models/nonlinear/newtonmethodparameters.hh rename to opm/models/nonlinear/newtonmethodparams.hpp index 72afa9ecee4..3b1b4710941 100644 --- a/opm/models/nonlinear/newtonmethodparameters.hh +++ b/opm/models/nonlinear/newtonmethodparams.hpp @@ -20,8 +20,8 @@ module for the precise wording of the license and the list of copyright holders. */ -#ifndef EWOMS_NEWTON_METHOD_PARAMETERS_HH -#define EWOMS_NEWTON_METHOD_PARAMETERS_HH +#ifndef OPM_NEWTON_METHOD_PARAMS_HPP +#define OPM_NEWTON_METHOD_PARAMS_HPP namespace Opm::Parameters { @@ -61,4 +61,4 @@ struct NewtonWriteConvergence { static constexpr bool value = false; }; } // end namespace Opm::Parameters -#endif +#endif // OPM_NEWTON_METHOD_PARAMS_HPP diff --git a/opm/simulators/flow/FlowProblemParameters.cpp b/opm/simulators/flow/FlowProblemParameters.cpp index a5a11008bf0..92c1e9a8828 100644 --- a/opm/simulators/flow/FlowProblemParameters.cpp +++ b/opm/simulators/flow/FlowProblemParameters.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/opm/simulators/flow/FlowUtils.cpp b/opm/simulators/flow/FlowUtils.cpp index ec8cb09190d..ab3dcc7ec5e 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include diff --git a/opm/simulators/flow/NonlinearSolver.hpp b/opm/simulators/flow/NonlinearSolver.hpp index a3235cf51b5..b05ea0a98c8 100644 --- a/opm/simulators/flow/NonlinearSolver.hpp +++ b/opm/simulators/flow/NonlinearSolver.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include From 3ee3dc2b5f605bd3244e070f9de693a37628a432 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 16 Sep 2024 08:43:09 +0200 Subject: [PATCH 33/33] newtonmethod: move parameters to dedicated struct with a translation unit --- CMakeLists.txt | 3 +- CMakeLists_files.cmake | 1 + flowexperimental/FlowExpNewtonMethod.hpp | 6 +- opm/models/nonlinear/newtonmethod.hh | 53 ++++---------- opm/models/nonlinear/newtonmethodparams.cpp | 77 +++++++++++++++++++++ opm/models/nonlinear/newtonmethodparams.hpp | 24 +++++++ 6 files changed, 122 insertions(+), 42 deletions(-) create mode 100644 opm/models/nonlinear/newtonmethodparams.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 40b6d4d1557..89f0cca41a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -321,7 +321,8 @@ macro (sources_hook) get_target_property(qm_defs QuadMath::QuadMath INTERFACE_COMPILE_DEFINITIONS) list(APPEND qm_defs HAVE_QUAD=1) get_target_property(qm_options QuadMath::QuadMath INTERFACE_COMPILE_OPTIONS) - set_source_files_properties(opm/models/utils/parametersystem.cpp + set_source_files_properties(opm/models/nonlinear/newtonmethodparams.cpp + opm/models/utils/parametersystem.cpp opm/models/utils/simulatorutils.cpp PROPERTIES COMPILE_DEFINITIONS "${qm_defs}" COMPILE_OPTIONS "${qm_options}") diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 967c98f76a1..fe4e8ec740c 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -77,6 +77,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkptflashparams.cpp opm/models/io/vtktemperatureparams.cpp opm/models/io/restart.cpp + opm/models/nonlinear/newtonmethodparams.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp opm/models/parallel/threadmanager.cpp diff --git a/flowexperimental/FlowExpNewtonMethod.hpp b/flowexperimental/FlowExpNewtonMethod.hpp index 53b5996224e..831b340b59f 100644 --- a/flowexperimental/FlowExpNewtonMethod.hpp +++ b/flowexperimental/FlowExpNewtonMethod.hpp @@ -149,7 +149,7 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod { const auto& constraintsMap = this->model().linearizer().constraintsMap(); this->lastError_ = this->error_; - Scalar newtonMaxError = Parameters::Get>(); + Scalar newtonMaxError = this->params_.maxError_; // calculate the error as the maximum weighted tolerance of // the solution's residual @@ -198,7 +198,7 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod this->error_ = max(std::abs(tmpError), this->error_); - if (std::abs(tmpError) > this->tolerance_) { + if (std::abs(tmpError) > this->params_.tolerance_) { cnvViolated = true; } @@ -231,7 +231,7 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod Scalar y = Parameters::Get>(); sumTolerance_ = x*std::pow(sumPv, y); - this->endIterMsg() << " (max: " << this->tolerance_ + this->endIterMsg() << " (max: " << this->params_.tolerance_ << ", violated for " << errorPvFraction_ * 100 << "% of the pore volume), aggegate error: " << errorSum_ << " (max: " << sumTolerance_ << ")"; diff --git a/opm/models/nonlinear/newtonmethod.hh b/opm/models/nonlinear/newtonmethod.hh index 588d23da8c2..aefaea00b56 100644 --- a/opm/models/nonlinear/newtonmethod.hh +++ b/opm/models/nonlinear/newtonmethod.hh @@ -118,9 +118,9 @@ public: { lastError_ = 1e100; error_ = 1e100; - tolerance_ = Parameters::Get>(); numIterations_ = 0; + params_.read(); } /*! @@ -129,23 +129,7 @@ public: static void registerParameters() { LinearSolverBackend::registerParameters(); - - Parameters::Register - ("Specify whether the Newton method should inform " - "the user about its progress or not"); - Parameters::Register - ("Write the convergence behaviour of the Newton " - "method to a VTK file"); - Parameters::Register - ("The 'optimum' number of Newton iterations per time step"); - Parameters::Register - ("The maximum number of Newton iterations per time step"); - Parameters::Register> - ("The maximum raw error tolerated by the Newton" - "method for considering a solution to be converged"); - Parameters::Register> - ("The maximum error tolerated by the Newton " - "method to which does not cause an abort"); + NewtonMethodParams::registerParameters(); } /*! @@ -210,14 +194,14 @@ public: * be converged. */ Scalar tolerance() const - { return tolerance_; } + { return params_.tolerance_; } /*! * \brief Set the current tolerance at which the Newton method considers itself to * be converged. */ void setTolerance(Scalar value) - { tolerance_ = value; } + { params_.tolerance_ = value; } /*! * \brief Run the Newton method. @@ -451,14 +435,14 @@ public: // conservative when increasing it. the rationale is // that we want to avoid failing in the next time // integration which would be quite expensive - if (numIterations_ > targetIterations_()) { - Scalar percent = Scalar(numIterations_ - targetIterations_())/targetIterations_(); + if (numIterations_ > params_.targetIterations_) { + Scalar percent = Scalar(numIterations_ - params_.targetIterations_) / params_.targetIterations_; Scalar nextDt = std::max(problem().minTimeStepSize(), oldDt / (Scalar{1.0} + percent)); return nextDt; } - Scalar percent = Scalar(targetIterations_() - numIterations_)/targetIterations_(); + Scalar percent = Scalar(params_.targetIterations_ - numIterations_) / params_.targetIterations_; Scalar nextDt = std::max(problem().minTimeStepSize(), oldDt*(Scalar{1.0} + percent / Scalar{1.2})); return nextDt; @@ -508,7 +492,7 @@ protected: */ bool verbose_() const { - return Parameters::Get() && (comm_.rank() == 0); + return params_.verbose_ && (comm_.rank() == 0); } /*! @@ -521,7 +505,7 @@ protected: { numIterations_ = 0; - if (Parameters::Get()) { + if (params_.writeConvergence_) { convergenceWriter_.beginTimeStep(); } } @@ -574,7 +558,7 @@ protected: { const auto& constraintsMap = model().linearizer().constraintsMap(); lastError_ = error_; - Scalar newtonMaxError = Parameters::Get>(); + Scalar newtonMaxError = params_.maxError_; // calculate the error as the maximum weighted tolerance of // the solution's residual @@ -739,7 +723,7 @@ protected: void writeConvergence_(const SolutionVector& currentSolution, const GlobalEqVector& solutionUpdate) { - if (Parameters::Get()) { + if (params_.writeConvergence_) { convergenceWriter_.beginIteration(); convergenceWriter_.writeFields(currentSolution, solutionUpdate); convergenceWriter_.endIteration(); @@ -794,7 +778,7 @@ protected: // do more iterations return false; } - else if (asImp_().numIterations() >= asImp_().maxIterations_()) { + else if (asImp_().numIterations() >= params_.maxIterations_) { // we have exceeded the allowed number of steps. If the // error was reduced by a factor of at least 4, // in the last iterations we proceed even if we are above @@ -811,7 +795,7 @@ protected: */ void end_() { - if (Parameters::Get()) { + if (params_.writeConvergence_) { convergenceWriter_.endTimeStep(); } } @@ -822,7 +806,7 @@ protected: * This method is called _after_ end_() */ void failed_() - { numIterations_ = targetIterations_() * 2; } + { numIterations_ = params_.targetIterations_ * 2; } /*! * \brief Called if the Newton method was successful. @@ -832,13 +816,6 @@ protected: void succeeded_() {} - // optimal number of iterations we want to achieve - int targetIterations_() const - { return Parameters::Get(); } - // maximum number of iterations we do before giving up - int maxIterations_() const - { return Parameters::Get(); } - static bool enableConstraints_() { return getPropValue(); } @@ -853,7 +830,7 @@ protected: Scalar error_; Scalar lastError_; - Scalar tolerance_; + NewtonMethodParams params_; // actual number of iterations done so far int numIterations_; diff --git a/opm/models/nonlinear/newtonmethodparams.cpp b/opm/models/nonlinear/newtonmethodparams.cpp new file mode 100644 index 00000000000..9a3eea5df60 --- /dev/null +++ b/opm/models/nonlinear/newtonmethodparams.cpp @@ -0,0 +1,77 @@ +// -*- 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 + +#include + +#if HAVE_QUAD +#include +#endif + +namespace Opm { + +template +void NewtonMethodParams::registerParameters() +{ + Parameters::Register + ("Specify whether the Newton method should inform " + "the user about its progress or not"); + Parameters::Register + ("Write the convergence behaviour of the Newton " + "method to a VTK file"); + Parameters::Register + ("The 'optimum' number of Newton iterations per time step"); + Parameters::Register + ("The maximum number of Newton iterations per time step"); + Parameters::Register> + ("The maximum raw error tolerated by the Newton" + "method for considering a solution to be converged"); + Parameters::Register> + ("The maximum error tolerated by the Newton " + "method to which does not cause an abort"); +} + +template +void NewtonMethodParams::read() +{ + verbose_ = Parameters::Get(); + writeConvergence_ = Parameters::Get(); + targetIterations_ = Parameters::Get(); + maxIterations_ = Parameters::Get(); + tolerance_ = Parameters::Get>(); + maxError_ = Parameters::Get>(); +} + +template struct NewtonMethodParams; + +#if FLOW_INSTANTIATE_FLOAT +template struct NewtonMethodParams; +#endif + +#if HAVE_QUAD +template struct NewtonMethodParams; +#endif + +} // namespace Opm diff --git a/opm/models/nonlinear/newtonmethodparams.hpp b/opm/models/nonlinear/newtonmethodparams.hpp index 3b1b4710941..b49d176285d 100644 --- a/opm/models/nonlinear/newtonmethodparams.hpp +++ b/opm/models/nonlinear/newtonmethodparams.hpp @@ -61,4 +61,28 @@ struct NewtonWriteConvergence { static constexpr bool value = false; }; } // end namespace Opm::Parameters +namespace Opm { + +/*! + * \brief Struct holding the parameters for NewtonMethod. + */ +template +struct NewtonMethodParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool verbose_; + bool writeConvergence_; + int targetIterations_; //!< Optimal number of iterations we want to achieve + int maxIterations_; //!< Maximum number of iterations we do before giving up + Scalar tolerance_; + Scalar maxError_; +}; + +} // namespace Opm + #endif // OPM_NEWTON_METHOD_PARAMS_HPP