All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
richardsmodel.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_RICHARDS_MODEL_HH
29 #define EWOMS_RICHARDS_MODEL_HH
30 
31 #include <opm/material/densead/Math.hpp>
32 
33 #include "richardsproperties.hh"
34 #include "richardsindices.hh"
35 #include "richardslocalresidual.hh"
37 #include "richardsratevector.hh"
41 #include "richardsnewtonmethod.hh"
42 
44 
45 #include <opm/material/components/NullComponent.hpp>
46 #include <opm/material/fluidsystems/LiquidPhase.hpp>
47 #include <opm/material/fluidsystems/GasPhase.hpp>
48 #include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
49 #include <opm/common/Unused.hpp>
50 
51 #include <sstream>
52 #include <string>
53 
54 namespace Ewoms {
55 template <class TypeTag>
57 }
58 
59 namespace Ewoms {
60 namespace Properties {
63 
65 SET_INT_PROP(Richards, LiquidPhaseIndex, 0);
66 
68 SET_INT_PROP(Richards, GasPhaseIndex, 1 - GET_PROP_VALUE(TypeTag, LiquidPhaseIndex));
69 
79 SET_INT_PROP(Richards, LiquidComponentIndex, GET_PROP_VALUE(TypeTag, LiquidPhaseIndex));
80 
82 SET_INT_PROP(Richards, GasComponentIndex, 1 - GET_PROP_VALUE(TypeTag, LiquidComponentIndex));
83 
85 SET_TYPE_PROP(Richards,
86  LocalResidual,
88 
91 
94 
96 SET_TYPE_PROP(Richards, BoundaryRateVector, Ewoms::RichardsBoundaryRateVector<TypeTag>);
97 
99 SET_TYPE_PROP(Richards, PrimaryVariables, Ewoms::RichardsPrimaryVariables<TypeTag>);
100 
102 SET_TYPE_PROP(Richards, IntensiveQuantities, Ewoms::RichardsIntensiveQuantities<TypeTag>);
103 
105 SET_TYPE_PROP(Richards, ExtensiveQuantities, Ewoms::RichardsExtensiveQuantities<TypeTag>);
106 
109 
111 SET_TYPE_PROP(Richards, Indices, Ewoms::RichardsIndices);
112 
123 SET_PROP(Richards, WettingFluid)
124 {
125 private:
126  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
127 
128 public:
129  typedef Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> > type;
130 };
131 
140 SET_PROP(Richards, NonWettingFluid)
141 {
142 private:
143  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
144 
145 public:
146  typedef Opm::GasPhase<Scalar, Opm::NullComponent<Scalar> > type;
147 };
148 
158 SET_PROP(Richards, FluidSystem)
159 {
160 private:
161  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
162  typedef typename GET_PROP_TYPE(TypeTag, WettingFluid) WettingFluid;
163  typedef typename GET_PROP_TYPE(TypeTag, NonWettingFluid) NonWettingFluid;
164 
165 public:
166  typedef Opm::FluidSystems::TwoPhaseImmiscible<Scalar, WettingFluid, NonWettingFluid> type;
167 };
168 
169 } // namespace Properties
170 } // namespace Ewoms
171 
172 namespace Ewoms {
173 
231 template <class TypeTag>
232 class RichardsModel
233  : public MultiPhaseBaseModel<TypeTag>
234 {
235  typedef MultiPhaseBaseModel<TypeTag> ParentType;
236 
237  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
238 
239  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
240  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
241  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
242 
243  static const unsigned numPhases = FluidSystem::numPhases;
244  static const unsigned numComponents = FluidSystem::numComponents;
245 
246  static const unsigned liquidPhaseIdx = GET_PROP_VALUE(TypeTag, LiquidPhaseIndex);
247  static const unsigned gasPhaseIdx = GET_PROP_VALUE(TypeTag, GasPhaseIndex);
248 
249  static const unsigned liquidCompIdx = GET_PROP_VALUE(TypeTag, LiquidComponentIndex);
250  static const unsigned gasCompIdx = GET_PROP_VALUE(TypeTag, GasComponentIndex);
251 
252 
253  // some consistency checks
254  static_assert(numPhases == 2,
255  "Exactly two fluids are required for this model");
256  static_assert(numComponents == 2,
257  "Exactly two components are required for this model");
258  static_assert(liquidPhaseIdx != gasPhaseIdx,
259  "The liquid and the gas phases must be different");
260  static_assert(liquidCompIdx != gasCompIdx,
261  "The liquid and the gas components must be different");
262 
263 public:
264  RichardsModel(Simulator& simulator)
265  : ParentType(simulator)
266  {
267  // the liquid phase must be liquid, the gas phase must be
268  // gaseous. Think about it!
269  assert(FluidSystem::isLiquid(liquidPhaseIdx));
270  assert(!FluidSystem::isLiquid(gasPhaseIdx));
271  }
272 
276  static void registerParameters()
277  {
278  ParentType::registerParameters();
279  }
280 
284  static std::string name()
285  { return "richards"; }
286 
290  std::string primaryVarName(unsigned pvIdx) const
291  {
292  std::ostringstream oss;
293  if (pvIdx == Indices::pressureWIdx)
294  oss << "pressure_" << FluidSystem::phaseName(liquidPhaseIdx);
295  else
296  assert(0);
297 
298  return oss.str();
299  }
300 
304  std::string eqName(unsigned eqIdx) const
305  {
306  std::ostringstream oss;
307  if (eqIdx == Indices::contiEqIdx)
308  oss << "continuity_" << FluidSystem::phaseName(liquidPhaseIdx);
309  else
310  assert(0);
311 
312  return oss.str();
313  }
314 
318  Scalar primaryVarWeight(unsigned globalDofIdx OPM_UNUSED, unsigned pvIdx) const
319  {
320  if (Indices::pressureWIdx == pvIdx) {
321  return 10 / referencePressure_;
322  }
323 
324  return 1;
325  }
326 
330  Scalar eqWeight(unsigned globalDofIdx OPM_UNUSED, unsigned OPM_OPTIM_UNUSED eqIdx) const
331  {
332  unsigned OPM_OPTIM_UNUSED compIdx = eqIdx - Indices::contiEqIdx;
333  assert(0 <= compIdx && compIdx <= FluidSystem::numPhases);
334 
335  // make all kg equal
336  return 1.0;
337  }
338 
342  void updateBegin()
343  {
344  ParentType::updateBegin();
345 
346  // find the a reference pressure. The first degree of freedom
347  // might correspond to non-interior entities which would lead
348  // to an undefined value, so we have to iterate...
349  for (unsigned dofIdx = 0; dofIdx < this->numGridDof(); ++ dofIdx) {
350  if (this->isLocalDof(dofIdx)) {
351  referencePressure_ =
352  this->solution(/*timeIdx=*/0)[dofIdx][/*pvIdx=*/Indices::pressureWIdx];
353  break;
354  }
355  }
356  }
357 
361  bool phaseIsConsidered(unsigned phaseIdx) const
362  { return phaseIdx == liquidPhaseIdx; }
363 
364  void registerOutputModules_()
365  {
366  ParentType::registerOutputModules_();
367  }
368 
369  mutable Scalar referencePressure_;
370 };
371 } // namespace Ewoms
372 
373 #endif
Scalar primaryVarWeight(unsigned globalDofIdx OPM_UNUSED, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition: richardsmodel.hh:318
Intensive quantities required by the Richards model.
A Richards model specific Newton method.
Definition: richardsnewtonmethod.hh:46
Calculates and stores the data which is required to calculate the flux of fluid over a face of a fini...
Definition: richardsextensivequantities.hh:45
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
static std::string name()
Definition: richardsmodel.hh:284
Element-wise calculation of the residual for the Richards model.
#define NEW_TYPE_TAG(...)
Define a new type tag.
Definition: propertysystem.hh:169
This model implements a variant of the Richards equation for quasi-twophase flow. ...
Definition: richardsmodel.hh:56
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
#define INHERITS_FROM(...)
Syntactic sugar for NEW_TYPE_TAG.
Definition: propertysystem.hh:230
#define SET_INT_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant integer value.
Definition: propertysystem.hh:345
Implements a vector representing mass, molar or volumetric rates.
A Richards model specific Newton method.
Intensive quantities required by the Richards model.
Definition: richardsintensivequantities.hh:47
Implements a vector representing mass, molar or volumetric rates.
Definition: richardsratevector.hh:49
Represents the primary variables used in the Richards model.
Definition: richardsprimaryvariables.hh:53
Contains the property declarations for the Richards model.
The multi-dimensional Newton method.
Definition: newtonmethod.hh:56
Implements a boundary vector for the fully implicit Richards model.
bool phaseIsConsidered(unsigned phaseIdx) const
Definition: richardsmodel.hh:361
#define SET_PROP(EffTypeTagName, PropTagName)
Set a property for a specific type tag.
Definition: propertysystem.hh:297
Element-wise calculation of the residual for the Richards model.
Definition: richardslocalresidual.hh:42
Implements a boundary vector for the fully implicit Richards model.
Definition: richardsboundaryratevector.hh:44
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: richardsmodel.hh:290
void updateBegin()
Called by the update() method before it tries to apply the newton method.
Definition: richardsmodel.hh:342
Calculates and stores the data which is required to calculate the flux of fluid over a face of a fini...
Represents the primary variables used in the Richards model.
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition: richardsmodel.hh:304
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
Scalar eqWeight(unsigned globalDofIdx OPM_UNUSED, unsigned OPM_OPTIM_UNUSED eqIdx) const
Returns the relative weight of an equation.
Definition: richardsmodel.hh:330
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
static void registerParameters()
Register all run-time parameters for the model.
Definition: richardsmodel.hh:276
Indices for the primary variables/conservation equations of the Richards model.
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377
Indices for the primary variables/conservation equations of the Richards model.
Definition: richardsindices.hh:38