vtkblackoilmodule.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_MODULE_HH
28#define EWOMS_VTK_BLACK_OIL_MODULE_HH
29
30#include "vtkmultiwriter.hh"
31#include "baseoutputmodule.hh"
32
33#include <dune/common/fvector.hh>
34
35#include <opm/material/densead/Math.hpp>
36
38
40
43
44namespace Opm::Parameters {
45
46// set default values for what quantities to output
47struct VtkWriteGasDissolutionFactor { static constexpr bool value = false; };
48struct VtkWriteOilVaporizationFactor { static constexpr bool value = false; };
49struct VtkWriteOilFormationVolumeFactor { static constexpr bool value = false; };
50struct VtkWriteGasFormationVolumeFactor { static constexpr bool value = false; };
51struct VtkWriteWaterFormationVolumeFactor { static constexpr bool value = false; };
52struct VtkWriteOilSaturationPressure { static constexpr bool value = false; };
53struct VtkWriteGasSaturationPressure { static constexpr bool value = false; };
54struct VtkWriteSaturationRatios { static constexpr bool value = false; };
55struct VtkWriteSaturatedOilGasDissolutionFactor { static constexpr bool value = false; };
56struct VtkWriteSaturatedGasOilVaporizationFactor { static constexpr bool value = false; };
57struct VtkWritePrimaryVarsMeaning { static constexpr bool value = false; };
58
59} // namespace Opm::Parameters
60
61namespace Opm {
67template <class TypeTag>
68class VtkBlackOilModule : public BaseOutputModule<TypeTag>
69{
71
76
79
80 static const int vtkFormat = getPropValue<TypeTag, Properties::VtkOutputFormat>();
82
83 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
84 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
85 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
86
87 enum { gasCompIdx = FluidSystem::gasCompIdx };
88 enum { oilCompIdx = FluidSystem::oilCompIdx };
89 enum { waterCompIdx = FluidSystem::waterCompIdx };
90
92
93public:
94 VtkBlackOilModule(const Simulator& simulator)
95 : ParentType(simulator)
96 { }
97
102 static void registerParameters()
103 {
104 Parameters::Register<Parameters::VtkWriteGasDissolutionFactor>
105 ("Include the gas dissolution factor (R_s) of the observed oil "
106 "in the VTK output files");
107 Parameters::Register<Parameters::VtkWriteOilVaporizationFactor>
108 ("Include the oil vaporization factor (R_v) of the observed gas "
109 "in the VTK output files");
110 Parameters::Register<Parameters::VtkWriteOilFormationVolumeFactor>
111 ("Include the oil formation volume factor (B_o) in the VTK output files");
112 Parameters::Register<Parameters::VtkWriteGasFormationVolumeFactor>
113 ("Include the gas formation volume factor (B_g) in the "
114 "VTK output files");
115 Parameters::Register<Parameters::VtkWriteWaterFormationVolumeFactor>
116 ("Include the water formation volume factor (B_w) in the "
117 "VTK output files");
118 Parameters::Register<Parameters::VtkWriteOilSaturationPressure>
119 ("Include the saturation pressure of oil (p_o,sat) in the "
120 "VTK output files");
121 Parameters::Register<Parameters::VtkWriteGasSaturationPressure>
122 ("Include the saturation pressure of gas (p_g,sat) in the "
123 "VTK output files");
124 Parameters::Register<Parameters::VtkWriteSaturatedOilGasDissolutionFactor>
125 ("Include the gas dissolution factor (R_s,sat) of gas saturated "
126 "oil in the VTK output files");
127 Parameters::Register<Parameters::VtkWriteSaturatedGasOilVaporizationFactor>
128 ("Include the oil vaporization factor (R_v,sat) of oil saturated "
129 "gas in the VTK output files");
130 Parameters::Register<Parameters::VtkWriteSaturationRatios>
131 ("Write the ratio of the actually and maximum dissolved component of "
132 "the mixtures");
133 Parameters::Register<Parameters::VtkWritePrimaryVarsMeaning>
134 ("Include how the primary variables should be interpreted to the "
135 "VTK output files");
136 }
137
143 {
144 if (gasDissolutionFactorOutput_())
145 this->resizeScalarBuffer_(gasDissolutionFactor_);
146 if (oilVaporizationFactorOutput_())
147 this->resizeScalarBuffer_(oilVaporizationFactor_);
148 if (oilFormationVolumeFactorOutput_())
149 this->resizeScalarBuffer_(oilFormationVolumeFactor_);
150 if (gasFormationVolumeFactorOutput_())
151 this->resizeScalarBuffer_(gasFormationVolumeFactor_);
152 if (waterFormationVolumeFactorOutput_())
153 this->resizeScalarBuffer_(waterFormationVolumeFactor_);
154 if (oilSaturationPressureOutput_())
155 this->resizeScalarBuffer_(oilSaturationPressure_);
156 if (gasSaturationPressureOutput_())
157 this->resizeScalarBuffer_(gasSaturationPressure_);
158 if (saturatedOilGasDissolutionFactorOutput_())
159 this->resizeScalarBuffer_(saturatedOilGasDissolutionFactor_);
160 if (saturatedGasOilVaporizationFactorOutput_())
161 this->resizeScalarBuffer_(saturatedGasOilVaporizationFactor_);
162 if (saturationRatiosOutput_()) {
163 this->resizeScalarBuffer_(oilSaturationRatio_);
164 this->resizeScalarBuffer_(gasSaturationRatio_);
165 }
166 if (primaryVarsMeaningOutput_()) {
167 this->resizeScalarBuffer_(primaryVarsMeaningPressure_);
168 this->resizeScalarBuffer_(primaryVarsMeaningWater_);
169 this->resizeScalarBuffer_(primaryVarsMeaningGas_);
170 }
171 }
172
177 void processElement(const ElementContext& elemCtx)
178 {
179 if (!Parameters::Get<Parameters::EnableVtkOutput>()) {
180 return;
181 }
182
183 for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) {
184 const auto& fs = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState();
185 using FluidState = typename std::remove_const<typename std::remove_reference<decltype(fs)>::type>::type;
186 unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0);
187
188 const auto& primaryVars = elemCtx.primaryVars(dofIdx, /*timeIdx=*/0);
189
190 unsigned pvtRegionIdx = elemCtx.primaryVars(dofIdx, /*timeIdx=*/0).pvtRegionIndex();
191 Scalar SoMax = 0.0;
192 if (FluidSystem::phaseIsActive(oilPhaseIdx))
193 SoMax = std::max(getValue(fs.saturation(oilPhaseIdx)),
194 elemCtx.problem().maxOilSaturation(globalDofIdx));
195
196 if (FluidSystem::phaseIsActive(gasPhaseIdx) && FluidSystem::phaseIsActive(oilPhaseIdx)) {
197 Scalar x_oG = getValue(fs.moleFraction(oilPhaseIdx, gasCompIdx));
198 Scalar x_gO = getValue(fs.moleFraction(gasPhaseIdx, oilCompIdx));
199 Scalar X_oG = getValue(fs.massFraction(oilPhaseIdx, gasCompIdx));
200 Scalar X_gO = getValue(fs.massFraction(gasPhaseIdx, oilCompIdx));
201 Scalar Rs = FluidSystem::convertXoGToRs(X_oG, pvtRegionIdx);
202 Scalar Rv = FluidSystem::convertXgOToRv(X_gO, pvtRegionIdx);
203
204 Scalar RsSat =
205 FluidSystem::template saturatedDissolutionFactor<FluidState, Scalar>(fs,
206 oilPhaseIdx,
207 pvtRegionIdx,
208 SoMax);
209 Scalar X_oG_sat = FluidSystem::convertRsToXoG(RsSat, pvtRegionIdx);
210 Scalar x_oG_sat = FluidSystem::convertXoGToxoG(X_oG_sat, pvtRegionIdx);
211
212 Scalar RvSat =
213 FluidSystem::template saturatedDissolutionFactor<FluidState, Scalar>(fs,
214 gasPhaseIdx,
215 pvtRegionIdx,
216 SoMax);
217 Scalar X_gO_sat = FluidSystem::convertRvToXgO(RvSat, pvtRegionIdx);
218 Scalar x_gO_sat = FluidSystem::convertXgOToxgO(X_gO_sat, pvtRegionIdx);
219 if (gasDissolutionFactorOutput_())
220 gasDissolutionFactor_[globalDofIdx] = Rs;
221 if (oilVaporizationFactorOutput_())
222 oilVaporizationFactor_[globalDofIdx] = Rv;
223 if (oilSaturationPressureOutput_())
224 oilSaturationPressure_[globalDofIdx] =
225 FluidSystem::template saturationPressure<FluidState, Scalar>(fs, oilPhaseIdx, pvtRegionIdx);
226 if (gasSaturationPressureOutput_())
227 gasSaturationPressure_[globalDofIdx] =
228 FluidSystem::template saturationPressure<FluidState, Scalar>(fs, gasPhaseIdx, pvtRegionIdx);
229 if (saturatedOilGasDissolutionFactorOutput_())
230 saturatedOilGasDissolutionFactor_[globalDofIdx] = RsSat;
231 if (saturatedGasOilVaporizationFactorOutput_())
232 saturatedGasOilVaporizationFactor_[globalDofIdx] = RvSat;
233 if (saturationRatiosOutput_()) {
234 if (x_oG_sat <= 0.0)
235 oilSaturationRatio_[globalDofIdx] = 1.0;
236 else
237 oilSaturationRatio_[globalDofIdx] = x_oG / x_oG_sat;
238
239 if (x_gO_sat <= 0.0)
240 gasSaturationRatio_[globalDofIdx] = 1.0;
241 else
242 gasSaturationRatio_[globalDofIdx] = x_gO / x_gO_sat;
243 }
244 }
245 if (oilFormationVolumeFactorOutput_())
246 oilFormationVolumeFactor_[globalDofIdx] =
247 1.0/FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(fs, oilPhaseIdx, pvtRegionIdx);
248 if (gasFormationVolumeFactorOutput_())
249 gasFormationVolumeFactor_[globalDofIdx] =
250 1.0/FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(fs, gasPhaseIdx, pvtRegionIdx);
251 if (waterFormationVolumeFactorOutput_())
252 waterFormationVolumeFactor_[globalDofIdx] =
253 1.0/FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(fs, waterPhaseIdx, pvtRegionIdx);
254
255 if (primaryVarsMeaningOutput_()) {
256 primaryVarsMeaningWater_[globalDofIdx] =
257 static_cast<int>(primaryVars.primaryVarsMeaningWater());
258 primaryVarsMeaningGas_[globalDofIdx] =
259 static_cast<int>(primaryVars.primaryVarsMeaningGas());
260 primaryVarsMeaningPressure_[globalDofIdx] =
261 static_cast<int>(primaryVars.primaryVarsMeaningPressure());
262 }
263 }
264 }
265
270 {
271 VtkMultiWriter *vtkWriter = dynamic_cast<VtkMultiWriter*>(&baseWriter);
272 if (!vtkWriter)
273 return;
274
275 if (gasDissolutionFactorOutput_())
276 this->commitScalarBuffer_(baseWriter, "R_s", gasDissolutionFactor_);
277 if (oilVaporizationFactorOutput_())
278 this->commitScalarBuffer_(baseWriter, "R_v", oilVaporizationFactor_);
279 if (oilFormationVolumeFactorOutput_())
280 this->commitScalarBuffer_(baseWriter, "B_o", oilFormationVolumeFactor_);
281 if (gasFormationVolumeFactorOutput_())
282 this->commitScalarBuffer_(baseWriter, "B_g", gasFormationVolumeFactor_);
283 if (waterFormationVolumeFactorOutput_())
284 this->commitScalarBuffer_(baseWriter, "B_w", waterFormationVolumeFactor_);
285 if (oilSaturationPressureOutput_())
286 this->commitScalarBuffer_(baseWriter, "p_o,sat", oilSaturationPressure_);
287 if (gasSaturationPressureOutput_())
288 this->commitScalarBuffer_(baseWriter, "p_g,sat", gasSaturationPressure_);
289 if (saturatedOilGasDissolutionFactorOutput_())
290 this->commitScalarBuffer_(baseWriter, "R_s,sat", saturatedOilGasDissolutionFactor_);
291 if (saturatedGasOilVaporizationFactorOutput_())
292 this->commitScalarBuffer_(baseWriter, "R_v,sat", saturatedGasOilVaporizationFactor_);
293 if (saturationRatiosOutput_()) {
294 this->commitScalarBuffer_(baseWriter, "saturation ratio_oil", oilSaturationRatio_);
295 this->commitScalarBuffer_(baseWriter, "saturation ratio_gas", gasSaturationRatio_);
296 }
297
298 if (primaryVarsMeaningOutput_()) {
299 this->commitScalarBuffer_(baseWriter, "primary vars meaning water", primaryVarsMeaningWater_);
300 this->commitScalarBuffer_(baseWriter, "primary vars meaning gas", primaryVarsMeaningGas_);
301 this->commitScalarBuffer_(baseWriter, "primary vars meaning pressure", primaryVarsMeaningPressure_);
302 }
303 }
304
305private:
306 static bool gasDissolutionFactorOutput_()
307 {
308 static bool val = Parameters::Get<Parameters::VtkWriteGasDissolutionFactor>();
309 return val;
310 }
311
312 static bool oilVaporizationFactorOutput_()
313 {
314 static bool val = Parameters::Get<Parameters::VtkWriteOilVaporizationFactor>();
315 return val;
316 }
317
318 static bool oilFormationVolumeFactorOutput_()
319 {
320 static bool val = Parameters::Get<Parameters::VtkWriteOilFormationVolumeFactor>();
321 return val;
322 }
323
324 static bool gasFormationVolumeFactorOutput_()
325 {
326 static bool val = Parameters::Get<Parameters::VtkWriteGasFormationVolumeFactor>();
327 return val;
328 }
329
330 static bool waterFormationVolumeFactorOutput_()
331 {
332 static bool val = Parameters::Get<Parameters::VtkWriteWaterFormationVolumeFactor>();
333 return val;
334 }
335
336 static bool oilSaturationPressureOutput_()
337 {
338 static bool val = Parameters::Get<Parameters::VtkWriteOilSaturationPressure>();
339 return val;
340 }
341
342 static bool gasSaturationPressureOutput_()
343 {
344 static bool val = Parameters::Get<Parameters::VtkWriteGasSaturationPressure>();
345 return val;
346 }
347
348 static bool saturatedOilGasDissolutionFactorOutput_()
349 {
350 static bool val = Parameters::Get<Parameters::VtkWriteSaturatedOilGasDissolutionFactor>();
351 return val;
352 }
353
354 static bool saturatedGasOilVaporizationFactorOutput_()
355 {
356 static bool val = Parameters::Get<Parameters::VtkWriteSaturatedGasOilVaporizationFactor>();
357 return val;
358 }
359
360 static bool saturationRatiosOutput_()
361 {
362 static bool val = Parameters::Get<Parameters::VtkWriteSaturationRatios>();
363 return val;
364 }
365
366 static bool primaryVarsMeaningOutput_()
367 {
368 static bool val = Parameters::Get<Parameters::VtkWritePrimaryVarsMeaning>();
369 return val;
370 }
371
372 ScalarBuffer gasDissolutionFactor_;
373 ScalarBuffer oilVaporizationFactor_;
374 ScalarBuffer oilFormationVolumeFactor_;
375 ScalarBuffer gasFormationVolumeFactor_;
376 ScalarBuffer waterFormationVolumeFactor_;
377 ScalarBuffer oilSaturationPressure_;
378 ScalarBuffer gasSaturationPressure_;
379
380 ScalarBuffer saturatedOilGasDissolutionFactor_;
381 ScalarBuffer saturatedGasOilVaporizationFactor_;
382 ScalarBuffer oilSaturationRatio_;
383 ScalarBuffer gasSaturationRatio_;
384
385 ScalarBuffer primaryVarsMeaningPressure_;
386 ScalarBuffer primaryVarsMeaningWater_;
387 ScalarBuffer primaryVarsMeaningGas_;
388};
389
390} // namespace Opm
391
392#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 parameters.
Definition: vtkblackoilmodule.hh:69
void processElement(const ElementContext &elemCtx)
Modify the internal buffers according to the intensive quantities relevant for an element.
Definition: vtkblackoilmodule.hh:177
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkblackoilmodule.hh:102
void commitBuffers(BaseOutputWriter &baseWriter)
Add all buffers to the VTK output writer.
Definition: vtkblackoilmodule.hh:269
VtkBlackOilModule(const Simulator &simulator)
Definition: vtkblackoilmodule.hh:94
void allocBuffers()
Allocate memory for the scalar fields we would like to write to the VTK file.
Definition: vtkblackoilmodule.hh:142
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: vtkblackoilmodule.hh:47
static constexpr bool value
Definition: vtkblackoilmodule.hh:47
Definition: vtkblackoilmodule.hh:50
static constexpr bool value
Definition: vtkblackoilmodule.hh:50
Definition: vtkblackoilmodule.hh:53
static constexpr bool value
Definition: vtkblackoilmodule.hh:53
Definition: vtkblackoilmodule.hh:49
static constexpr bool value
Definition: vtkblackoilmodule.hh:49
Definition: vtkblackoilmodule.hh:52
static constexpr bool value
Definition: vtkblackoilmodule.hh:52
Definition: vtkblackoilmodule.hh:48
static constexpr bool value
Definition: vtkblackoilmodule.hh:48
Definition: vtkblackoilmodule.hh:57
static constexpr bool value
Definition: vtkblackoilmodule.hh:57
static constexpr bool value
Definition: vtkblackoilmodule.hh:56
static constexpr bool value
Definition: vtkblackoilmodule.hh:55
Definition: vtkblackoilmodule.hh:54
static constexpr bool value
Definition: vtkblackoilmodule.hh:54
Definition: vtkblackoilmodule.hh:51
static constexpr bool value
Definition: vtkblackoilmodule.hh:51