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  Copyright (C) 2010-2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
26 #ifndef EWOMS_IMMISCIBLE_MODEL_HH
27 #define EWOMS_IMMISCIBLE_MODEL_HH
28 
29 #include <opm/material/localad/Math.hpp>
30 #include "immiscibleproperties.hh"
31 #include "immiscibleindices.hh"
35 #include "immiscibleratevector.hh"
38 
42 #include <opm/material/components/NullComponent.hpp>
43 #include <opm/material/fluidsystems/GasPhase.hpp>
44 #include <opm/material/fluidsystems/LiquidPhase.hpp>
45 #include <opm/material/fluidsystems/SinglePhaseFluidSystem.hpp>
46 #include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
47 
48 #include <dune/common/unused.hh>
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:
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(int 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  int 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(int 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  int nDof = this->numTotalDof();
291  for (int 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(int globalDofIdx, int 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(int globalDofIdx, int 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  int compIdx = eqIdx - Indices::conti0EqIdx;
329  assert(0 <= compIdx && compIdx <= numPhases);
330 #endif
331 
332  // make all kg equal
333  return 1.0;
334  }
335 
337  {
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
void registerOutputModules_()
Definition: multiphasebasemodel.hh:244
VTK output module for quantities which make sense for models which assume thermal equilibrium...
This class provides the data all quantities that are required to calculate the fluxes of the fluid ph...
Represents the primary variables used by the immiscible multi-phase, model.
Implements a boundary vector for the fully implicit multi-phase model which assumes immiscibility...
void registerOutputModules_()
Definition: immisciblemodel.hh:336
std::string eqName(int eqIdx) const
Given an equation index, return a human readable name.
Definition: immisciblemodel.hh:264
VTK output module for quantities which make sense for models which assume thermal equilibrium...
Definition: vtkenergymodule.hh:70
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
std::string primaryVarName(int pvIdx) const
Given an primary variable index, return a human readable name.
Definition: immisciblemodel.hh:239
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:45
void updateBegin()
Called by the update() method before it tries to apply the newton method. This is primary a hook whic...
Definition: immisciblemodel.hh:283
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:485
Scalar eqWeight(int globalDofIdx, int eqIdx) const
Definition: immisciblemodel.hh:320
static std::string name()
Definition: immisciblemodel.hh:233
SET_PROP(NumericModel, ParameterTree)
Set the ParameterTree property.
Definition: basicproperties.hh:117
Implements a vector representing rates of conserved quantities.
Definition: immiscibleratevector.hh:46
Calculates the local residual of the immiscible multi-phase model.
Definition: immisciblelocalresidual.hh:41
Defines the properties required for the immiscible multi-phase model.
This class provides the data all quantities that are required to calculate the fluxes of the fluid ph...
Definition: immiscibleextensivequantities.hh:47
Implements a vector representing rates of conserved quantities.
SET_TYPE_PROP(NumericModel, Scalar, double)
Set the default type of scalar values to double.
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:54
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:73
Definition: baseauxiliarymodule.hh:35
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:145
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
The indices for the isothermal multi-phase model.
Definition: immiscibleindices.hh:40
ImmiscibleModel(Simulator &simulator)
Definition: immisciblemodel.hh:215
A fully-implicit multi-phase flow model which assumes immiscibility of the phases.
Definition: immisciblemodel.hh:55
Implements a boundary vector for the fully implicit multi-phase model which assumes immiscibility...
Definition: immiscibleboundaryratevector.hh:43
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: immisciblemodel.hh:222
NEW_TYPE_TAG(AuxModule)
Scalar primaryVarWeight(int globalDofIdx, int pvIdx) const
Definition: immisciblemodel.hh:303
Represents the primary variables used by the immiscible multi-phase, model.
Definition: immiscibleprimaryvariables.hh:51
SET_BOOL_PROP(FvBaseDiscretization, EnableVtkOutput, true)
Enable the VTK output by default.
#define INHERITS_FROM(...)
Syntactic sugar for NEW_TYPE_TAG.
Definition: propertysystem.hh:229
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkenergymodule.hh:98
Calculates the local residual of the immiscible multi-phase model.
Contains the quantities which are are constant within a finite volume for the immiscible multi-phase ...
Definition: immiscibleintensivequantities.hh:46
Contains the quantities which are are constant within a finite volume for the immiscible multi-phase ...
The indices for the isothermal multi-phase model.
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...