vtkblackoilsolventmodule.hh
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 EWOMS_VTK_BLACK_OIL_SOLVENT_MODULE_HH
28#define EWOMS_VTK_BLACK_OIL_SOLVENT_MODULE_HH
29
30#include <dune/common/fvector.hh>
31
32#include <opm/material/densead/Math.hpp>
33
35
37
40
43
44namespace Opm::Parameters {
45
46// set default values for what quantities to output
47struct VtkWriteSolventSaturation { static constexpr bool value = true; };
48struct VtkWriteSolventRsw { static constexpr bool value = true; };
49struct VtkWriteSolventDensity { static constexpr bool value = true; };
50struct VtkWriteSolventViscosity { static constexpr bool value = true; };
51struct VtkWriteSolventMobility { static constexpr bool value = true; };
52
53} // namespace Opm::Properties
54
55namespace Opm {
61template <class TypeTag>
63{
65
71
72 static const int vtkFormat = getPropValue<TypeTag, Properties::VtkOutputFormat>();
74
75 enum { enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>() };
76
78
79public:
80 VtkBlackOilSolventModule(const Simulator& simulator)
81 : ParentType(simulator)
82 { }
83
88 static void registerParameters()
89 {
90 if (!enableSolvent)
91 return;
92
93 Parameters::Register<Parameters::VtkWriteSolventSaturation>
94 ("Include the \"saturation\" of the solvent component "
95 "in the VTK output files");
96 Parameters::Register<Parameters::VtkWriteSolventRsw>
97 ("Include the \"dissolved volume in water\" of the solvent component "
98 "in the VTK output files");
99 Parameters::Register<Parameters::VtkWriteSolventDensity>
100 ("Include the \"density\" of the solvent component "
101 "in the VTK output files");
102 Parameters::Register<Parameters::VtkWriteSolventViscosity>
103 ("Include the \"viscosity\" of the solvent component "
104 "in the VTK output files");
105 Parameters::Register<Parameters::VtkWriteSolventMobility>
106 ("Include the \"mobility\" of the solvent component "
107 "in the VTK output files");
108 }
109
115 {
116 if (!Parameters::Get<Parameters::EnableVtkOutput>()) {
117 return;
118 }
119
120 if (!enableSolvent)
121 return;
122
123 if (solventSaturationOutput_())
124 this->resizeScalarBuffer_(solventSaturation_);
125 if (solventRswOutput_())
126 this->resizeScalarBuffer_(solventRsw_);
127 if (solventDensityOutput_())
128 this->resizeScalarBuffer_(solventDensity_);
129 if (solventViscosityOutput_())
130 this->resizeScalarBuffer_(solventViscosity_);
131 if (solventMobilityOutput_())
132 this->resizeScalarBuffer_(solventMobility_);
133 }
134
139 void processElement(const ElementContext& elemCtx)
140 {
141 if (!Parameters::Get<Parameters::EnableVtkOutput>()) {
142 return;
143 }
144
145 if (!enableSolvent)
146 return;
147
148 using Toolbox = MathToolbox<Evaluation>;
149 for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) {
150 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0);
151 unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0);
152
153 if (solventSaturationOutput_())
154 solventSaturation_[globalDofIdx] =
155 Toolbox::scalarValue(intQuants.solventSaturation());
156
157 if (solventRswOutput_())
158 solventRsw_[globalDofIdx] =
159 Toolbox::scalarValue(intQuants.rsSolw());
160
161 if (solventDensityOutput_())
162 solventDensity_[globalDofIdx] =
163 Toolbox::scalarValue(intQuants.solventDensity());
164
165 if (solventViscosityOutput_())
166 solventViscosity_[globalDofIdx] =
167 Toolbox::scalarValue(intQuants.solventViscosity());
168
169 if (solventMobilityOutput_())
170 solventMobility_[globalDofIdx] =
171 Toolbox::scalarValue(intQuants.solventMobility());
172 }
173 }
174
179 {
180 VtkMultiWriter *vtkWriter = dynamic_cast<VtkMultiWriter*>(&baseWriter);
181 if (!vtkWriter)
182 return;
183
184 if (!enableSolvent)
185 return;
186
187 if (solventSaturationOutput_())
188 this->commitScalarBuffer_(baseWriter, "saturation_solvent", solventSaturation_);
189
190 if (solventRswOutput_())
191 this->commitScalarBuffer_(baseWriter, "dissolved_solvent", solventRsw_);
192
193 if (solventDensityOutput_())
194 this->commitScalarBuffer_(baseWriter, "density_solvent", solventDensity_);
195
196 if (solventViscosityOutput_())
197 this->commitScalarBuffer_(baseWriter, "viscosity_solvent", solventViscosity_);
198
199 if (solventMobilityOutput_())
200 this->commitScalarBuffer_(baseWriter, "mobility_solvent", solventMobility_);
201 }
202
203private:
204 static bool solventSaturationOutput_()
205 {
206 static bool val = Parameters::Get<Parameters::VtkWriteSolventSaturation>();
207 return val;
208 }
209
210 static bool solventRswOutput_()
211 {
212 static bool val = Parameters::Get<Parameters::VtkWriteSolventRsw>();
213 return val;
214 }
215
216 static bool solventDensityOutput_()
217 {
218 static bool val = Parameters::Get<Parameters::VtkWriteSolventDensity>();
219 return val;
220 }
221
222 static bool solventViscosityOutput_()
223 {
224 static bool val = Parameters::Get<Parameters::VtkWriteSolventViscosity>();
225 return val;
226 }
227
228 static bool solventMobilityOutput_()
229 {
230 static bool val = Parameters::Get<Parameters::VtkWriteSolventMobility>();
231 return val;
232 }
233
234 ScalarBuffer solventSaturation_;
235 ScalarBuffer solventRsw_;
236 ScalarBuffer solventDensity_;
237 ScalarBuffer solventViscosity_;
238 ScalarBuffer solventMobility_;
239};
240
241} // namespace Opm
242
243#endif
Declares the properties required by the black oil model.
The base class for writer modules.
Definition: baseoutputmodule.hh:67
BaseOutputWriter::ScalarBuffer ScalarBuffer
Definition: baseoutputmodule.hh:85
void commitScalarBuffer_(BaseOutputWriter &baseWriter, const char *name, ScalarBuffer &buffer, BufferType bufferType=DofBuffer)
Add a buffer containing scalar quantities to the result file.
Definition: baseoutputmodule.hh:244
void resizeScalarBuffer_(ScalarBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a scalar quantity.
Definition: baseoutputmodule.hh:156
The base class for all output writers.
Definition: baseoutputwriter.hh:44
VTK output module for the black oil model's solvent related quantities.
Definition: vtkblackoilsolventmodule.hh:63
void commitBuffers(BaseOutputWriter &baseWriter)
Add all buffers to the VTK output writer.
Definition: vtkblackoilsolventmodule.hh:178
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkblackoilsolventmodule.hh:88
void processElement(const ElementContext &elemCtx)
Modify the internal buffers according to the intensive quantities relevant for an element.
Definition: vtkblackoilsolventmodule.hh:139
VtkBlackOilSolventModule(const Simulator &simulator)
Definition: vtkblackoilsolventmodule.hh:80
void allocBuffers()
Allocate memory for the scalar fields we would like to write to the VTK file.
Definition: vtkblackoilsolventmodule.hh:114
Simplifies writing multi-file VTK datasets.
Definition: vtkmultiwriter.hh:66
Declare the properties used by the infrastructure code of the finite volume discretizations.
Definition: blackoilnewtonmethodparameters.hh:31
Definition: blackoilboundaryratevector.hh:37
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:235
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
Definition: vtkblackoilsolventmodule.hh:49
static constexpr bool value
Definition: vtkblackoilsolventmodule.hh:49
Definition: vtkblackoilsolventmodule.hh:51
static constexpr bool value
Definition: vtkblackoilsolventmodule.hh:51
Definition: vtkblackoilsolventmodule.hh:48
static constexpr bool value
Definition: vtkblackoilsolventmodule.hh:48
Definition: vtkblackoilsolventmodule.hh:47
static constexpr bool value
Definition: vtkblackoilsolventmodule.hh:47
Definition: vtkblackoilsolventmodule.hh:50
static constexpr bool value
Definition: vtkblackoilsolventmodule.hh:50