mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
vtkphasepresencemodule: move parameters to dedicated struct with a translation unit
This commit is contained in:
parent
08b9c78ddd
commit
adb6438d84
@ -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
|
||||
|
@ -30,18 +30,14 @@
|
||||
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
||||
|
||||
#include <opm/models/io/baseoutputmodule.hh>
|
||||
#include <opm/models/io/vtkphasepresenceparams.hpp>
|
||||
#include <opm/models/io/vtkmultiwriter.hh>
|
||||
|
||||
#include <opm/models/utils/parametersystem.hpp>
|
||||
#include <opm/models/utils/propertysystem.hh>
|
||||
|
||||
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<TypeTag>
|
||||
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<Parameters::VtkWritePhasePresence>
|
||||
("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<VtkMultiWriter*>(&baseWriter);
|
||||
VtkMultiWriter* vtkWriter = dynamic_cast<VtkMultiWriter*>(&baseWriter);
|
||||
if (!vtkWriter) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (phasePresenceOutput_())
|
||||
if (params_.phasePresenceOutput_) {
|
||||
this->commitScalarBuffer_(baseWriter, "phase presence", phasePresence_);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static bool phasePresenceOutput_()
|
||||
{
|
||||
static bool val = Parameters::Get<Parameters::VtkWritePhasePresence>();
|
||||
return val;
|
||||
}
|
||||
|
||||
ScalarBuffer phasePresence_;
|
||||
VtkPhasePresenceParams params_{};
|
||||
ScalarBuffer phasePresence_{};
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
43
opm/models/io/vtkphasepresenceparams.cpp
Normal file
43
opm/models/io/vtkphasepresenceparams.cpp
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 <config.h>
|
||||
#include <opm/models/io/vtkphasepresenceparams.hpp>
|
||||
|
||||
#include <opm/models/utils/parametersystem.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
void VtkPhasePresenceParams::registerParameters()
|
||||
{
|
||||
Parameters::Register<Parameters::VtkWritePhasePresence>
|
||||
("Include the phase presence pseudo primary "
|
||||
"variable in the VTK output files");
|
||||
}
|
||||
|
||||
void VtkPhasePresenceParams::read()
|
||||
{
|
||||
phasePresenceOutput_ = Parameters::Get<Parameters::VtkWritePhasePresence>();
|
||||
}
|
||||
|
||||
} // namespace Opm
|
54
opm/models/io/vtkphasepresenceparams.hpp
Normal file
54
opm/models/io/vtkphasepresenceparams.hpp
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
Loading…
Reference in New Issue
Block a user