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 12f7ff18cfa..fe4e8ec740c 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -59,9 +59,25 @@ list (APPEND MAIN_SOURCE_FILES opm/models/blackoil/blackoilextboparams.cpp opm/models/blackoil/blackoilfoamparams.cpp opm/models/blackoil/blackoilmicpparams.cpp + opm/models/blackoil/blackoilnewtonmethodparams.cpp opm/models/blackoil/blackoilpolymerparams.cpp 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/vtkblackoilsolventparams.cpp + opm/models/io/vtkcompositionparams.cpp + opm/models/io/vtkdiffusionparams.cpp + opm/models/io/vtkdiscretefractureparams.cpp + opm/models/io/vtkenergyparams.cpp + opm/models/io/vtkmultiphaseparams.cpp + 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/nonlinear/newtonmethodparams.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp opm/models/parallel/threadmanager.cpp @@ -553,8 +569,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/blackoilnewtonmethodparams.hpp opm/models/blackoil/blackoilonephaseindices.hh opm/models/blackoil/blackoilpolymermodules.hh opm/models/blackoil/blackoilpolymerparams.hpp @@ -648,22 +664,36 @@ 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/vtkblackoilmicpmodule.hh - opm/models/io/vtkblackoilmodule.hh - opm/models/io/vtkblackoilpolymermodule.hh - opm/models/io/vtkblackoilsolventmodule.hh - opm/models/io/vtkcompositionmodule.hh - opm/models/io/vtkdiffusionmodule.hh - opm/models/io/vtkdiscretefracturemodule.hh - opm/models/io/vtkenergymodule.hh - opm/models/io/vtkmultiphasemodule.hh + 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.hpp + opm/models/io/vtkblackoilpolymerparams.hpp + opm/models/io/vtkblackoilsolventmodule.hpp + opm/models/io/vtkblackoilsolventparams.hpp + opm/models/io/vtkcompositionmodule.hpp + opm/models/io/vtkcompositionparams.hpp + opm/models/io/vtkdiffusionmodule.hpp + opm/models/io/vtkdiffusionparams.hpp + opm/models/io/vtkdiscretefracturemodule.hpp + opm/models/io/vtkdiscretefractureparams.hpp + 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 - opm/models/io/vtkptflashmodule.hh + opm/models/io/vtkphasepresencemodule.hpp + opm/models/io/vtkphasepresenceparams.hpp + 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/vtktemperaturemodule.hpp + opm/models/io/vtktemperatureparams.hpp opm/models/io/vtktensorfunction.hh opm/models/io/vtkvectorfunction.hh opm/models/ncp/ncpboundaryratevector.hh @@ -677,7 +707,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/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/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/flowexperimental/FlowExpNewtonMethod.hpp b/flowexperimental/FlowExpNewtonMethod.hpp index 6e9753d7533..831b340b59f 100644 --- a/flowexperimental/FlowExpNewtonMethod.hpp +++ b/flowexperimental/FlowExpNewtonMethod.hpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include namespace Opm::Parameters { @@ -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/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/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/blackoil/blackoilmodel.hh b/opm/models/blackoil/blackoilmodel.hh index 36252fc57a9..c469ebcabf7 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 @@ -55,9 +55,9 @@ #include -#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 78% rename from opm/models/blackoil/blackoilnewtonmethod.hh rename to opm/models/blackoil/blackoilnewtonmethod.hpp index b160dc62f1f..125aedab0f4 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 { @@ -72,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(); } /*! @@ -92,40 +83,16 @@ 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() { ParentType::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 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(); } /*! @@ -193,8 +160,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 @@ -285,17 +254,20 @@ class BlackOilNewtonMethod : public GetPropType dpMaxRel_*currentValue[pvIdx]) - delta = signum(delta)*dpMaxRel_*currentValue[pvIdx]; + if (std::abs(delta) > bparams_.dpMaxRel_ * currentValue[pvIdx]) { + delta = signum(delta) * bparams_.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 +275,9 @@ class BlackOilNewtonMethod : public GetPropType currentValue[Indices::compositionSwitchIdx]) @@ -336,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 && @@ -351,44 +324,52 @@ 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(); } @@ -427,26 +423,15 @@ 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 -#endif +#endif // OPM_BLACK_OIL_NEWTHON_METHOD_HPP diff --git a/opm/models/blackoil/blackoilnewtonmethodparams.cpp b/opm/models/blackoil/blackoilnewtonmethodparams.cpp new file mode 100644 index 00000000000..7e1fa1a5a90 --- /dev/null +++ b/opm/models/blackoil/blackoilnewtonmethodparams.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.hh b/opm/models/blackoil/blackoilnewtonmethodparams.hpp similarity index 77% rename from opm/models/blackoil/blackoilnewtonmethodparameters.hh rename to opm/models/blackoil/blackoilnewtonmethodparams.hpp index 6897083341f..7289e98a40a 100644 --- a/opm/models/blackoil/blackoilnewtonmethodparameters.hh +++ b/opm/models/blackoil/blackoilnewtonmethodparams.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 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/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/common/multiphasebasemodel.hh b/opm/models/common/multiphasebasemodel.hh index 1d251ac7396..885e96d1fd5 100644 --- a/opm/models/common/multiphasebasemodel.hh +++ b/opm/models/common/multiphasebasemodel.hh @@ -44,8 +44,8 @@ #include -#include -#include +#include +#include namespace Opm { template 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/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/flash/flashmodel.hh b/opm/models/flash/flashmodel.hh index 070bae6136c..e21b7957646 100644 --- a/opm/models/flash/flashmodel.hh +++ b/opm/models/flash/flashmodel.hh @@ -48,9 +48,9 @@ #include #include -#include -#include -#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/vtkblackoilenergymodule.hh b/opm/models/io/vtkblackoilenergymodule.hh deleted file mode 100644 index 1fcfb516a5b..00000000000 --- a/opm/models/io/vtkblackoilenergymodule.hh +++ /dev/null @@ -1,226 +0,0 @@ -// -*- 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 EWOMS_VTK_BLACK_OIL_ENERGY_MODULE_HH -#define EWOMS_VTK_BLACK_OIL_ENERGY_MODULE_HH - -#include - -#include - -#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 { -/*! - * \ingroup Vtk - * - * \brief VTK output module for the black oil model's energy related quantities. - */ -template -class VtkBlackOilEnergyModule : public BaseOutputModule -{ - using ParentType = BaseOutputModule; - - using Simulator = GetPropType; - using GridView = GetPropType; - using Scalar = GetPropType; - using Evaluation = GetPropType; - using ElementContext = GetPropType; - using FluidSystem = GetPropType; - - static const int vtkFormat = getPropValue(); - using VtkMultiWriter = ::Opm::VtkMultiWriter; - - enum { enableEnergy = getPropValue() }; - enum { numPhases = getPropValue() }; - - using ScalarBuffer = typename ParentType::ScalarBuffer; - using PhaseBuffer = typename ParentType::PhaseBuffer; - -public: - VtkBlackOilEnergyModule(const Simulator& simulator) - : ParentType(simulator) - { } - - /*! - * \brief Register all run-time parameters for the multi-phase VTK output - * module. - */ - 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"); - } - - /*! - * \brief Allocate memory for the scalar fields we would like to - * write to the VTK file. - */ - void allocBuffers() - { - 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_); - } - - /*! - * \brief Modify the internal buffers according to the intensive quantities relevant for - * an element - */ - 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 (rockInternalEnergyOutput_()) - rockInternalEnergy_[globalDofIdx] = - scalarValue(intQuants.rockInternalEnergy()); - - if (totalThermalConductivityOutput_()) - totalThermalConductivity_[globalDofIdx] = - scalarValue(intQuants.totalThermalConductivity()); - - for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { - if (FluidSystem::phaseIsActive(phaseIdx)) { - if (fluidInternalEnergiesOutput_()) - fluidInternalEnergies_[phaseIdx][globalDofIdx] = - scalarValue(intQuants.fluidState().internalEnergy(phaseIdx)); - - if (fluidEnthalpiesOutput_()) - fluidEnthalpies_[phaseIdx][globalDofIdx] = - scalarValue(intQuants.fluidState().enthalpy(phaseIdx)); - } - } - } - } - - /*! - * \brief Add all buffers to the VTK output writer. - */ - void commitBuffers(BaseOutputWriter& baseWriter) - { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); - if (!vtkWriter) - return; - - if (!enableEnergy) - return; - - if (rockInternalEnergyOutput_()) - this->commitScalarBuffer_(baseWriter, "volumetric internal energy rock", rockInternalEnergy_); - - if (totalThermalConductivityOutput_()) - this->commitScalarBuffer_(baseWriter, "total thermal conductivity", totalThermalConductivity_); - - if (fluidInternalEnergiesOutput_()) - this->commitPhaseBuffer_(baseWriter, "internal energy_%s", fluidInternalEnergies_); - - if (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; - } - - ScalarBuffer rockInternalEnergy_; - ScalarBuffer totalThermalConductivity_; - PhaseBuffer fluidInternalEnergies_; - PhaseBuffer fluidEnthalpies_; -}; -} // namespace Opm - -#endif diff --git a/opm/models/io/vtkblackoilenergymodule.hpp b/opm/models/io/vtkblackoilenergymodule.hpp new file mode 100644 index 00000000000..589584393f6 --- /dev/null +++ b/opm/models/io/vtkblackoilenergymodule.hpp @@ -0,0 +1,201 @@ +// -*- 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_MODULE_HPP +#define OPM_VTK_BLACK_OIL_ENERGY_MODULE_HPP + +#include + +#include + +#include + +#include + +#include +#include +#include + +#include +#include + +namespace Opm { + +/*! + * \ingroup Vtk + * + * \brief VTK output module for the black oil model's energy related quantities. + */ +template +class VtkBlackOilEnergyModule : public BaseOutputModule +{ + using ParentType = BaseOutputModule; + + using Simulator = GetPropType; + using GridView = GetPropType; + using Scalar = GetPropType; + using Evaluation = GetPropType; + using ElementContext = GetPropType; + using FluidSystem = GetPropType; + + static const int vtkFormat = getPropValue(); + using VtkMultiWriter = ::Opm::VtkMultiWriter; + + enum { enableEnergy = getPropValue() }; + enum { numPhases = getPropValue() }; + + using ScalarBuffer = typename ParentType::ScalarBuffer; + using PhaseBuffer = typename ParentType::PhaseBuffer; + +public: + VtkBlackOilEnergyModule(const Simulator& simulator) + : ParentType(simulator) + { + if constexpr (enableEnergy) { + params_.read(); + } + } + + /*! + * \brief Register all run-time parameters for the multi-phase VTK output + * module. + */ + static void registerParameters() + { + if constexpr (enableEnergy) { + VtkBlackoilEnergyParams::registerParameters(); + } + } + + /*! + * \brief Allocate memory for the scalar fields we would like to + * write to the VTK file. + */ + void allocBuffers() + { + if constexpr (enableEnergy) { + if (!Parameters::Get()) { + return; + } + + if (params_.rockInternalEnergyOutput_) { + this->resizeScalarBuffer_(rockInternalEnergy_); + } + if (params_.totalThermalConductivityOutput_) { + this->resizeScalarBuffer_(totalThermalConductivity_); + } + if (params_.fluidInternalEnergiesOutput_) { + this->resizePhaseBuffer_(fluidInternalEnergies_); + } + if (params_.fluidEnthalpiesOutput_) { + this->resizePhaseBuffer_(fluidEnthalpies_); + } + } + } + + /*! + * \brief Modify the internal buffers according to the intensive quantities relevant for + * an element + */ + void processElement(const ElementContext& elemCtx) + { + if constexpr (enableEnergy) { + 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_.rockInternalEnergyOutput_) { + rockInternalEnergy_[globalDofIdx] = + scalarValue(intQuants.rockInternalEnergy()); + } + + if (params_.totalThermalConductivityOutput_) { + totalThermalConductivity_[globalDofIdx] = + scalarValue(intQuants.totalThermalConductivity()); + } + + 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)); + } + } + } + } + } + } + + /*! + * \brief Add all buffers to the VTK output writer. + */ + void commitBuffers(BaseOutputWriter& baseWriter) + { + if constexpr (enableEnergy) { + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); + if (!vtkWriter) { + return; + } + + if (params_.rockInternalEnergyOutput_) { + this->commitScalarBuffer_(baseWriter, "volumetric internal energy rock", rockInternalEnergy_); + } + + if (params_.totalThermalConductivityOutput_) { + this->commitScalarBuffer_(baseWriter, "total thermal conductivity", totalThermalConductivity_); + } + + if (params_.fluidInternalEnergiesOutput_) { + this->commitPhaseBuffer_(baseWriter, "internal energy_%s", fluidInternalEnergies_); + } + + if (params_.fluidEnthalpiesOutput_) { + this->commitPhaseBuffer_(baseWriter, "enthalpy_%s", fluidEnthalpies_); + } + } + } + +private: + VtkBlackoilEnergyParams params_{}; + + ScalarBuffer rockInternalEnergy_{}; + ScalarBuffer totalThermalConductivity_{}; + PhaseBuffer fluidInternalEnergies_{}; + PhaseBuffer fluidEnthalpies_{}; +}; + +} // namespace Opm + +#endif // OPM_VTK_BLACKOIL_ENERGY_MODULE_HPP 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 diff --git a/opm/models/io/vtkblackoilmicpmodule.hh b/opm/models/io/vtkblackoilmicpmodule.hh deleted file mode 100644 index 95723b440a1..00000000000 --- a/opm/models/io/vtkblackoilmicpmodule.hh +++ /dev/null @@ -1,242 +0,0 @@ -// -*- 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 EWOMS_VTK_BLACK_OIL_MICP_MODULE_HH -#define EWOMS_VTK_BLACK_OIL_MICP_MODULE_HH - -#include - -#include - -#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 - * - * \brief VTK output module for the MICP model's related quantities. - */ -template -class VtkBlackOilMICPModule : public BaseOutputModule -{ - using ParentType = BaseOutputModule; - - using Simulator = GetPropType; - using GridView = GetPropType; - using Scalar = GetPropType; - using Evaluation = GetPropType; - using ElementContext = GetPropType; - - static const int vtkFormat = getPropValue(); - using VtkMultiWriter = ::Opm::VtkMultiWriter; - - enum { enableMICP = getPropValue() }; - - using ScalarBuffer = typename ParentType::ScalarBuffer; - -public: - VtkBlackOilMICPModule(const Simulator& simulator) - : ParentType(simulator) - { } - - /*! - * \brief Register all run-time parameters for the multi-phase VTK output - * module. - */ - 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"); - } - - /*! - * \brief Allocate memory for the scalar fields we would like to - * write to the VTK file. - */ - void allocBuffers() - { - if (!Parameters::Get()) { - return; - } - - 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_); - } - - /*! - * \brief Modify the internal buffers according to the intensive quantities relevant for - * an element - */ - 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()); - - } - } - - /*! - * \brief Add all buffers to the VTK output writer. - */ - 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_); - - } - -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_; -}; - -} // namespace Opm - -#endif diff --git a/opm/models/io/vtkblackoilmicpmodule.hpp b/opm/models/io/vtkblackoilmicpmodule.hpp new file mode 100644 index 00000000000..6c862c5e912 --- /dev/null +++ b/opm/models/io/vtkblackoilmicpmodule.hpp @@ -0,0 +1,205 @@ +// -*- 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_MODULE_HPP +#define OPM_VTK_BLACK_OIL_MICP_MODULE_HPP + +#include + +#include + +#include + +#include + +#include +#include +#include + +#include +#include + +namespace Opm { +/*! + * \ingroup Vtk + * + * \brief VTK output module for the MICP model's related quantities. + */ +template +class VtkBlackOilMICPModule : public BaseOutputModule +{ + using ParentType = BaseOutputModule; + + using Simulator = GetPropType; + using GridView = GetPropType; + using Scalar = GetPropType; + using Evaluation = GetPropType; + using ElementContext = GetPropType; + + static const int vtkFormat = getPropValue(); + using VtkMultiWriter = ::Opm::VtkMultiWriter; + + enum { enableMICP = getPropValue() }; + + using ScalarBuffer = typename ParentType::ScalarBuffer; + +public: + VtkBlackOilMICPModule(const Simulator& simulator) + : ParentType(simulator) + { + if constexpr (enableMICP) { + params_.read(); + } + } + + /*! + * \brief Register all run-time parameters for the multi-phase VTK output + * module. + */ + static void registerParameters() + { + if constexpr (enableMICP) { + VtkBlackoilMICPParams::registerParameters(); + } + } + + /*! + * \brief Allocate memory for the scalar fields we would like to + * write to the VTK file. + */ + void allocBuffers() + { + 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_); + } + } + } + + /*! + * \brief Modify the internal buffers according to the intensive quantities relevant for + * an element + */ + void processElement(const ElementContext& elemCtx) + { + 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()); + } + } + } + } + + /*! + * \brief Add all buffers to the VTK output writer. + */ + void commitBuffers(BaseOutputWriter& baseWriter) + { + 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: + VtkBlackoilMICPParams params_{}; + ScalarBuffer microbialConcentration_{}; + ScalarBuffer oxygenConcentration_{}; + ScalarBuffer ureaConcentration_{}; + ScalarBuffer biofilmConcentration_{}; + ScalarBuffer calciteConcentration_{}; +}; + +} // namespace Opm + +#endif // OPM_VTK_BLACKOIL_MICP_MODULE_HPP 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 diff --git a/opm/models/io/vtkblackoilmodule.hh b/opm/models/io/vtkblackoilmodule.hpp similarity index 55% rename from opm/models/io/vtkblackoilmodule.hh rename to opm/models/io/vtkblackoilmodule.hpp index 30b8127ad92..4d23ff2f69d 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,26 +35,13 @@ #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,90 +290,25 @@ 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 -#endif +#endif // OPM_VTK_BLACK_OIL_MODULE_HPP 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 diff --git a/opm/models/io/vtkblackoilpolymermodule.hh b/opm/models/io/vtkblackoilpolymermodule.hh deleted file mode 100644 index 0f012069ba0..00000000000 --- a/opm/models/io/vtkblackoilpolymermodule.hh +++ /dev/null @@ -1,268 +0,0 @@ -// -*- 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 EWOMS_VTK_BLACK_OIL_POLYMER_MODULE_HH -#define EWOMS_VTK_BLACK_OIL_POLYMER_MODULE_HH - -#include - -#include - -#include - -#include - -#include -#include - -#include -#include - -namespace Opm::Properties::TTag { - -// create new type tag for the VTK multi-phase output -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 { -/*! - * \ingroup Vtk - * - * \brief VTK output module for the black oil model's polymer related quantities. - */ -template -class VtkBlackOilPolymerModule : public BaseOutputModule -{ - using ParentType = BaseOutputModule; - - using Simulator = GetPropType; - using GridView = GetPropType; - using Scalar = GetPropType; - using Evaluation = GetPropType; - using ElementContext = GetPropType; - - static const int vtkFormat = getPropValue(); - using VtkMultiWriter = ::Opm::VtkMultiWriter; - - enum { enablePolymer = getPropValue() }; - - using ScalarBuffer = typename ParentType::ScalarBuffer; - -public: - VtkBlackOilPolymerModule(const Simulator& simulator) - : ParentType(simulator) - { } - - /*! - * \brief Register all run-time parameters for the multi-phase VTK output - * module. - */ - 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"); - } - - /*! - * \brief Allocate memory for the scalar fields we would like to - * write to the VTK file. - */ - void allocBuffers() - { - if (!Parameters::Get()) { - return; - } - - 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_); - } - - /*! - * \brief Modify the internal buffers according to the intensive quantities relevant for - * an element - */ - 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()); - } - } - - /*! - * \brief Add all buffers to the VTK output writer. - */ - 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_); - } - -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_; -}; -} // namespace Opm - -#endif diff --git a/opm/models/io/vtkblackoilpolymermodule.hpp b/opm/models/io/vtkblackoilpolymermodule.hpp new file mode 100644 index 00000000000..ac6d9f43eb0 --- /dev/null +++ b/opm/models/io/vtkblackoilpolymermodule.hpp @@ -0,0 +1,226 @@ +// -*- 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_MODULE_HPP +#define OPM_VTK_BLACK_OIL_POLYMER_MODULE_HPP + +#include + +#include + +#include + +#include + +#include +#include +#include + +#include +#include + +namespace Opm::Properties::TTag { + +// create new type tag for the VTK multi-phase output +struct VtkBlackOilPolymer {}; + +} // namespace Opm::Properties::TTag + +namespace Opm { + +/*! + * \ingroup Vtk + * + * \brief VTK output module for the black oil model's polymer related quantities. + */ +template +class VtkBlackOilPolymerModule : public BaseOutputModule +{ + using ParentType = BaseOutputModule; + + using Simulator = GetPropType; + using GridView = GetPropType; + using Scalar = GetPropType; + using Evaluation = GetPropType; + using ElementContext = GetPropType; + + static const int vtkFormat = getPropValue(); + using VtkMultiWriter = ::Opm::VtkMultiWriter; + + enum { enablePolymer = getPropValue() }; + + using ScalarBuffer = typename ParentType::ScalarBuffer; + +public: + VtkBlackOilPolymerModule(const Simulator& simulator) + : ParentType(simulator) + { + if constexpr (enablePolymer) { + params_.read(); + } + } + + /*! + * \brief Register all run-time parameters for the multi-phase VTK output + * module. + */ + static void registerParameters() + { + if constexpr (enablePolymer) { + VtkBlackoilPolymerParams::registerParameters(); + } + } + + /*! + * \brief Allocate memory for the scalar fields we would like to + * write to the VTK file. + */ + void allocBuffers() + { + 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_); + } + } + } + + /*! + * \brief Modify the internal buffers according to the intensive quantities relevant for + * an element + */ + void processElement(const ElementContext& elemCtx) + { + 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()); + } + } + } + } + + /*! + * \brief Add all buffers to the VTK output writer. + */ + void commitBuffers(BaseOutputWriter& baseWriter) + { + 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: + VtkBlackoilPolymerParams params_{}; + ScalarBuffer polymerConcentration_{}; + ScalarBuffer polymerDeadPoreVolume_{}; + ScalarBuffer polymerRockDensity_{}; + ScalarBuffer polymerAdsorption_{}; + ScalarBuffer polymerViscosityCorrection_{}; + ScalarBuffer waterViscosityCorrection_{}; +}; + +} // namespace Opm + +#endif // OPM_VTK_BLACK_OIL_POLYMER_MODULE_HPP 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 diff --git a/opm/models/io/vtkblackoilsolventmodule.hh b/opm/models/io/vtkblackoilsolventmodule.hh deleted file mode 100644 index 3dda896e9c9..00000000000 --- a/opm/models/io/vtkblackoilsolventmodule.hh +++ /dev/null @@ -1,243 +0,0 @@ -// -*- 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 EWOMS_VTK_BLACK_OIL_SOLVENT_MODULE_HH -#define EWOMS_VTK_BLACK_OIL_SOLVENT_MODULE_HH - -#include - -#include - -#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 { -/*! - * \ingroup Vtk - * - * \brief VTK output module for the black oil model's solvent related quantities. - */ -template -class VtkBlackOilSolventModule : public BaseOutputModule -{ - using ParentType = BaseOutputModule; - - using Simulator = GetPropType; - using GridView = GetPropType; - using Scalar = GetPropType; - using Evaluation = GetPropType; - using ElementContext = GetPropType; - - static const int vtkFormat = getPropValue(); - using VtkMultiWriter = ::Opm::VtkMultiWriter; - - enum { enableSolvent = getPropValue() }; - - using ScalarBuffer = typename ParentType::ScalarBuffer; - -public: - VtkBlackOilSolventModule(const Simulator& simulator) - : ParentType(simulator) - { } - - /*! - * \brief Register all run-time parameters for the multi-phase VTK output - * module. - */ - 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"); - } - - /*! - * \brief Allocate memory for the scalar fields we would like to - * write to the VTK file. - */ - void allocBuffers() - { - if (!Parameters::Get()) { - return; - } - - 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_); - } - - /*! - * \brief Modify the internal buffers according to the intensive quantities relevant for - * an element - */ - 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()); - } - } - - /*! - * \brief Add all buffers to the VTK output writer. - */ - 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_); - } - -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_; -}; - -} // namespace Opm - -#endif diff --git a/opm/models/io/vtkblackoilsolventmodule.hpp b/opm/models/io/vtkblackoilsolventmodule.hpp new file mode 100644 index 00000000000..0fdb69a7c80 --- /dev/null +++ b/opm/models/io/vtkblackoilsolventmodule.hpp @@ -0,0 +1,207 @@ +// -*- 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_MODULE_HPP +#define OPM_VTK_BLACK_OIL_SOLVENT_MODULE_HPP + +#include + +#include + +#include + +#include + +#include +#include +#include + +#include +#include + +namespace Opm { + +/*! + * \ingroup Vtk + * + * \brief VTK output module for the black oil model's solvent related quantities. + */ +template +class VtkBlackOilSolventModule : public BaseOutputModule +{ + using ParentType = BaseOutputModule; + + using Simulator = GetPropType; + using GridView = GetPropType; + using Scalar = GetPropType; + using Evaluation = GetPropType; + using ElementContext = GetPropType; + + static const int vtkFormat = getPropValue(); + using VtkMultiWriter = ::Opm::VtkMultiWriter; + + enum { enableSolvent = getPropValue() }; + + using ScalarBuffer = typename ParentType::ScalarBuffer; + +public: + VtkBlackOilSolventModule(const Simulator& simulator) + : ParentType(simulator) + { + if constexpr (enableSolvent) { + params_.read(); + } + } + + /*! + * \brief Register all run-time parameters for the multi-phase VTK output + * module. + */ + static void registerParameters() + { + if constexpr (enableSolvent) { + VtkBlackOilSolventParams::registerParameters(); + } + } + + /*! + * \brief Allocate memory for the scalar fields we would like to + * write to the VTK file. + */ + void allocBuffers() + { + 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_); + } + } + } + + /*! + * \brief Modify the internal buffers according to the intensive quantities relevant for + * an element + */ + void processElement(const ElementContext& elemCtx) + { + 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()); + } + } + } + } + + /*! + * \brief Add all buffers to the VTK output writer. + */ + void commitBuffers(BaseOutputWriter& baseWriter) + { + 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: + VtkBlackOilSolventParams params_{}; + ScalarBuffer solventSaturation_{}; + ScalarBuffer solventRsw_{}; + ScalarBuffer solventDensity_{}; + ScalarBuffer solventViscosity_{}; + ScalarBuffer solventMobility_{}; +}; + +} // namespace Opm + +#endif // OPM_VTK_BLACK_OIL_SOLVENT_MODULE_HPP 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 diff --git a/opm/models/io/vtkcompositionmodule.hh b/opm/models/io/vtkcompositionmodule.hpp similarity index 65% rename from opm/models/io/vtkcompositionmodule.hh rename to opm/models/io/vtkcompositionmodule.hpp index 984add073fa..962bfdb7c6f 100644 --- a/opm/models/io/vtkcompositionmodule.hh +++ b/opm/models/io/vtkcompositionmodule.hpp @@ -24,32 +24,20 @@ * \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 #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,81 +193,47 @@ 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 -#endif +#endif // OPM_VTK_COMPOSITION_MODULE_HPP 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 diff --git a/opm/models/io/vtkdiffusionmodule.hh b/opm/models/io/vtkdiffusionmodule.hpp similarity index 71% rename from opm/models/io/vtkdiffusionmodule.hh rename to opm/models/io/vtkdiffusionmodule.hpp index f8f12a403d1..3d02fa0690e 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 @@ -34,21 +34,14 @@ #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 { + /*! * \ingroup Vtk * @@ -84,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(); } /*! @@ -107,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_); + } } /*! @@ -130,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)); + } } } } @@ -149,46 +143,32 @@ 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 -#endif +#endif // OPM_VTK_DIFFUSION_MODULE_HPP 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 diff --git a/opm/models/io/vtkdiscretefracturemodule.hh b/opm/models/io/vtkdiscretefracturemodule.hpp similarity index 68% rename from opm/models/io/vtkdiscretefracturemodule.hh rename to opm/models/io/vtkdiscretefracturemodule.hpp index 14251282fd8..0a2718e9c31 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 @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -41,20 +42,8 @@ #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 { + /*! * \ingroup Vtk * @@ -97,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(); } /*! @@ -128,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); @@ -169,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); @@ -216,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 = @@ -246,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()); @@ -288,63 +279,22 @@ 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 -#endif +#endif // OPM_VTK_DISCRETE_FRACTURE_MODULE_HPP 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 diff --git a/opm/models/io/vtkenergymodule.hh b/opm/models/io/vtkenergymodule.hpp similarity index 66% rename from opm/models/io/vtkenergymodule.hh rename to opm/models/io/vtkenergymodule.hpp index 06cc4dad49f..394d3af6b01 100644 --- a/opm/models/io/vtkenergymodule.hh +++ b/opm/models/io/vtkenergymodule.hpp @@ -24,12 +24,13 @@ * \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 #include +#include #include #include @@ -37,17 +38,8 @@ #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 { + /*! * \ingroup Vtk * @@ -85,6 +77,7 @@ class VtkEnergyModule : public BaseOutputModule VtkEnergyModule(const Simulator& simulator) : ParentType(simulator) { + params_.read(); } /*! @@ -92,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(); } /*! @@ -112,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_); + } } /*! @@ -138,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)); + } } } } @@ -157,54 +147,35 @@ 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 -#endif +#endif // OPM_VTK_ENERGY_MODULE_HPP 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 diff --git a/opm/models/io/vtkmultiphasemodule.hh b/opm/models/io/vtkmultiphasemodule.hpp similarity index 61% rename from opm/models/io/vtkmultiphasemodule.hh rename to opm/models/io/vtkmultiphasemodule.hpp index bf8e1e7a298..c8342ae0410 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 @@ -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,103 +378,32 @@ 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 -#endif +#endif // OPM_VTK_MULTI_PHASE_MODULE_HPP 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 diff --git a/opm/models/io/vtkphasepresencemodule.hh b/opm/models/io/vtkphasepresencemodule.hpp similarity index 80% rename from opm/models/io/vtkphasepresencemodule.hh rename to opm/models/io/vtkphasepresencemodule.hpp index c66429c4aa7..2de0e401067 100644 --- a/opm/models/io/vtkphasepresencemodule.hh +++ b/opm/models/io/vtkphasepresencemodule.hpp @@ -24,24 +24,20 @@ * \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 #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,25 +111,21 @@ 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 -#endif +#endif // OPM_VTK_PHASE_PRESENCE_MODULE_HPP 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 diff --git a/opm/models/io/vtkprimaryvarsmodule.hh b/opm/models/io/vtkprimaryvarsmodule.hpp similarity index 71% rename from opm/models/io/vtkprimaryvarsmodule.hh rename to opm/models/io/vtkprimaryvarsmodule.hpp index 5bbbcdc3bf2..830e1300bc5 100644 --- a/opm/models/io/vtkprimaryvarsmodule.hh +++ b/opm/models/io/vtkprimaryvarsmodule.hpp @@ -24,25 +24,18 @@ * \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 #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,44 +130,32 @@ 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 -#endif +#endif // OPM_VTK_PRIMARY_VARS_MODULE_HPP 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 diff --git a/opm/models/io/vtkptflashmodule.hh b/opm/models/io/vtkptflashmodule.hpp similarity index 77% rename from opm/models/io/vtkptflashmodule.hh rename to opm/models/io/vtkptflashmodule.hpp index a7509f8dec1..4b531afda94 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 @@ -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,34 +132,25 @@ 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 -#endif +#endif // OPM_VTK_PTFLASH_MODULE_HPP 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 diff --git a/opm/models/io/vtktemperaturemodule.hh b/opm/models/io/vtktemperaturemodule.hpp similarity index 81% rename from opm/models/io/vtktemperaturemodule.hh rename to opm/models/io/vtktemperaturemodule.hpp index 0cdd62c2763..34242a39ea4 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 @@ -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,25 +116,21 @@ 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 -#endif +#endif // OPM_VTK_TEMPERATURE_MODULE_HPP 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 diff --git a/opm/models/ncp/ncpmodel.hh b/opm/models/ncp/ncpmodel.hh index 4dbaefd4dbd..d0459ecdb05 100644 --- a/opm/models/ncp/ncpmodel.hh +++ b/opm/models/ncp/ncpmodel.hh @@ -45,9 +45,9 @@ #include #include #include -#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..2120b8d8c16 100644 --- a/opm/models/ncp/ncpproperties.hh +++ b/opm/models/ncp/ncpproperties.hh @@ -31,9 +31,9 @@ #define EWOMS_NCP_PROPERTIES_HH #include -#include -#include -#include +#include +#include +#include namespace Opm::Properties { diff --git a/opm/models/nonlinear/newtonmethod.hh b/opm/models/nonlinear/newtonmethod.hh index 744d90349f8..aefaea00b56 100644 --- a/opm/models/nonlinear/newtonmethod.hh +++ b/opm/models/nonlinear/newtonmethod.hh @@ -37,7 +37,7 @@ #include -#include +#include #include #include @@ -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/newtonmethodparameters.hh b/opm/models/nonlinear/newtonmethodparams.hpp similarity index 76% rename from opm/models/nonlinear/newtonmethodparameters.hh rename to opm/models/nonlinear/newtonmethodparams.hpp index 72afa9ecee4..b49d176285d 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,28 @@ struct NewtonWriteConvergence { static constexpr bool value = false; }; } // end namespace Opm::Parameters -#endif +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 diff --git a/opm/models/ptflash/flashmodel.hh b/opm/models/ptflash/flashmodel.hh index 3d87ba36593..83644c11379 100644 --- a/opm/models/ptflash/flashmodel.hh +++ b/opm/models/ptflash/flashmodel.hh @@ -43,10 +43,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/opm/models/pvs/pvsmodel.hh b/opm/models/pvs/pvsmodel.hh index ec165efe2e4..f5c600d76fa 100644 --- a/opm/models/pvs/pvsmodel.hh +++ b/opm/models/pvs/pvsmodel.hh @@ -38,9 +38,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/opm/models/pvs/pvsproperties.hh b/opm/models/pvs/pvsproperties.hh index b6ef7031850..0408de9fbed 100644 --- a/opm/models/pvs/pvsproperties.hh +++ b/opm/models/pvs/pvsproperties.hh @@ -33,10 +33,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Opm::Properties { 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 db63cfee42f..ab3dcc7ec5e 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -31,13 +31,13 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#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