diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index ebfcde1a0..efb48cac8 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -74,6 +74,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkmultiphaseparams.cpp opm/models/io/vtkphasepresenceparams.cpp opm/models/io/vtkprimaryvarsparams.cpp + opm/models/io/vtkptflashparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -687,6 +688,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkprimaryvarsmodule.hpp opm/models/io/vtkprimaryvarsparams.hpp opm/models/io/vtkptflashmodule.hpp + opm/models/io/vtkptflashparams.hpp opm/models/io/vtkscalarfunction.hh opm/models/io/vtktemperaturemodule.hh opm/models/io/vtktensorfunction.hh diff --git a/opm/models/io/vtkptflashmodule.hpp b/opm/models/io/vtkptflashmodule.hpp index 2581186b1..4b531afda 100644 --- a/opm/models/io/vtkptflashmodule.hpp +++ b/opm/models/io/vtkptflashmodule.hpp @@ -33,18 +33,11 @@ #include #include +#include #include #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteLiquidMoleFractions { static constexpr bool value = false; }; -struct VtkWriteEquilibriumConstants { static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -79,17 +72,16 @@ class VtkPTFlashModule: public BaseOutputModule public: explicit VtkPTFlashModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the Vtk output module. */ static void registerParameters() { - Parameters::Register - ("Include liquid mole fractions (L) in the VTK output files"); - Parameters::Register - ("Include equilibrium constants (K) in the VTK output files"); + VtkPtFlashParams::registerParameters(); } /*! @@ -98,10 +90,12 @@ public: */ void allocBuffers() { - if (LOutput_()) + if (params_.LOutput_) { this->resizeScalarBuffer_(L_); - if (equilConstOutput_()) + } + if (params_.equilConstOutput_) { this->resizeComponentBuffer_(K_); + } } /*! @@ -121,12 +115,14 @@ public: const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0); const auto& fs = intQuants.fluidState(); - if (LOutput_()) + if (params_.LOutput_) { L_[I] = Toolbox::value(fs.L()); + } for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { - if (equilConstOutput_()) + if (params_.equilConstOutput_) { K_[compIdx][I] = Toolbox::value(fs.K(compIdx)); + } } } } @@ -136,32 +132,23 @@ public: */ void commitBuffers(BaseOutputWriter& baseWriter) { - auto *vtkWriter = dynamic_cast(&baseWriter); + auto* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (equilConstOutput_()) + if (params_.equilConstOutput_) { this->commitComponentBuffer_(baseWriter, "K^%s", K_); - if (LOutput_()) + } + if (params_.LOutput_) { this->commitScalarBuffer_(baseWriter, "L", L_); + } } private: - static bool LOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool equilConstOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ComponentBuffer K_; - ScalarBuffer L_; + VtkPtFlashParams params_{}; + ComponentBuffer K_{}; + ScalarBuffer L_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkptflashparams.cpp b/opm/models/io/vtkptflashparams.cpp new file mode 100644 index 000000000..38ef51f04 --- /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 000000000..96c587ad6 --- /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