immisciblemodel.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 */
28 #ifndef EWOMS_IMMISCIBLE_MODEL_HH
29 #define EWOMS_IMMISCIBLE_MODEL_HH
30 
31 #include <opm/material/densead/Math.hpp>
32 #include "immiscibleproperties.hh"
33 #include "immiscibleindices.hh"
37 #include "immiscibleratevector.hh"
40 
44 #include <opm/material/components/NullComponent.hpp>
45 #include <opm/material/fluidsystems/GasPhase.hpp>
46 #include <opm/material/fluidsystems/LiquidPhase.hpp>
47 #include <opm/material/fluidsystems/SinglePhaseFluidSystem.hpp>
48 #include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
49 
50 #include <sstream>
51 #include <string>
52 
53 namespace Ewoms {
54 template <class TypeTag>
56 }
57 
58 namespace Ewoms {
59 namespace Properties {
63 NEW_TYPE_TAG(ImmiscibleSinglePhaseModel, INHERITS_FROM(ImmiscibleModel));
65 NEW_TYPE_TAG(ImmiscibleTwoPhaseModel, INHERITS_FROM(ImmiscibleModel));
66 
68 SET_TYPE_PROP(ImmiscibleModel, LocalResidual,
70 
73 
76 
79 
82 
85 
88 
91 
93 SET_BOOL_PROP(ImmiscibleModel, EnableEnergy, false);
94 
96 // set slightly different properties for the single-phase case
98 
100 SET_PROP(ImmiscibleSinglePhaseModel, FluidSystem)
101 { private:
102  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
103  typedef typename GET_PROP_TYPE(TypeTag, Fluid) Fluid;
104 public:
105  typedef Opm::FluidSystems::SinglePhase<Scalar , Fluid> type;
106 };
107 
108 SET_PROP(ImmiscibleSinglePhaseModel, Fluid)
109 {
110 private:
111  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
112 
113 public:
114  typedef Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> > type;
115 };
116 
117 // disable output of a few quantities which make sense in a
118 // multi-phase but not in a single-phase context
119 SET_BOOL_PROP(ImmiscibleSinglePhaseModel, VtkWriteSaturations, false);
120 SET_BOOL_PROP(ImmiscibleSinglePhaseModel, VtkWriteMobilities, false);
121 SET_BOOL_PROP(ImmiscibleSinglePhaseModel, VtkWriteRelativePermeabilities, false);
122 
124 // set slightly different properties for the two-phase case
126 SET_PROP(ImmiscibleTwoPhaseModel, WettingPhase)
127 {
128 private:
129  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
130 
131 public:
132  typedef Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> > type;
133 };
134 
135 SET_PROP(ImmiscibleTwoPhaseModel, NonwettingPhase)
136 {
137 private:
138  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
139 
140 public:
141  typedef Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> > type;
142 };
143 
144 SET_PROP(ImmiscibleTwoPhaseModel, FluidSystem)
145 {
146 private:
147  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
148  typedef typename GET_PROP_TYPE(TypeTag, WettingPhase) WettingPhase;
149  typedef typename GET_PROP_TYPE(TypeTag, NonwettingPhase) NonwettingPhase;
150 
151 public:
152  typedef Opm::FluidSystems::TwoPhaseImmiscible<Scalar, WettingPhase,
153  NonwettingPhase> type;
154 };
155 
156 } // namespace Properties
157 
194 template <class TypeTag>
195 class ImmiscibleModel
196  : public Ewoms::MultiPhaseBaseModel<TypeTag>
197 {
198  typedef Ewoms::MultiPhaseBaseModel<TypeTag> ParentType;
199  typedef typename GET_PROP_TYPE(TypeTag, Model) Implementation;
200  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
201 
202  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
203  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
204  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
205 
206  enum { numComponents = FluidSystem::numComponents };
207 
208 
209 
210  enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases) };
211  enum { enableEnergy = GET_PROP_VALUE(TypeTag, EnableEnergy) };
212  typedef Ewoms::EnergyModule<TypeTag, enableEnergy> EnergyModule;
213 
214 public:
215  ImmiscibleModel(Simulator& simulator)
216  : ParentType(simulator)
217  {}
218 
222  static void registerParameters()
223  {
225 
226  if (enableEnergy)
228  }
229 
233  static std::string name()
234  { return "immiscible"; }
235 
239  std::string primaryVarName(unsigned pvIdx) const
240  {
241  std::string s;
242  if (!(s = EnergyModule::primaryVarName(pvIdx)).empty())
243  return s;
244 
245  std::ostringstream oss;
246 
247  if (pvIdx == Indices::pressure0Idx) {
248  oss << "pressure_" << FluidSystem::phaseName(/*phaseIdx=*/0);
249  }
250  else if (Indices::saturation0Idx <= pvIdx
251  && pvIdx < Indices::saturation0Idx + numPhases - 1) {
252  unsigned phaseIdx = pvIdx - Indices::saturation0Idx;
253  oss << "saturation_" << FluidSystem::phaseName(phaseIdx);
254  }
255  else
256  assert(false);
257 
258  return oss.str();
259  }
260 
264  std::string eqName(unsigned eqIdx) const
265  {
266  std::string s;
267  if (!(s = EnergyModule::eqName(eqIdx)).empty())
268  return s;
269 
270  std::ostringstream oss;
271 
272  if (Indices::conti0EqIdx <= eqIdx && eqIdx < Indices::conti0EqIdx + numComponents)
273  oss << "conti_" << FluidSystem::phaseName(eqIdx - Indices::conti0EqIdx);
274  else
275  assert(false);
276 
277  return oss.str();
278  }
279 
283  void updateBegin()
284  {
285  ParentType::updateBegin();
286 
287  // find the a reference pressure. The first degree of freedom
288  // might correspond to non-interior entities which would lead
289  // to an undefined value, so we have to iterate...
290  size_t nDof = this->numTotalDof();
291  for (unsigned dofIdx = 0; dofIdx < nDof; ++ dofIdx) {
292  if (this->isLocalDof(dofIdx)) {
293  referencePressure_ =
294  this->solution(/*timeIdx=*/0)[dofIdx][/*pvIdx=*/Indices::pressure0Idx];
295  break;
296  }
297  }
298  }
299 
303  Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
304  {
305  assert(referencePressure_ > 0);
306 
307  Scalar tmp = EnergyModule::primaryVarWeight(asImp_(), globalDofIdx, pvIdx);
308  if (tmp > 0)
309  // energy related quantity
310  return tmp;
311  if (Indices::pressure0Idx == pvIdx) {
312  return 10 / referencePressure_;
313  }
314  return 1.0;
315  }
316 
320  Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
321  {
322  Scalar tmp = EnergyModule::eqWeight(asImp_(), globalDofIdx, eqIdx);
323  if (tmp > 0)
324  // energy related equation
325  return tmp;
326 
327 #ifndef NDEBUG
328  unsigned compIdx = eqIdx - Indices::conti0EqIdx;
329  assert(0 <= compIdx && compIdx <= numPhases);
330 #endif
331 
332  // make all kg equal
333  return 1.0;
334  }
335 
336  void registerOutputModules_()
337  {
338  ParentType::registerOutputModules_();
339 
340  if (enableEnergy)
341  this->addOutputModule(new Ewoms::VtkEnergyModule<TypeTag>(this->simulator_));
342  }
343 
344 private:
345  const Implementation& asImp_() const
346  { return *static_cast<const Implementation *>(this); }
347 
348  mutable Scalar referencePressure_;
349 };
350 } // namespace Ewoms
351 
352 #endif
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: immisciblemodel.hh:222
A fully-implicit multi-phase flow model which assumes immiscibility of the phases.
Definition: immisciblemodel.hh:55
#define SET_BOOL_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant boolean value.
Definition: propertysystem.hh:361
Contains the quantities which are are constant within a finite volume for the immiscible multi-phase ...
Contains the quantities which are are constant within a finite volume for the immiscible multi-phase ...
Definition: immiscibleintensivequantities.hh:50
Definition: baseauxiliarymodule.hh:37
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkenergymodule.hh:101
Implements a vector representing rates of conserved quantities.
void updateBegin()
Called by the update() method before it tries to apply the newton method.
Definition: immisciblemodel.hh:283
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:59
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
Implements a vector representing rates of conserved quantities.
Definition: immiscibleratevector.hh:48
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...
The indices for the isothermal multi-phase model.
#define NEW_TYPE_TAG(...)
Define a new type tag.
Definition: propertysystem.hh:169
The indices for the isothermal multi-phase model.
Definition: immiscibleindices.hh:42
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
Implements a boundary vector for the fully implicit multi-phase model which assumes immiscibility...
Definition: immiscibleboundaryratevector.hh:45
#define INHERITS_FROM(...)
Syntactic sugar for NEW_TYPE_TAG.
Definition: propertysystem.hh:230
VTK output module for quantities which make sense for models which assume thermal equilibrium...
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Definition: immisciblemodel.hh:303
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: immisciblemodel.hh:239
Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
Definition: immisciblemodel.hh:320
This class provides the data all quantities that are required to calculate the fluxes of the fluid ph...
Definition: immiscibleextensivequantities.hh:49
#define SET_PROP(EffTypeTagName, PropTagName)
Set a property for a specific type tag.
Definition: propertysystem.hh:297
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition: immisciblemodel.hh:264
This class provides the data all quantities that are required to calculate the fluxes of the fluid ph...
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:147
static std::string name()
Definition: immisciblemodel.hh:233
Defines the properties required for the immiscible multi-phase model.
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:47
VTK output module for quantities which make sense for models which assume thermal equilibrium...
Definition: vtkenergymodule.hh:73
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377
Represents the primary variables used by the immiscible multi-phase, model.
Represents the primary variables used by the immiscible multi-phase, model.
Definition: immiscibleprimaryvariables.hh:54
Implements a boundary vector for the fully implicit multi-phase model which assumes immiscibility...
Calculates the local residual of the immiscible multi-phase model.
Definition: immisciblelocalresidual.hh:45
Calculates the local residual of the immiscible multi-phase model.