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 <opm/material/densead/Math.hpp>
31 
32 #include "vtkmultiwriter.hh"
33 #include "baseoutputmodule.hh"
34 
38 
39 #include <dune/common/fvector.hh>
40 
41 #include <cstdio>
42 
43 namespace Ewoms {
44 namespace Properties {
45 // create new type tag for the VTK multi-phase output
46 NEW_TYPE_TAG(VtkBlackOilSolvent);
47 
48 // create the property tags needed for the solvent output module
49 NEW_PROP_TAG(EnableSolvent);
50 NEW_PROP_TAG(EnableVtkOutput);
51 NEW_PROP_TAG(VtkWriteSolventSaturation);
52 NEW_PROP_TAG(VtkWriteSolventDensity);
53 NEW_PROP_TAG(VtkWriteSolventViscosity);
54 NEW_PROP_TAG(VtkWriteSolventMobility);
55 
56 // set default values for what quantities to output
57 SET_BOOL_PROP(VtkBlackOilSolvent, VtkWriteSolventSaturation, true);
58 SET_BOOL_PROP(VtkBlackOilSolvent, VtkWriteSolventDensity, true);
59 SET_BOOL_PROP(VtkBlackOilSolvent, VtkWriteSolventViscosity, true);
60 SET_BOOL_PROP(VtkBlackOilSolvent, VtkWriteSolventMobility, true);
61 } // namespace Properties
62 } // namespace Ewoms
63 
64 namespace Ewoms {
70 template <class TypeTag>
72 {
74 
75  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
76  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
77  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
78  typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
79  typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
80 
81  static const int vtkFormat = GET_PROP_VALUE(TypeTag, VtkOutputFormat);
83 
84  enum { enableSolvent = GET_PROP_VALUE(TypeTag, EnableSolvent) };
85 
86  typedef typename ParentType::ScalarBuffer ScalarBuffer;
87 
88 public:
89  VtkBlackOilSolventModule(const Simulator& simulator)
90  : ParentType(simulator)
91  { }
92 
97  static void registerParameters()
98  {
99  if (!enableSolvent)
100  return;
101 
102  EWOMS_REGISTER_PARAM(TypeTag, bool, VtkWriteSolventSaturation,
103  "Include the \"saturation\" of the solvent component "
104  "in the VTK output files");
105  EWOMS_REGISTER_PARAM(TypeTag, bool, VtkWriteSolventDensity,
106  "Include the \"density\" of the solvent component "
107  "in the VTK output files");
108  EWOMS_REGISTER_PARAM(TypeTag, bool, VtkWriteSolventViscosity,
109  "Include the \"viscosity\" of the solvent component "
110  "in the VTK output files");
111  EWOMS_REGISTER_PARAM(TypeTag, bool, VtkWriteSolventMobility,
112  "Include the \"mobility\" of the solvent component "
113  "in the VTK output files");
114  }
115 
121  {
122  if (!EWOMS_GET_PARAM(TypeTag, bool, EnableVtkOutput))
123  return;
124 
125  if (!enableSolvent)
126  return;
127 
128  if (solventSaturationOutput_())
129  this->resizeScalarBuffer_(solventSaturation_);
130  if (solventDensityOutput_())
131  this->resizeScalarBuffer_(solventDensity_);
132  if (solventViscosityOutput_())
133  this->resizeScalarBuffer_(solventViscosity_);
134  if (solventMobilityOutput_())
135  this->resizeScalarBuffer_(solventMobility_);
136  }
137 
142  void processElement(const ElementContext& elemCtx)
143  {
144  if (!EWOMS_GET_PARAM(TypeTag, bool, EnableVtkOutput))
145  return;
146 
147  if (!enableSolvent)
148  return;
149 
150  typedef Opm::MathToolbox<Evaluation> Toolbox;
151  for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) {
152  const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0);
153  unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0);
154 
155  if (solventSaturationOutput_())
156  solventSaturation_[globalDofIdx] =
157  Toolbox::scalarValue(intQuants.solventSaturation());
158 
159  if (solventDensityOutput_())
160  solventDensity_[globalDofIdx] =
161  Toolbox::scalarValue(intQuants.solventDensity());
162 
163  if (solventViscosityOutput_())
164  solventViscosity_[globalDofIdx] =
165  Toolbox::scalarValue(intQuants.solventViscosity());
166 
167  if (solventMobilityOutput_())
168  solventMobility_[globalDofIdx] =
169  Toolbox::scalarValue(intQuants.solventMobility());
170  }
171  }
172 
176  void commitBuffers(BaseOutputWriter& baseWriter)
177  {
178  VtkMultiWriter *vtkWriter = dynamic_cast<VtkMultiWriter*>(&baseWriter);
179  if (!vtkWriter)
180  return;
181 
182  if (!enableSolvent)
183  return;
184 
185  if (solventSaturationOutput_())
186  this->commitScalarBuffer_(baseWriter, "saturation_solvent", solventSaturation_);
187 
188  if (solventDensityOutput_())
189  this->commitScalarBuffer_(baseWriter, "density_solvent", solventDensity_);
190 
191  if (solventViscosityOutput_())
192  this->commitScalarBuffer_(baseWriter, "viscosity_solvent", solventViscosity_);
193 
194  if (solventMobilityOutput_())
195  this->commitScalarBuffer_(baseWriter, "mobility_solvent", solventMobility_);
196  }
197 
198 private:
199  static bool solventSaturationOutput_()
200  { return EWOMS_GET_PARAM(TypeTag, bool, VtkWriteSolventSaturation); }
201 
202  static bool solventDensityOutput_()
203  { return EWOMS_GET_PARAM(TypeTag, bool, VtkWriteSolventDensity); }
204 
205  static bool solventViscosityOutput_()
206  { return EWOMS_GET_PARAM(TypeTag, bool, VtkWriteSolventViscosity); }
207 
208  static bool solventMobilityOutput_()
209  { return EWOMS_GET_PARAM(TypeTag, bool, VtkWriteSolventMobility); }
210 
211  ScalarBuffer solventSaturation_;
212  ScalarBuffer solventDensity_;
213  ScalarBuffer solventViscosity_;
214  ScalarBuffer solventMobility_;
215 };
216 } // namespace Ewoms
217 
218 #endif
The base class for all output writers.
Definition: baseoutputwriter.hh:43
#define SET_BOOL_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant boolean value.
Definition: propertysystem.hh:361
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkblackoilsolventmodule.hh:97
void allocBuffers()
Allocate memory for the scalar fields we would like to write to the VTK file.
Definition: vtkblackoilsolventmodule.hh:120
Definition: baseauxiliarymodule.hh:37
Simplifies writing multi-file VTK datasets.
Definition: vtkmultiwriter.hh:63
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:305
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
The base class for writer modules.
#define NEW_TYPE_TAG(...)
Define a new type tag.
Definition: propertysystem.hh:169
VTK output module for the black oil model&#39;s solvent related quantities.
Definition: vtkblackoilsolventmodule.hh:71
void commitBuffers(BaseOutputWriter &baseWriter)
Add all buffers to the VTK output writer.
Definition: vtkblackoilsolventmodule.hh:176
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
Declares the properties required by the black oil model.
This file provides the infrastructure to retrieve run-time parameters.
The base class for writer modules.
Definition: baseoutputmodule.hh:80
void processElement(const ElementContext &elemCtx)
Modify the internal buffers according to the intensive quantities relevant for an element...
Definition: vtkblackoilsolventmodule.hh:142
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
Provides the magic behind the eWoms property system.
void resizeScalarBuffer_(ScalarBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a scalar quantity.
Definition: baseoutputmodule.hh:170
Simplifies writing multi-file VTK datasets.
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247