diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 064698859..70dab1e52 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -72,6 +72,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkdiscretefractureparams.cpp opm/models/io/vtkenergyparams.cpp opm/models/io/vtkmultiphaseparams.cpp + opm/models/io/vtkphasepresenceparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -681,6 +682,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkmultiphaseparams.hpp opm/models/io/vtkmultiwriter.hh opm/models/io/vtkphasepresencemodule.hpp + opm/models/io/vtkphasepresenceparams.hpp opm/models/io/vtkprimaryvarsmodule.hh opm/models/io/vtkptflashmodule.hh opm/models/io/vtkscalarfunction.hh diff --git a/opm/models/io/vtkphasepresencemodule.hpp b/opm/models/io/vtkphasepresencemodule.hpp index 862ce9301..2de0e4010 100644 --- a/opm/models/io/vtkphasepresencemodule.hpp +++ b/opm/models/io/vtkphasepresencemodule.hpp @@ -30,18 +30,14 @@ #include #include +#include #include #include #include -namespace Opm::Parameters { - -struct VtkWritePhasePresence { static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { + /*! * \ingroup Vtk * @@ -66,16 +62,16 @@ class VtkPhasePresenceModule : public BaseOutputModule public: VtkPhasePresenceModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the Vtk output module. */ static void registerParameters() { - Parameters::Register - ("Include the phase presence pseudo primary " - "variable in the VTK output files"); + VtkPhasePresenceParams::registerParameters(); } /*! @@ -84,7 +80,9 @@ public: */ void allocBuffers() { - if (phasePresenceOutput_()) this->resizeScalarBuffer_(phasePresence_); + if (params_.phasePresenceOutput_) { + this->resizeScalarBuffer_(phasePresence_); + } } /*! @@ -102,8 +100,9 @@ public: int phasePresence = elemCtx.primaryVars(i, /*timeIdx=*/0).phasePresence(); unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); - if (phasePresenceOutput_()) + if (params_.phasePresenceOutput_) { phasePresence_[I] = phasePresence; + } } } @@ -112,23 +111,19 @@ public: */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (phasePresenceOutput_()) + if (params_.phasePresenceOutput_) { this->commitScalarBuffer_(baseWriter, "phase presence", phasePresence_); + } } private: - static bool phasePresenceOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - ScalarBuffer phasePresence_; + VtkPhasePresenceParams params_{}; + ScalarBuffer phasePresence_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkphasepresenceparams.cpp b/opm/models/io/vtkphasepresenceparams.cpp new file mode 100644 index 000000000..7a8c6f6bc --- /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 000000000..2a66e0d36 --- /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