diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index e49999421..3eb385e1f 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -69,6 +69,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/io/vtkblackoilsolventparams.cpp opm/models/io/vtkcompositionparams.cpp opm/models/io/vtkdiffusionparams.cpp + opm/models/io/vtkdiscretefractureparams.cpp opm/models/io/restart.cpp opm/models/parallel/mpiutil.cpp opm/models/parallel/tasklets.cpp @@ -671,6 +672,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/vtkdiffusionmodule.hpp opm/models/io/vtkdiffusionparams.hpp opm/models/io/vtkdiscretefracturemodule.hpp + opm/models/io/vtkdiscretefractureparams.hpp opm/models/io/vtkenergymodule.hh opm/models/io/vtkmultiphasemodule.hh opm/models/io/vtkmultiwriter.hh diff --git a/opm/models/io/vtkdiscretefracturemodule.hpp b/opm/models/io/vtkdiscretefracturemodule.hpp index ae70de96a..0a2718e9c 100644 --- a/opm/models/io/vtkdiscretefracturemodule.hpp +++ b/opm/models/io/vtkdiscretefracturemodule.hpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -41,19 +42,6 @@ #include -namespace Opm::Parameters { - -// set default values for what quantities to output -struct VtkWriteFractureSaturations { static constexpr bool value = true; }; -struct VtkWriteFractureMobilities { static constexpr bool value = false; }; -struct VtkWriteFractureRelativePermeabilities { static constexpr bool value = true; }; -struct VtkWriteFracturePorosity { static constexpr bool value = true; }; -struct VtkWriteFractureIntrinsicPermeabilities { static constexpr bool value = false; }; -struct VtkWriteFractureFilterVelocities { static constexpr bool value = false; }; -struct VtkWriteFractureVolumeFraction { static constexpr bool value = true; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -98,29 +86,16 @@ class VtkDiscreteFractureModule : public BaseOutputModule public: VtkDiscreteFractureModule(const Simulator& simulator) : ParentType(simulator) - { } + { + params_.read(); + } /*! * \brief Register all run-time parameters for the multi-phase VTK output module. */ static void registerParameters() { - Parameters::Register - ("Include the phase saturations in the VTK output files"); - Parameters::Register - ("Include the phase mobilities in the VTK output files"); - Parameters::Register - ("Include the phase relative permeabilities in the " - "VTK output files"); - Parameters::Register - ("Include the porosity in the VTK output files"); - Parameters::Register - ("Include the intrinsic permeability in the VTK output files"); - Parameters::Register - ("Include in the filter velocities of the phases in the VTK output files"); - Parameters::Register - ("Add the fraction of the total volume which is " - "occupied by fractures in the VTK output"); + VtkDiscreteFractureParams::registerParameters(); } /*! @@ -129,21 +104,27 @@ public: */ void allocBuffers() { - if (saturationOutput_()) + if (params_.saturationOutput_) { this->resizePhaseBuffer_(fractureSaturation_); - if (mobilityOutput_()) + } + if (params_.mobilityOutput_) { this->resizePhaseBuffer_(fractureMobility_); - if (relativePermeabilityOutput_()) + } + if (params_.relativePermeabilityOutput_) { this->resizePhaseBuffer_(fractureRelativePermeability_); + } - if (porosityOutput_()) + if (params_.porosityOutput_) { this->resizeScalarBuffer_(fracturePorosity_); - if (intrinsicPermeabilityOutput_()) + } + if (params_.intrinsicPermeabilityOutput_) { this->resizeScalarBuffer_(fractureIntrinsicPermeability_); - if (volumeFractionOutput_()) + } + if (params_.volumeFractionOutput_) { this->resizeScalarBuffer_(fractureVolumeFraction_); + } - if (velocityOutput_()) { + if (params_.velocityOutput_) { size_t nDof = this->simulator_.model().numGridDof(); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { fractureVelocity_[phaseIdx].resize(nDof); @@ -170,43 +151,44 @@ public: for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); - if (!fractureMapper.isFractureVertex(I)) + if (!fractureMapper.isFractureVertex(I)) { continue; + } const auto& intQuants = elemCtx.intensiveQuantities(i, /*timeIdx=*/0); const auto& fs = intQuants.fractureFluidState(); - if (porosityOutput_()) { + if (params_.porosityOutput_) { Opm::Valgrind::CheckDefined(intQuants.fracturePorosity()); fracturePorosity_[I] = intQuants.fracturePorosity(); } - if (intrinsicPermeabilityOutput_()) { + if (params_.intrinsicPermeabilityOutput_) { const auto& K = intQuants.fractureIntrinsicPermeability(); fractureIntrinsicPermeability_[I] = K[0][0]; } for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - if (saturationOutput_()) { + if (params_.saturationOutput_) { Opm::Valgrind::CheckDefined(fs.saturation(phaseIdx)); fractureSaturation_[phaseIdx][I] = fs.saturation(phaseIdx); } - if (mobilityOutput_()) { + if (params_.mobilityOutput_) { Opm::Valgrind::CheckDefined(intQuants.fractureMobility(phaseIdx)); fractureMobility_[phaseIdx][I] = intQuants.fractureMobility(phaseIdx); } - if (relativePermeabilityOutput_()) { + if (params_.relativePermeabilityOutput_) { Opm::Valgrind::CheckDefined(intQuants.fractureRelativePermeability(phaseIdx)); fractureRelativePermeability_[phaseIdx][I] = intQuants.fractureRelativePermeability(phaseIdx); } - if (volumeFractionOutput_()) { + if (params_.volumeFractionOutput_) { Opm::Valgrind::CheckDefined(intQuants.fractureVolume()); fractureVolumeFraction_[I] += intQuants.fractureVolume(); } } } - if (velocityOutput_()) { + if (params_.velocityOutput_) { // calculate velocities if requested by the simulator for (unsigned scvfIdx = 0; scvfIdx < elemCtx.numInteriorFaces(/*timeIdx=*/0); ++ scvfIdx) { const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, /*timeIdx=*/0); @@ -217,8 +199,9 @@ public: unsigned j = extQuants.exteriorIndex(); unsigned J = elemCtx.globalSpaceIndex(j, /*timeIdx=*/0); - if (!fractureMapper.isFractureEdge(I, J)) + if (!fractureMapper.isFractureEdge(I, J)) { continue; + } for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { Scalar weight = @@ -247,38 +230,45 @@ public: */ void commitBuffers(BaseOutputWriter& baseWriter) { - VtkMultiWriter *vtkWriter = dynamic_cast(&baseWriter); + VtkMultiWriter* vtkWriter = dynamic_cast(&baseWriter); if (!vtkWriter) { return; } - if (saturationOutput_()) + if (params_.saturationOutput_) { this->commitPhaseBuffer_(baseWriter, "fractureSaturation_%s", fractureSaturation_); - if (mobilityOutput_()) + } + if (params_.mobilityOutput_) { this->commitPhaseBuffer_(baseWriter, "fractureMobility_%s", fractureMobility_); - if (relativePermeabilityOutput_()) + } + if (params_.relativePermeabilityOutput_) { this->commitPhaseBuffer_(baseWriter, "fractureRelativePerm_%s", fractureRelativePermeability_); + } - if (porosityOutput_()) + if (params_.porosityOutput_) { this->commitScalarBuffer_(baseWriter, "fracturePorosity", fracturePorosity_); - if (intrinsicPermeabilityOutput_()) + } + if (params_.intrinsicPermeabilityOutput_) { this->commitScalarBuffer_(baseWriter, "fractureIntrinsicPerm", fractureIntrinsicPermeability_); - if (volumeFractionOutput_()) { + } + if (params_.volumeFractionOutput_) { // divide the fracture volume by the total volume of the finite volumes - for (unsigned I = 0; I < fractureVolumeFraction_.size(); ++I) + for (unsigned I = 0; I < fractureVolumeFraction_.size(); ++I) { fractureVolumeFraction_[I] /= this->simulator_.model().dofTotalVolume(I); + } this->commitScalarBuffer_(baseWriter, "fractureVolumeFraction", fractureVolumeFraction_); } - if (velocityOutput_()) { + if (params_.velocityOutput_) { size_t nDof = this->simulator_.model().numGridDof(); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { // first, divide the velocity field by the // respective finite volume's surface area - for (unsigned dofIdx = 0; dofIdx < nDof; ++dofIdx) + for (unsigned dofIdx = 0; dofIdx < nDof; ++dofIdx) { fractureVelocity_[phaseIdx][dofIdx] /= std::max(1e-20, fractureVelocityWeight_[phaseIdx][dofIdx]); + } // commit the phase velocity char name[512]; snprintf(name, 512, "fractureFilterVelocity_%s", FluidSystem::phaseName(phaseIdx).data()); @@ -289,61 +279,20 @@ public: } private: - static bool saturationOutput_() - { - static bool val = Parameters::Get(); - return val; - } + VtkDiscreteFractureParams params_{}; + PhaseBuffer fractureSaturation_{}; + PhaseBuffer fractureMobility_{}; + PhaseBuffer fractureRelativePermeability_{}; - static bool mobilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } + ScalarBuffer fracturePorosity_{}; + ScalarBuffer fractureVolumeFraction_{}; + ScalarBuffer fractureIntrinsicPermeability_{}; - static bool relativePermeabilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } + PhaseVectorBuffer fractureVelocity_{}; + PhaseBuffer fractureVelocityWeight_{}; - static bool porosityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool intrinsicPermeabilityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool volumeFractionOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - static bool velocityOutput_() - { - static bool val = Parameters::Get(); - return val; - } - - PhaseBuffer fractureSaturation_; - PhaseBuffer fractureMobility_; - PhaseBuffer fractureRelativePermeability_; - - ScalarBuffer fracturePorosity_; - ScalarBuffer fractureVolumeFraction_; - ScalarBuffer fractureIntrinsicPermeability_; - - PhaseVectorBuffer fractureVelocity_; - PhaseBuffer fractureVelocityWeight_; - - PhaseVectorBuffer potentialGradient_; - PhaseBuffer potentialWeight_; + PhaseVectorBuffer potentialGradient_{}; + PhaseBuffer potentialWeight_{}; }; } // namespace Opm diff --git a/opm/models/io/vtkdiscretefractureparams.cpp b/opm/models/io/vtkdiscretefractureparams.cpp new file mode 100644 index 000000000..9f1c075ec --- /dev/null +++ b/opm/models/io/vtkdiscretefractureparams.cpp @@ -0,0 +1,62 @@ +// -*- 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 VtkDiscreteFractureParams::registerParameters() +{ + Parameters::Register + ("Include the phase saturations in the VTK output files"); + Parameters::Register + ("Include the phase mobilities in the VTK output files"); + Parameters::Register + ("Include the phase relative permeabilities in the " + "VTK output files"); + Parameters::Register + ("Include the porosity in the VTK output files"); + Parameters::Register + ("Include the intrinsic permeability in the VTK output files"); + Parameters::Register + ("Include in the filter velocities of the phases in the VTK output files"); + Parameters::Register + ("Add the fraction of the total volume which is " + "occupied by fractures in the VTK output"); +} + +void VtkDiscreteFractureParams::read() +{ + saturationOutput_ = Parameters::Get(); + mobilityOutput_ = Parameters::Get(); + relativePermeabilityOutput_ = Parameters::Get(); + porosityOutput_ = Parameters::Get(); + intrinsicPermeabilityOutput_ = Parameters::Get(); + volumeFractionOutput_ = Parameters::Get(); + velocityOutput_ = Parameters::Get(); +} + +} // namespace Opm diff --git a/opm/models/io/vtkdiscretefractureparams.hpp b/opm/models/io/vtkdiscretefractureparams.hpp new file mode 100644 index 000000000..7afdedff7 --- /dev/null +++ b/opm/models/io/vtkdiscretefractureparams.hpp @@ -0,0 +1,67 @@ +// -*- 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::VtkDiscreteFractureModule + */ +#ifndef OPM_VTK_DISCRETE_FRACTURE_PARAMS_HPP +#define OPM_VTK_DISCRETE_FRACTURE_PARAMS_HPP + +namespace Opm::Parameters { + +// set default values for what quantities to output +struct VtkWriteFractureSaturations { static constexpr bool value = true; }; +struct VtkWriteFractureMobilities { static constexpr bool value = false; }; +struct VtkWriteFractureRelativePermeabilities { static constexpr bool value = true; }; +struct VtkWriteFracturePorosity { static constexpr bool value = true; }; +struct VtkWriteFractureIntrinsicPermeabilities { static constexpr bool value = false; }; +struct VtkWriteFractureFilterVelocities { static constexpr bool value = false; }; +struct VtkWriteFractureVolumeFraction { static constexpr bool value = true; }; + +} // namespace Opm::Parameters + +namespace Opm { + +/*! + * \brief Struct holding the parameters for VtkDiscreteFractureModule. + */ +struct VtkDiscreteFractureParams +{ + //! \brief Registers the parameters in parameter system. + static void registerParameters(); + + //! \brief Reads the parameter values from the parameter system. + void read(); + + bool saturationOutput_; + bool mobilityOutput_; + bool relativePermeabilityOutput_; + bool porosityOutput_; + bool intrinsicPermeabilityOutput_; + bool volumeFractionOutput_; + bool velocityOutput_; +}; + +} // namespace Opm + +#endif // OPM_VTK_DISCRETE_FRACTURE_MODULE_HPP