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  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_RICHARDS_MODEL_HH
27 #define EWOMS_RICHARDS_MODEL_HH
28 
29 #include <opm/material/localad/Math.hpp>
30 
31 #include "richardsproperties.hh"
32 #include "richardsindices.hh"
33 #include "richardslocalresidual.hh"
35 #include "richardsratevector.hh"
39 #include "richardsnewtonmethod.hh"
40 
42 
43 #include <opm/material/components/NullComponent.hpp>
44 #include <opm/material/fluidsystems/LiquidPhase.hpp>
45 #include <opm/material/fluidsystems/GasPhase.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 {
62 
64 SET_INT_PROP(Richards, LiquidPhaseIndex, 0);
65 
67 SET_INT_PROP(Richards, GasPhaseIndex, 1 - GET_PROP_VALUE(TypeTag, LiquidPhaseIndex));
68 
78 SET_INT_PROP(Richards, LiquidComponentIndex, GET_PROP_VALUE(TypeTag, LiquidPhaseIndex));
79 
81 SET_INT_PROP(Richards, GasComponentIndex, 1 - GET_PROP_VALUE(TypeTag, LiquidComponentIndex));
82 
84 SET_TYPE_PROP(Richards,
85  LocalResidual,
87 
90 
93 
95 SET_TYPE_PROP(Richards, BoundaryRateVector, Ewoms::RichardsBoundaryRateVector<TypeTag>);
96 
98 SET_TYPE_PROP(Richards, PrimaryVariables, Ewoms::RichardsPrimaryVariables<TypeTag>);
99 
101 SET_TYPE_PROP(Richards, IntensiveQuantities, Ewoms::RichardsIntensiveQuantities<TypeTag>);
102 
104 SET_TYPE_PROP(Richards, ExtensiveQuantities, Ewoms::RichardsExtensiveQuantities<TypeTag>);
105 
108 
110 SET_TYPE_PROP(Richards, Indices, Ewoms::RichardsIndices);
111 
122 SET_PROP(Richards, WettingFluid)
123 {
124 private:
125  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
126 
127 public:
128  typedef Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> > type;
129 };
130 
139 SET_PROP(Richards, NonWettingFluid)
140 {
141 private:
142  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
143 
144 public:
145  typedef Opm::GasPhase<Scalar, Opm::NullComponent<Scalar> > type;
146 };
147 
157 SET_PROP(Richards, FluidSystem)
158 {
159 private:
160  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
161  typedef typename GET_PROP_TYPE(TypeTag, WettingFluid) WettingFluid;
162  typedef typename GET_PROP_TYPE(TypeTag, NonWettingFluid) NonWettingFluid;
163 
164 public:
165  typedef Opm::FluidSystems::TwoPhaseImmiscible<Scalar, WettingFluid, NonWettingFluid> type;
166 };
167 
168 } // namespace Properties
169 } // namespace Ewoms
170 
171 namespace Ewoms {
172 
230 template <class TypeTag>
231 class RichardsModel
232  : public MultiPhaseBaseModel<TypeTag>
233 {
234  typedef MultiPhaseBaseModel<TypeTag> ParentType;
235 
236  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
237 
238  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
239  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
240  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
241 
242  static const int numPhases = FluidSystem::numPhases;
243  static const int numComponents = FluidSystem::numComponents;
244 
245  static const int liquidPhaseIdx = GET_PROP_VALUE(TypeTag, LiquidPhaseIndex);
246  static const int gasPhaseIdx = GET_PROP_VALUE(TypeTag, GasPhaseIndex);
247 
248  static const int liquidCompIdx = GET_PROP_VALUE(TypeTag, LiquidComponentIndex);
249  static const int gasCompIdx = GET_PROP_VALUE(TypeTag, GasComponentIndex);
250 
251 
252  // some consistency checks
253  static_assert(numPhases == 2,
254  "Exactly two fluids are required for this model");
255  static_assert(numComponents == 2,
256  "Exactly two components are required for this model");
257  static_assert(liquidPhaseIdx != gasPhaseIdx,
258  "The liquid and the gas phases must be different");
259  static_assert(liquidCompIdx != gasCompIdx,
260  "The liquid and the gas components must be different");
261 
262 public:
263  RichardsModel(Simulator &simulator)
264  : ParentType(simulator)
265  {
266  // the liquid phase must be liquid, the gas phase must be
267  // gaseous. Think about it!
268  assert(FluidSystem::isLiquid(liquidPhaseIdx));
269  assert(!FluidSystem::isLiquid(gasPhaseIdx));
270  }
271 
275  static void registerParameters()
276  {
278  }
279 
283  static std::string name()
284  { return "richards"; }
285 
289  std::string primaryVarName(int pvIdx) const
290  {
291  std::ostringstream oss;
292  if (pvIdx == Indices::pressureWIdx)
293  oss << "pressure_" << FluidSystem::phaseName(liquidPhaseIdx);
294  else
295  assert(0);
296 
297  return oss.str();
298  }
299 
303  std::string eqName(int eqIdx) const
304  {
305  std::ostringstream oss;
306  if (eqIdx == Indices::contiEqIdx)
307  oss << "continuity_" << FluidSystem::phaseName(liquidPhaseIdx);
308  else
309  assert(0);
310 
311  return oss.str();
312  }
313 
317  Scalar primaryVarWeight(int globalDofIdx, int pvIdx) const
318  {
319  if (Indices::pressureWIdx == pvIdx) {
320  return 10 / referencePressure_;
321  }
322 
323  return 1;
324  }
325 
329  Scalar eqWeight(int globalDofIdx, int eqIdx) const
330  {
331  int DUNE_UNUSED compIdx = eqIdx - Indices::contiEqIdx;
332  assert(0 <= compIdx && compIdx <= FluidSystem::numPhases);
333 
334  // make all kg equal
335  return 1.0;
336  }
337 
341  void updateBegin()
342  {
343  ParentType::updateBegin();
344 
345  // find the a reference pressure. The first degree of freedom
346  // might correspond to non-interior entities which would lead
347  // to an undefined value, so we have to iterate...
348  for (size_t dofIdx = 0; dofIdx < this->numGridDof(); ++ dofIdx) {
349  if (this->isLocalDof(dofIdx)) {
350  referencePressure_ =
351  this->solution(/*timeIdx=*/0)[dofIdx][/*pvIdx=*/Indices::pressureWIdx];
352  break;
353  }
354  }
355  }
356 
360  bool phaseIsConsidered(int phaseIdx) const
361  { return phaseIdx == liquidPhaseIdx; }
362 
364  {
366  }
367 
368  mutable Scalar referencePressure_;
369 };
370 } // namespace Ewoms
371 
372 #endif
void registerOutputModules_()
Definition: multiphasebasemodel.hh:244
Implements a boundary vector for the fully implicit Richards model.
A Richards model specific Newton method.
The multi-dimensional Newton method.
Definition: newtonmethod.hh:54
Element-wise calculation of the residual for the Richards model.
Definition: richardslocalresidual.hh:40
bool phaseIsConsidered(int phaseIdx) const
Returns true iff a fluid phase is used by the model.
Definition: multiphasebasemodel.hh:180
Implements a boundary vector for the fully implicit Richards model.
Definition: richardsboundaryratevector.hh:42
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:45
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:485
Implements a vector representing mass, molar or volumetric rates.
Definition: richardsratevector.hh:47
SET_PROP(NumericModel, ParameterTree)
Set the ParameterTree property.
Definition: basicproperties.hh:117
Implements a vector representing mass, molar or volumetric rates.
SET_INT_PROP(NumericModel, GridGlobalRefinements, 0)
Indices for the primary variables/conservation equations of the Richards model.
Intensive quantities required by the Richards model.
SET_TYPE_PROP(NumericModel, Scalar, double)
Set the default type of scalar values to double.
Calculates and stores the data which is required to calculate the flux of fluid over a face of a fini...
Element-wise calculation of the residual for the Richards model.
Intensive quantities required by the Richards model.
Definition: richardsintensivequantities.hh:45
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...
Represents the primary variables used in the Richards model.
Definition: richardsprimaryvariables.hh:49
A Richards model specific Newton method.
Definition: richardsnewtonmethod.hh:43
This model implements a variant of the Richards equation for quasi-twophase flow. ...
Definition: richardsmodel.hh:55
Indices for the primary variables/conservation equations of the Richards model.
Definition: richardsindices.hh:36
NEW_TYPE_TAG(AuxModule)
Calculates and stores the data which is required to calculate the flux of fluid over a face of a fini...
Definition: richardsextensivequantities.hh:43
#define INHERITS_FROM(...)
Syntactic sugar for NEW_TYPE_TAG.
Definition: propertysystem.hh:229
Represents the primary variables used in the Richards model.
Contains the property declarations for the Richards model.