mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
vtkdiffusionmodule: move parameters to dedicated struct with a translation unit
This commit is contained in:
parent
6ab0fbe6c2
commit
28995d3624
@ -68,6 +68,7 @@ list (APPEND MAIN_SOURCE_FILES
|
|||||||
opm/models/io/vtkblackoilparams.cpp
|
opm/models/io/vtkblackoilparams.cpp
|
||||||
opm/models/io/vtkblackoilsolventparams.cpp
|
opm/models/io/vtkblackoilsolventparams.cpp
|
||||||
opm/models/io/vtkcompositionparams.cpp
|
opm/models/io/vtkcompositionparams.cpp
|
||||||
|
opm/models/io/vtkdiffusionparams.cpp
|
||||||
opm/models/io/restart.cpp
|
opm/models/io/restart.cpp
|
||||||
opm/models/parallel/mpiutil.cpp
|
opm/models/parallel/mpiutil.cpp
|
||||||
opm/models/parallel/tasklets.cpp
|
opm/models/parallel/tasklets.cpp
|
||||||
@ -668,6 +669,7 @@ list (APPEND PUBLIC_HEADER_FILES
|
|||||||
opm/models/io/vtkcompositionmodule.hpp
|
opm/models/io/vtkcompositionmodule.hpp
|
||||||
opm/models/io/vtkcompositionparams.hpp
|
opm/models/io/vtkcompositionparams.hpp
|
||||||
opm/models/io/vtkdiffusionmodule.hpp
|
opm/models/io/vtkdiffusionmodule.hpp
|
||||||
|
opm/models/io/vtkdiffusionparams.hpp
|
||||||
opm/models/io/vtkdiscretefracturemodule.hh
|
opm/models/io/vtkdiscretefracturemodule.hh
|
||||||
opm/models/io/vtkenergymodule.hh
|
opm/models/io/vtkenergymodule.hh
|
||||||
opm/models/io/vtkmultiphasemodule.hh
|
opm/models/io/vtkmultiphasemodule.hh
|
||||||
|
@ -34,20 +34,12 @@
|
|||||||
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
||||||
|
|
||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
|
#include <opm/models/io/vtkdiffusionparams.hpp>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hpp>
|
#include <opm/models/utils/parametersystem.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 {
|
namespace Opm {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -85,21 +77,16 @@ class VtkDiffusionModule : public BaseOutputModule<TypeTag>
|
|||||||
public:
|
public:
|
||||||
VtkDiffusionModule(const Simulator& simulator)
|
VtkDiffusionModule(const Simulator& simulator)
|
||||||
: ParentType(simulator)
|
: ParentType(simulator)
|
||||||
{ }
|
{
|
||||||
|
params_.read();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Register all run-time parameters for the Vtk output module.
|
* \brief Register all run-time parameters for the Vtk output module.
|
||||||
*/
|
*/
|
||||||
static void registerParameters()
|
static void registerParameters()
|
||||||
{
|
{
|
||||||
Parameters::Register<Parameters::VtkWriteTortuosities>
|
VtkDiffusionParams::registerParameters();
|
||||||
("Include the tortuosity for each phase in the VTK output files");
|
|
||||||
Parameters::Register<Parameters::VtkWriteDiffusionCoefficients>
|
|
||||||
("Include the molecular diffusion coefficients in "
|
|
||||||
"the VTK output files");
|
|
||||||
Parameters::Register<Parameters::VtkWriteEffectiveDiffusionCoefficients>
|
|
||||||
("Include the effective molecular diffusion "
|
|
||||||
"coefficients the medium in the VTK output files");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -108,12 +95,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
void allocBuffers()
|
void allocBuffers()
|
||||||
{
|
{
|
||||||
if (tortuosityOutput_())
|
if (params_.tortuosityOutput_) {
|
||||||
this->resizePhaseBuffer_(tortuosity_);
|
this->resizePhaseBuffer_(tortuosity_);
|
||||||
if (diffusionCoefficientOutput_())
|
}
|
||||||
|
if (params_.diffusionCoefficientOutput_) {
|
||||||
this->resizePhaseComponentBuffer_(diffusionCoefficient_);
|
this->resizePhaseComponentBuffer_(diffusionCoefficient_);
|
||||||
if (effectiveDiffusionCoefficientOutput_())
|
}
|
||||||
|
if (params_.effectiveDiffusionCoefficientOutput_) {
|
||||||
this->resizePhaseComponentBuffer_(effectiveDiffusionCoefficient_);
|
this->resizePhaseComponentBuffer_(effectiveDiffusionCoefficient_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -131,15 +121,18 @@ public:
|
|||||||
const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0);
|
const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0);
|
||||||
|
|
||||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
|
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
|
||||||
if (tortuosityOutput_())
|
if (params_.tortuosityOutput_) {
|
||||||
tortuosity_[phaseIdx][I] = Toolbox::value(intQuants.tortuosity(phaseIdx));
|
tortuosity_[phaseIdx][I] = Toolbox::value(intQuants.tortuosity(phaseIdx));
|
||||||
|
}
|
||||||
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
|
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
|
||||||
if (diffusionCoefficientOutput_())
|
if (params_.diffusionCoefficientOutput_) {
|
||||||
diffusionCoefficient_[phaseIdx][compIdx][I] =
|
diffusionCoefficient_[phaseIdx][compIdx][I] =
|
||||||
Toolbox::value(intQuants.diffusionCoefficient(phaseIdx, compIdx));
|
Toolbox::value(intQuants.diffusionCoefficient(phaseIdx, compIdx));
|
||||||
if (effectiveDiffusionCoefficientOutput_())
|
}
|
||||||
|
if (params_.effectiveDiffusionCoefficientOutput_) {
|
||||||
effectiveDiffusionCoefficient_[phaseIdx][compIdx][I] =
|
effectiveDiffusionCoefficient_[phaseIdx][compIdx][I] =
|
||||||
Toolbox::value(intQuants.effectiveDiffusionCoefficient(phaseIdx, compIdx));
|
Toolbox::value(intQuants.effectiveDiffusionCoefficient(phaseIdx, compIdx));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,44 +143,30 @@ public:
|
|||||||
*/
|
*/
|
||||||
void commitBuffers(BaseOutputWriter& baseWriter)
|
void commitBuffers(BaseOutputWriter& baseWriter)
|
||||||
{
|
{
|
||||||
VtkMultiWriter *vtkWriter = dynamic_cast<VtkMultiWriter*>(&baseWriter);
|
VtkMultiWriter* vtkWriter = dynamic_cast<VtkMultiWriter*>(&baseWriter);
|
||||||
if (!vtkWriter) {
|
if (!vtkWriter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tortuosityOutput_())
|
if (params_.tortuosityOutput_) {
|
||||||
this->commitPhaseBuffer_(baseWriter, "tortuosity", tortuosity_);
|
this->commitPhaseBuffer_(baseWriter, "tortuosity", tortuosity_);
|
||||||
if (diffusionCoefficientOutput_())
|
}
|
||||||
|
if (params_.diffusionCoefficientOutput_) {
|
||||||
this->commitPhaseComponentBuffer_(baseWriter, "diffusionCoefficient",
|
this->commitPhaseComponentBuffer_(baseWriter, "diffusionCoefficient",
|
||||||
diffusionCoefficient_);
|
diffusionCoefficient_);
|
||||||
if (effectiveDiffusionCoefficientOutput_())
|
}
|
||||||
|
if (params_.effectiveDiffusionCoefficientOutput_) {
|
||||||
this->commitPhaseComponentBuffer_(baseWriter,
|
this->commitPhaseComponentBuffer_(baseWriter,
|
||||||
"effectiveDiffusionCoefficient",
|
"effectiveDiffusionCoefficient",
|
||||||
effectiveDiffusionCoefficient_);
|
effectiveDiffusionCoefficient_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool tortuosityOutput_()
|
VtkDiffusionParams params_{};
|
||||||
{
|
PhaseBuffer tortuosity_{};
|
||||||
static bool val = Parameters::Get<Parameters::VtkWriteTortuosities>();
|
PhaseComponentBuffer diffusionCoefficient_{};
|
||||||
return val;
|
PhaseComponentBuffer effectiveDiffusionCoefficient_{};
|
||||||
}
|
|
||||||
|
|
||||||
static bool diffusionCoefficientOutput_()
|
|
||||||
{
|
|
||||||
static bool val = Parameters::Get<Parameters::VtkWriteDiffusionCoefficients>();
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool effectiveDiffusionCoefficientOutput_()
|
|
||||||
{
|
|
||||||
static bool val = Parameters::Get<Parameters::VtkWriteEffectiveDiffusionCoefficients>();
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
PhaseBuffer tortuosity_;
|
|
||||||
PhaseComponentBuffer diffusionCoefficient_;
|
|
||||||
PhaseComponentBuffer effectiveDiffusionCoefficient_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
50
opm/models/io/vtkdiffusionparams.cpp
Normal file
50
opm/models/io/vtkdiffusionparams.cpp
Normal file
@ -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 <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/vtkdiffusionparams.hpp>
|
||||||
|
|
||||||
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
|
namespace Opm {
|
||||||
|
|
||||||
|
void VtkDiffusionParams::registerParameters()
|
||||||
|
{
|
||||||
|
Parameters::Register<Parameters::VtkWriteTortuosities>
|
||||||
|
("Include the tortuosity for each phase in the VTK output files");
|
||||||
|
Parameters::Register<Parameters::VtkWriteDiffusionCoefficients>
|
||||||
|
("Include the molecular diffusion coefficients in "
|
||||||
|
"the VTK output files");
|
||||||
|
Parameters::Register<Parameters::VtkWriteEffectiveDiffusionCoefficients>
|
||||||
|
("Include the effective molecular diffusion "
|
||||||
|
"coefficients the medium in the VTK output files");
|
||||||
|
}
|
||||||
|
|
||||||
|
void VtkDiffusionParams::read()
|
||||||
|
{
|
||||||
|
tortuosityOutput_ = Parameters::Get<Parameters::VtkWriteTortuosities>();
|
||||||
|
diffusionCoefficientOutput_ = Parameters::Get<Parameters::VtkWriteDiffusionCoefficients>();
|
||||||
|
effectiveDiffusionCoefficientOutput_ = Parameters::Get<Parameters::VtkWriteEffectiveDiffusionCoefficients>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Opm
|
60
opm/models/io/vtkdiffusionparams.hpp
Normal file
60
opm/models/io/vtkdiffusionparams.hpp
Normal file
@ -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 <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::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
|
Loading…
Reference in New Issue
Block a user