diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 450d1fded..d1df4df7b 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -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 diff --git a/opm/models/io/vtkblackoilmodule.hpp b/opm/models/io/vtkblackoilmodule.hpp index 9c2d52b9d..4d23ff2f6 100644 --- a/opm/models/io/vtkblackoilmodule.hpp +++ b/opm/models/io/vtkblackoilmodule.hpp @@ -36,28 +36,12 @@ #include #include +#include #include #include #include -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 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 - ("Include the gas dissolution factor (R_s) of the observed oil " - "in the VTK output files"); - Parameters::Register - ("Include the oil vaporization factor (R_v) of the observed gas " - "in the VTK output files"); - Parameters::Register - ("Include the oil formation volume factor (B_o) in the VTK output files"); - Parameters::Register - ("Include the gas formation volume factor (B_g) in the " - "VTK output files"); - Parameters::Register - ("Include the water formation volume factor (B_w) in the " - "VTK output files"); - Parameters::Register - ("Include the saturation pressure of oil (p_o,sat) in the " - "VTK output files"); - Parameters::Register - ("Include the saturation pressure of gas (p_g,sat) in the " - "VTK output files"); - Parameters::Register - ("Include the gas dissolution factor (R_s,sat) of gas saturated " - "oil in the VTK output files"); - Parameters::Register - ("Include the oil vaporization factor (R_v,sat) of oil saturated " - "gas in the VTK output files"); - Parameters::Register - ("Write the ratio of the actually and maximum dissolved component of " - "the mixtures"); - Parameters::Register - ("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(fs, oilPhaseIdx, pvtRegionIdx); - if (gasSaturationPressureOutput_()) + } + if (params_.gasSaturationPressureOutput_) { gasSaturationPressure_[globalDofIdx] = FluidSystem::template saturationPressure(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(fs, oilPhaseIdx, pvtRegionIdx); - if (gasFormationVolumeFactorOutput_()) + 1.0 / FluidSystem::template inverseFormationVolumeFactor(fs, oilPhaseIdx, pvtRegionIdx); + } + if (params_.gasFormationVolumeFactorOutput_) { gasFormationVolumeFactor_[globalDofIdx] = - 1.0/FluidSystem::template inverseFormationVolumeFactor(fs, gasPhaseIdx, pvtRegionIdx); - if (waterFormationVolumeFactorOutput_()) + 1.0 / FluidSystem::template inverseFormationVolumeFactor(fs, gasPhaseIdx, pvtRegionIdx); + } + if (params_.waterFormationVolumeFactorOutput_) { waterFormationVolumeFactor_[globalDofIdx] = - 1.0/FluidSystem::template inverseFormationVolumeFactor(fs, waterPhaseIdx, pvtRegionIdx); + 1.0 / FluidSystem::template inverseFormationVolumeFactor(fs, waterPhaseIdx, pvtRegionIdx); + } - if (primaryVarsMeaningOutput_()) { + if (params_.primaryVarsMeaningOutput_) { primaryVarsMeaningWater_[globalDofIdx] = static_cast(primaryVars.primaryVarsMeaningWater()); primaryVarsMeaningGas_[globalDofIdx] = @@ -269,33 +246,43 @@ public: void commitBuffers(BaseOutputWriter& baseWriter) { VtkMultiWriter *vtkWriter = dynamic_cast(&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(); - 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(); - return val; - } + ScalarBuffer saturatedOilGasDissolutionFactor_{}; + ScalarBuffer saturatedGasOilVaporizationFactor_{}; + ScalarBuffer oilSaturationRatio_{}; + ScalarBuffer gasSaturationRatio_{}; - static bool oilFormationVolumeFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool gasFormationVolumeFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool waterFormationVolumeFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool oilSaturationPressureOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool gasSaturationPressureOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool saturatedOilGasDissolutionFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool saturatedGasOilVaporizationFactorOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool saturationRatiosOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool primaryVarsMeaningOutput_() - { - static bool val = Parameters::Get(); - 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 diff --git a/opm/models/io/vtkblackoilparams.cpp b/opm/models/io/vtkblackoilparams.cpp new file mode 100644 index 000000000..90c93fbcf --- /dev/null +++ b/opm/models/io/vtkblackoilparams.cpp @@ -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 . + + 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 VtkBlackoilParams::registerParameters() +{ + Parameters::Register + ("Include the gas dissolution factor (R_s) of the observed oil " + "in the VTK output files"); + Parameters::Register + ("Include the oil vaporization factor (R_v) of the observed gas " + "in the VTK output files"); + Parameters::Register + ("Include the oil formation volume factor (B_o) in the VTK output files"); + Parameters::Register + ("Include the gas formation volume factor (B_g) in the " + "VTK output files"); + Parameters::Register + ("Include the water formation volume factor (B_w) in the " + "VTK output files"); + Parameters::Register + ("Include the saturation pressure of oil (p_o,sat) in the " + "VTK output files"); + Parameters::Register + ("Include the saturation pressure of gas (p_g,sat) in the " + "VTK output files"); + Parameters::Register + ("Include the gas dissolution factor (R_s,sat) of gas saturated " + "oil in the VTK output files"); + Parameters::Register + ("Include the oil vaporization factor (R_v,sat) of oil saturated " + "gas in the VTK output files"); + Parameters::Register + ("Write the ratio of the actually and maximum dissolved component of " + "the mixtures"); + Parameters::Register + ("Include how the primary variables should be interpreted to the " + "VTK output files"); +} + +void VtkBlackoilParams::read() +{ + gasDissolutionFactorOutput_ = Parameters::Get(); + oilVaporizationFactorOutput_ = Parameters::Get(); + oilFormationVolumeFactorOutput_ = Parameters::Get(); + gasFormationVolumeFactorOutput_ = Parameters::Get(); + waterFormationVolumeFactorOutput_ = Parameters::Get(); + oilSaturationPressureOutput_ = Parameters::Get(); + gasSaturationPressureOutput_ = Parameters::Get(); + saturatedOilGasDissolutionFactorOutput_ = Parameters::Get(); + saturatedGasOilVaporizationFactorOutput_ = Parameters::Get(); + saturationRatiosOutput_ = Parameters::Get(); + primaryVarsMeaningOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkblackoilparams.hpp b/opm/models/io/vtkblackoilparams.hpp new file mode 100644 index 000000000..5fc29074b --- /dev/null +++ b/opm/models/io/vtkblackoilparams.hpp @@ -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 . + + 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