25 #ifndef EWOMS_VTK_BLACK_OIL_MODULE_HH
26 #define EWOMS_VTK_BLACK_OIL_MODULE_HH
28 #include <opm/material/localad/Math.hpp>
37 #include <dune/common/fvector.hh>
42 namespace Properties {
55 SET_BOOL_PROP(VtkBlackOil, VtkWriteGasDissolutionFactor,
false);
56 SET_BOOL_PROP(VtkBlackOil, VtkWriteSaturatedOilGasDissolutionFactor,
false);
57 SET_BOOL_PROP(VtkBlackOil, VtkWriteGasFormationVolumeFactor,
false);
58 SET_BOOL_PROP(VtkBlackOil, VtkWriteOilFormationVolumeFactor,
false);
59 SET_BOOL_PROP(VtkBlackOil, VtkWriteOilSaturationPressure,
false);
69 template <
class TypeTag>
75 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
76 typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
77 typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
79 typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
80 typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
82 static const int vtkFormat =
GET_PROP_VALUE(TypeTag, VtkOutputFormat);
85 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
86 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
87 enum { gasCompIdx = FluidSystem::gasCompIdx };
88 enum { oilCompIdx = FluidSystem::oilCompIdx };
94 : ParentType(simulator)
104 "Include the gas dissolution factor (R_s) of the observed oil "
105 "in the VTK output files");
107 "Include the gas dissolution factor (R_s,sat) of gas saturated "
108 "oil in the VTK output files");
110 "Include the gas formation volume factor (B_g) in the "
113 "Include the oil formation volume factor (B_o) of gas saturated "
114 "oil in the VTK output files");
116 "Include the saturation pressure of oil in the "
126 if (gasDissolutionFactorOutput_())
128 if (saturatedOilGasDissolutionFactorOutput_())
130 if (gasFormationVolumeFactorOutput_())
132 if (saturatedOilFormationVolumeFactorOutput_())
134 if (oilSaturationPressureOutput_())
144 typedef Opm::MathToolbox<Evaluation> Toolbox;
146 for (
int dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
147 const auto &fs = elemCtx.intensiveQuantities(dofIdx, 0).fluidState();
148 int globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
149 Scalar po = Toolbox::value(fs.pressure(oilPhaseIdx));
150 Scalar To = Toolbox::value(fs.temperature(oilPhaseIdx));
151 Scalar X_oG = Toolbox::value(fs.massFraction(oilPhaseIdx, gasCompIdx));
152 Scalar X_gO = Toolbox::value(fs.massFraction(gasPhaseIdx, oilCompIdx));
153 int regionIdx = elemCtx.primaryVars(dofIdx, 0).pvtRegionIndex();
154 Scalar rhooRef = FluidSystem::referenceDensity(oilPhaseIdx, regionIdx);
155 Scalar rhogRef = FluidSystem::referenceDensity(gasPhaseIdx, regionIdx);
157 if (gasDissolutionFactorOutput_())
158 gasDissolutionFactor_[globalDofIdx] = X_oG / rhogRef * rhooRef / (1 - X_oG);
159 if (saturatedOilGasDissolutionFactorOutput_())
160 saturatedOilGasDissolutionFactor_[globalDofIdx] =
161 FluidSystem::template gasDissolutionFactor<Scalar>(To, po, regionIdx);
162 if (gasFormationVolumeFactorOutput_())
163 gasFormationVolumeFactor_[globalDofIdx] =
164 FluidSystem::gasFormationVolumeFactor(To, po, X_gO, regionIdx);
165 if (saturatedOilFormationVolumeFactorOutput_())
166 saturatedOilFormationVolumeFactor_[globalDofIdx] =
167 FluidSystem::saturatedOilFormationVolumeFactor(To, po, regionIdx);
168 if (oilSaturationPressureOutput_())
169 oilSaturationPressure_[globalDofIdx] =
170 FluidSystem::oilSaturationPressure(To, X_oG, regionIdx);
179 VtkMultiWriter *vtkWriter =
dynamic_cast<VtkMultiWriter*
>(&baseWriter);
183 if (gasDissolutionFactorOutput_())
185 if (saturatedOilGasDissolutionFactorOutput_())
187 if (gasFormationVolumeFactorOutput_())
189 if (saturatedOilFormationVolumeFactorOutput_())
191 if (oilSaturationPressureOutput_())
196 static bool gasDissolutionFactorOutput_()
197 {
return EWOMS_GET_PARAM(TypeTag,
bool, VtkWriteGasDissolutionFactor); }
199 static bool saturatedOilGasDissolutionFactorOutput_()
200 {
return EWOMS_GET_PARAM(TypeTag,
bool, VtkWriteSaturatedOilGasDissolutionFactor); }
202 static bool gasFormationVolumeFactorOutput_()
203 {
return EWOMS_GET_PARAM(TypeTag,
bool, VtkWriteGasFormationVolumeFactor); }
205 static bool saturatedOilFormationVolumeFactorOutput_()
206 {
return EWOMS_GET_PARAM(TypeTag,
bool, VtkWriteOilFormationVolumeFactor); }
208 static bool oilSaturationPressureOutput_()
209 {
return EWOMS_GET_PARAM(TypeTag,
bool, VtkWriteOilSaturationPressure); }
211 ScalarBuffer gasDissolutionFactor_;
212 ScalarBuffer saturatedOilGasDissolutionFactor_;
213 ScalarBuffer gasFormationVolumeFactor_;
214 ScalarBuffer saturatedOilFormationVolumeFactor_;
215 ScalarBuffer oilSaturationPressure_;
void processElement(const ElementContext &elemCtx)
Modify the internal buffers according to the intensive quantities relevant for an element...
Definition: vtkblackoilmodule.hh:142
void resizeScalarBuffer_(ScalarBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a scalar quantity.
Definition: baseoutputmodule.hh:148
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkblackoilmodule.hh:101
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
VtkBlackOilModule(const Simulator &simulator)
Definition: vtkblackoilmodule.hh:93
NEW_PROP_TAG(Grid)
The type of the DUNE grid.
This file provides the infrastructure to retrieve run-time parameters.
Declares the properties required by the black oil model.
The base class for all output writers.
Definition: baseoutputwriter.hh:41
Simplifies writing multi-file VTK datasets.
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:73
Definition: baseauxiliarymodule.hh:35
void commitBuffers(BaseOutputWriter &baseWriter)
Add all buffers to the VTK output writer.
Definition: vtkblackoilmodule.hh:177
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:64
void allocBuffers()
Allocate memory for the scalar fields we would like to write to the VTK file.
Definition: vtkblackoilmodule.hh:124
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:283
Provides the magic behind the eWoms property system.
The base class for writer modules.
SET_BOOL_PROP(FvBaseDiscretization, EnableVtkOutput, true)
Enable the VTK output by default.
VTK output module for the black oil model's parameters.
Definition: vtkblackoilmodule.hh:70
The base class for writer modules.
Definition: baseoutputmodule.hh:71
Simplifies writing multi-file VTK datasets.
Definition: vtkmultiwriter.hh:61
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:95
BaseOutputWriter::ScalarBuffer ScalarBuffer
Definition: baseoutputmodule.hh:90