vtkblackoilsolventmodule.hpp
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
27#ifndef OPM_VTK_BLACK_OIL_SOLVENT_MODULE_HPP
28#define OPM_VTK_BLACK_OIL_SOLVENT_MODULE_HPP
29
30#include <dune/common/fvector.hh>
31
32#include <opm/material/densead/Math.hpp>
33
35
37
41
44
45namespace Opm {
46
52template <class TypeTag>
54{
56
62
63 static constexpr auto vtkFormat = getPropValue<TypeTag, Properties::VtkOutputFormat>();
65
66 enum { enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>() };
67
68 using BufferType = typename ParentType::BufferType;
70
71public:
72 explicit VtkBlackOilSolventModule(const Simulator& simulator)
73 : ParentType(simulator)
74 {
75 if constexpr (enableSolvent) {
76 params_.read();
77 }
78 }
79
84 static void registerParameters()
85 {
86 if constexpr (enableSolvent) {
88 }
89 }
90
95 void allocBuffers() override
96 {
97 if constexpr (enableSolvent) {
98 if (!Parameters::Get<Parameters::EnableVtkOutput>()) {
99 return;
100 }
101
102 if (params_.solventSaturationOutput_) {
103 this->resizeScalarBuffer_(solventSaturation_, BufferType::Dof);
104 }
105 if (params_.solventRswOutput_) {
106 this->resizeScalarBuffer_(solventRsw_, BufferType::Dof);
107 }
108 if (params_.solventDensityOutput_) {
109 this->resizeScalarBuffer_(solventDensity_, BufferType::Dof);
110 }
111 if (params_.solventViscosityOutput_) {
112 this->resizeScalarBuffer_(solventViscosity_, BufferType::Dof);
113 }
114 if (params_.solventMobilityOutput_) {
115 this->resizeScalarBuffer_(solventMobility_, BufferType::Dof);
116 }
117 }
118 }
119
124 void processElement(const ElementContext& elemCtx) override
125 {
126 if constexpr (enableSolvent) {
127 if (!Parameters::Get<Parameters::EnableVtkOutput>()) {
128 return;
129 }
130
131 using Toolbox = MathToolbox<Evaluation>;
132 for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) {
133 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0);
134 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0);
135
136 if (params_.solventSaturationOutput_) {
137 solventSaturation_[globalDofIdx] =
138 Toolbox::scalarValue(intQuants.solventSaturation());
139 }
140
141 if (params_.solventRswOutput_) {
142 solventRsw_[globalDofIdx] =
143 Toolbox::scalarValue(intQuants.rsSolw());
144 }
145
146 if (params_.solventDensityOutput_) {
147 solventDensity_[globalDofIdx] =
148 Toolbox::scalarValue(intQuants.solventDensity());
149 }
150
151 if (params_.solventViscosityOutput_) {
152 solventViscosity_[globalDofIdx] =
153 Toolbox::scalarValue(intQuants.solventViscosity());
154 }
155
156 if (params_.solventMobilityOutput_) {
157 solventMobility_[globalDofIdx] =
158 Toolbox::scalarValue(intQuants.solventMobility());
159 }
160 }
161 }
162 }
163
167 void commitBuffers(BaseOutputWriter& baseWriter) override
168 {
169 if constexpr (enableSolvent) {
170 if (!dynamic_cast<VtkMultiWriter*>(&baseWriter)) {
171 return;
172 }
173
174 if (params_.solventSaturationOutput_) {
175 this->commitScalarBuffer_(baseWriter, "saturation_solvent",
176 solventSaturation_, BufferType::Dof);
177 }
178
179 if (params_.solventRswOutput_) {
180 this->commitScalarBuffer_(baseWriter, "dissolved_solvent",
181 solventRsw_, BufferType::Dof);
182 }
183
184 if (params_.solventDensityOutput_) {
185 this->commitScalarBuffer_(baseWriter, "density_solvent",
186 solventDensity_, BufferType::Dof);
187 }
188
189 if (params_.solventViscosityOutput_) {
190 this->commitScalarBuffer_(baseWriter, "viscosity_solvent",
191 solventViscosity_, BufferType::Dof);
192 }
193
194 if (params_.solventMobilityOutput_) {
195 this->commitScalarBuffer_(baseWriter, "mobility_solvent",
196 solventMobility_, BufferType::Dof);
197 }
198 }
199 }
200
201private:
202 VtkBlackOilSolventParams params_{};
203 ScalarBuffer solventSaturation_{};
204 ScalarBuffer solventRsw_{};
205 ScalarBuffer solventDensity_{};
206 ScalarBuffer solventViscosity_{};
207 ScalarBuffer solventMobility_{};
208};
209
210} // namespace Opm
211
212#endif // OPM_VTK_BLACK_OIL_SOLVENT_MODULE_HPP
Declares the properties required by the black oil model.
The base class for writer modules.
Definition: baseoutputmodule.hh:68
BaseOutputWriter::ScalarBuffer ScalarBuffer
Definition: baseoutputmodule.hh:86
void resizeScalarBuffer_(ScalarBuffer &buffer, BufferType bufferType)
Allocate the space for a buffer storing a scalar quantity.
Definition: baseoutputmodule.hh:157
BufferType
Definition: baseoutputmodule.hh:143
void commitScalarBuffer_(BaseOutputWriter &baseWriter, const char *name, ScalarBuffer &buffer, BufferType bufferType)
Add a buffer containing scalar quantities to the result file.
Definition: baseoutputmodule.hh:238
The base class for all output writers.
Definition: baseoutputwriter.hh:46
VTK output module for the black oil model's solvent related quantities.
Definition: vtkblackoilsolventmodule.hpp:54
void processElement(const ElementContext &elemCtx) override
Modify the internal buffers according to the intensive quantities relevant for an element.
Definition: vtkblackoilsolventmodule.hpp:124
void allocBuffers() override
Allocate memory for the scalar fields we would like to write to the VTK file.
Definition: vtkblackoilsolventmodule.hpp:95
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkblackoilsolventmodule.hpp:84
void commitBuffers(BaseOutputWriter &baseWriter) override
Add all buffers to the VTK output writer.
Definition: vtkblackoilsolventmodule.hpp:167
VtkBlackOilSolventModule(const Simulator &simulator)
Definition: vtkblackoilsolventmodule.hpp:72
Simplifies writing multi-file VTK datasets.
Definition: vtkmultiwriter.hh:65
Declare the properties used by the infrastructure code of the finite volume discretizations.
Definition: blackoilboundaryratevector.hh:39
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
Struct holding the parameters for VtkBlackoilPolymerModule.
Definition: vtkblackoilsolventparams.hpp:47
bool solventMobilityOutput_
Definition: vtkblackoilsolventparams.hpp:58
bool solventDensityOutput_
Definition: vtkblackoilsolventparams.hpp:56
static void registerParameters()
Registers the parameters in parameter system.
bool solventViscosityOutput_
Definition: vtkblackoilsolventparams.hpp:57
bool solventSaturationOutput_
Definition: vtkblackoilsolventparams.hpp:54
bool solventRswOutput_
Definition: vtkblackoilsolventparams.hpp:55
void read()
Reads the parameter values from the parameter system.