vtkblackoilmodule: move parameters to dedicated struct with a translation unit

This commit is contained in:
Arne Morten Kvarving 2024-09-16 08:43:09 +02:00
parent 6a1b33c793
commit a44640bc65
4 changed files with 252 additions and 171 deletions

View File

@ -62,6 +62,7 @@ list (APPEND MAIN_SOURCE_FILES
opm/models/blackoil/blackoilnewtonmethodparams.cpp
opm/models/blackoil/blackoilpolymerparams.cpp
opm/models/blackoil/blackoilsolventparams.cpp
opm/models/io/vtkblackoilparams.cpp
opm/models/io/restart.cpp
opm/models/parallel/mpiutil.cpp
opm/models/parallel/tasklets.cpp
@ -652,6 +653,7 @@ list (APPEND PUBLIC_HEADER_FILES
opm/models/io/vtkblackoilenergymodule.hh
opm/models/io/vtkblackoilmicpmodule.hh
opm/models/io/vtkblackoilmodule.hpp
opm/models/io/vtkblackoilparams.hpp
opm/models/io/vtkblackoilpolymermodule.hh
opm/models/io/vtkblackoilsolventmodule.hh
opm/models/io/vtkcompositionmodule.hh

View File

@ -36,28 +36,12 @@
#include <opm/models/discretization/common/fvbaseparameters.hh>
#include <opm/models/io/baseoutputmodule.hh>
#include <opm/models/io/vtkblackoilparams.hpp>
#include <opm/models/io/vtkmultiwriter.hh>
#include <opm/models/utils/parametersystem.hpp>
#include <opm/models/utils/propertysystem.hh>
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<TypeTag>
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 @@ public:
*/
static void registerParameters()
{
Parameters::Register<Parameters::VtkWriteGasDissolutionFactor>
("Include the gas dissolution factor (R_s) of the observed oil "
"in the VTK output files");
Parameters::Register<Parameters::VtkWriteOilVaporizationFactor>
("Include the oil vaporization factor (R_v) of the observed gas "
"in the VTK output files");
Parameters::Register<Parameters::VtkWriteOilFormationVolumeFactor>
("Include the oil formation volume factor (B_o) in the VTK output files");
Parameters::Register<Parameters::VtkWriteGasFormationVolumeFactor>
("Include the gas formation volume factor (B_g) in the "
"VTK output files");
Parameters::Register<Parameters::VtkWriteWaterFormationVolumeFactor>
("Include the water formation volume factor (B_w) in the "
"VTK output files");
Parameters::Register<Parameters::VtkWriteOilSaturationPressure>
("Include the saturation pressure of oil (p_o,sat) in the "
"VTK output files");
Parameters::Register<Parameters::VtkWriteGasSaturationPressure>
("Include the saturation pressure of gas (p_g,sat) in the "
"VTK output files");
Parameters::Register<Parameters::VtkWriteSaturatedOilGasDissolutionFactor>
("Include the gas dissolution factor (R_s,sat) of gas saturated "
"oil in the VTK output files");
Parameters::Register<Parameters::VtkWriteSaturatedGasOilVaporizationFactor>
("Include the oil vaporization factor (R_v,sat) of oil saturated "
"gas in the VTK output files");
Parameters::Register<Parameters::VtkWriteSaturationRatios>
("Write the ratio of the actually and maximum dissolved component of "
"the mixtures");
Parameters::Register<Parameters::VtkWritePrimaryVarsMeaning>
("Include how the primary variables should be interpreted to the "
"VTK output files");
VtkBlackoilParams::registerParameters();
}
/*!
@ -141,29 +96,38 @@ public:
*/
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 @@ public:
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<FluidState, Scalar>(fs, oilPhaseIdx, pvtRegionIdx);
if (gasSaturationPressureOutput_())
}
if (params_.gasSaturationPressureOutput_) {
gasSaturationPressure_[globalDofIdx] =
FluidSystem::template saturationPressure<FluidState, Scalar>(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<FluidState, Scalar>(fs, oilPhaseIdx, pvtRegionIdx);
if (gasFormationVolumeFactorOutput_())
1.0 / FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(fs, oilPhaseIdx, pvtRegionIdx);
}
if (params_.gasFormationVolumeFactorOutput_) {
gasFormationVolumeFactor_[globalDofIdx] =
1.0/FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(fs, gasPhaseIdx, pvtRegionIdx);
if (waterFormationVolumeFactorOutput_())
1.0 / FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(fs, gasPhaseIdx, pvtRegionIdx);
}
if (params_.waterFormationVolumeFactorOutput_) {
waterFormationVolumeFactor_[globalDofIdx] =
1.0/FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(fs, waterPhaseIdx, pvtRegionIdx);
1.0 / FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(fs, waterPhaseIdx, pvtRegionIdx);
}
if (primaryVarsMeaningOutput_()) {
if (params_.primaryVarsMeaningOutput_) {
primaryVarsMeaningWater_[globalDofIdx] =
static_cast<int>(primaryVars.primaryVarsMeaningWater());
primaryVarsMeaningGas_[globalDofIdx] =
@ -269,33 +246,43 @@ public:
void commitBuffers(BaseOutputWriter& baseWriter)
{
VtkMultiWriter *vtkWriter = dynamic_cast<VtkMultiWriter*>(&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,88 +290,23 @@ public:
}
private:
static bool gasDissolutionFactorOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteGasDissolutionFactor>();
return val;
}
VtkBlackoilParams params_{};
ScalarBuffer gasDissolutionFactor_{};
ScalarBuffer oilVaporizationFactor_{};
ScalarBuffer oilFormationVolumeFactor_{};
ScalarBuffer gasFormationVolumeFactor_{};
ScalarBuffer waterFormationVolumeFactor_{};
ScalarBuffer oilSaturationPressure_{};
ScalarBuffer gasSaturationPressure_{};
static bool oilVaporizationFactorOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteOilVaporizationFactor>();
return val;
}
ScalarBuffer saturatedOilGasDissolutionFactor_{};
ScalarBuffer saturatedGasOilVaporizationFactor_{};
ScalarBuffer oilSaturationRatio_{};
ScalarBuffer gasSaturationRatio_{};
static bool oilFormationVolumeFactorOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteOilFormationVolumeFactor>();
return val;
}
static bool gasFormationVolumeFactorOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteGasFormationVolumeFactor>();
return val;
}
static bool waterFormationVolumeFactorOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteWaterFormationVolumeFactor>();
return val;
}
static bool oilSaturationPressureOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteOilSaturationPressure>();
return val;
}
static bool gasSaturationPressureOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteGasSaturationPressure>();
return val;
}
static bool saturatedOilGasDissolutionFactorOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteSaturatedOilGasDissolutionFactor>();
return val;
}
static bool saturatedGasOilVaporizationFactorOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteSaturatedGasOilVaporizationFactor>();
return val;
}
static bool saturationRatiosOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWriteSaturationRatios>();
return val;
}
static bool primaryVarsMeaningOutput_()
{
static bool val = Parameters::Get<Parameters::VtkWritePrimaryVarsMeaning>();
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_;
ScalarBuffer primaryVarsMeaningPressure_{};
ScalarBuffer primaryVarsMeaningWater_{};
ScalarBuffer primaryVarsMeaningGas_{};
};
} // namespace Opm

View File

@ -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 <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/vtkblackoilparams.hpp>
#include <opm/models/utils/parametersystem.hpp>
namespace Opm {
void VtkBlackoilParams::registerParameters()
{
Parameters::Register<Parameters::VtkWriteGasDissolutionFactor>
("Include the gas dissolution factor (R_s) of the observed oil "
"in the VTK output files");
Parameters::Register<Parameters::VtkWriteOilVaporizationFactor>
("Include the oil vaporization factor (R_v) of the observed gas "
"in the VTK output files");
Parameters::Register<Parameters::VtkWriteOilFormationVolumeFactor>
("Include the oil formation volume factor (B_o) in the VTK output files");
Parameters::Register<Parameters::VtkWriteGasFormationVolumeFactor>
("Include the gas formation volume factor (B_g) in the "
"VTK output files");
Parameters::Register<Parameters::VtkWriteWaterFormationVolumeFactor>
("Include the water formation volume factor (B_w) in the "
"VTK output files");
Parameters::Register<Parameters::VtkWriteOilSaturationPressure>
("Include the saturation pressure of oil (p_o,sat) in the "
"VTK output files");
Parameters::Register<Parameters::VtkWriteGasSaturationPressure>
("Include the saturation pressure of gas (p_g,sat) in the "
"VTK output files");
Parameters::Register<Parameters::VtkWriteSaturatedOilGasDissolutionFactor>
("Include the gas dissolution factor (R_s,sat) of gas saturated "
"oil in the VTK output files");
Parameters::Register<Parameters::VtkWriteSaturatedGasOilVaporizationFactor>
("Include the oil vaporization factor (R_v,sat) of oil saturated "
"gas in the VTK output files");
Parameters::Register<Parameters::VtkWriteSaturationRatios>
("Write the ratio of the actually and maximum dissolved component of "
"the mixtures");
Parameters::Register<Parameters::VtkWritePrimaryVarsMeaning>
("Include how the primary variables should be interpreted to the "
"VTK output files");
}
void VtkBlackoilParams::read()
{
gasDissolutionFactorOutput_ = Parameters::Get<Parameters::VtkWriteGasDissolutionFactor>();
oilVaporizationFactorOutput_ = Parameters::Get<Parameters::VtkWriteOilVaporizationFactor>();
oilFormationVolumeFactorOutput_ = Parameters::Get<Parameters::VtkWriteOilFormationVolumeFactor>();
gasFormationVolumeFactorOutput_ = Parameters::Get<Parameters::VtkWriteGasFormationVolumeFactor>();
waterFormationVolumeFactorOutput_ = Parameters::Get<Parameters::VtkWriteWaterFormationVolumeFactor>();
oilSaturationPressureOutput_ = Parameters::Get<Parameters::VtkWriteOilSaturationPressure>();
gasSaturationPressureOutput_ = Parameters::Get<Parameters::VtkWriteGasSaturationPressure>();
saturatedOilGasDissolutionFactorOutput_ = Parameters::Get<Parameters::VtkWriteSaturatedOilGasDissolutionFactor>();
saturatedGasOilVaporizationFactorOutput_ = Parameters::Get<Parameters::VtkWriteSaturatedGasOilVaporizationFactor>();
saturationRatiosOutput_ = Parameters::Get<Parameters::VtkWriteSaturationRatios>();
primaryVarsMeaningOutput_ = Parameters::Get<Parameters::VtkWritePrimaryVarsMeaning>();
}
} // namespace Opm

View File

@ -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 <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::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