opm-simulators
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/components/NullComponent.hpp>
32 #include <opm/material/densead/Math.hpp>
33 #include <opm/material/fluidsystems/LiquidPhase.hpp>
34 #include <opm/material/fluidsystems/GasPhase.hpp>
35 #include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
36 
47 
48 #include <cassert>
49 #include <sstream>
50 #include <string>
51 #include <tuple>
52 
53 namespace Opm {
54 
55 template <class TypeTag>
57 
58 }
59 
60 namespace Opm::Properties {
61 
62 // Create new type tags
63 namespace TTag {
64 
66 struct Richards { using InheritsFrom = std::tuple<MultiPhaseBaseModel>; };
67 
68 } // end namespace TTag
69 
71 template<class TypeTag>
72 struct LiquidPhaseIndex<TypeTag, TTag::Richards>
73 { static constexpr int value = 0; };
74 
76 template<class TypeTag>
77 struct GasPhaseIndex<TypeTag, TTag::Richards>
78 { static constexpr int value = 1 - getPropValue<TypeTag, Properties::LiquidPhaseIndex>(); };
79 
89 template<class TypeTag>
90 struct LiquidComponentIndex<TypeTag, TTag::Richards>
91 { static constexpr int value = getPropValue<TypeTag, Properties::LiquidPhaseIndex>(); };
92 
94 template<class TypeTag>
95 struct GasComponentIndex<TypeTag, TTag::Richards>
96 { static constexpr int value = 1 - getPropValue<TypeTag, Properties::LiquidComponentIndex>(); };
97 
99 template<class TypeTag>
100 struct LocalResidual<TypeTag, TTag::Richards>
102 
104 template<class TypeTag>
105 struct Model<TypeTag, TTag::Richards>
106 { using type = RichardsModel<TypeTag>; };
107 
109 template<class TypeTag>
110 struct RateVector<TypeTag, TTag::Richards>
111 { using type = RichardsRateVector<TypeTag>; };
112 
114 template<class TypeTag>
115 struct BoundaryRateVector<TypeTag, TTag::Richards>
117 
119 template<class TypeTag>
120 struct PrimaryVariables<TypeTag, TTag::Richards>
122 
124 template<class TypeTag>
125 struct IntensiveQuantities<TypeTag, TTag::Richards>
127 
129 template<class TypeTag>
130 struct ExtensiveQuantities<TypeTag, TTag::Richards>
132 
134 template<class TypeTag>
135 struct NewtonMethod<TypeTag, TTag::Richards>
137 
139 template<class TypeTag>
140 struct Indices<TypeTag, TTag::Richards>
141 { using type = RichardsIndices; };
142 
153 template<class TypeTag>
154 struct WettingFluid<TypeTag, TTag::Richards>
155 {
156 private:
158 
159 public:
160  using type = LiquidPhase<Scalar, NullComponent<Scalar>>;
161 };
162 
171 template<class TypeTag>
172 struct NonWettingFluid<TypeTag, TTag::Richards>
173 {
174 private:
176 
177 public:
178  using type = GasPhase<Scalar, NullComponent<Scalar>>;
179 };
180 
190 template<class TypeTag>
191 struct FluidSystem<TypeTag, TTag::Richards>
192 {
193 private:
197 
198 public:
199  using type = TwoPhaseImmiscibleFluidSystem<Scalar, WettingFluid, NonWettingFluid>;
200 };
201 
202 
203 } // namespace Opm::Properties
204 
205 namespace Opm {
206 
264 template <class TypeTag>
265 class RichardsModel
266  : public MultiPhaseBaseModel<TypeTag>
267 {
268  using ParentType = MultiPhaseBaseModel<TypeTag>;
269 
271 
275 
276  static const unsigned numPhases = FluidSystem::numPhases;
277  static const unsigned numComponents = FluidSystem::numComponents;
278 
279  static const unsigned liquidPhaseIdx = getPropValue<TypeTag, Properties::LiquidPhaseIndex>();
280  static const unsigned gasPhaseIdx = getPropValue<TypeTag, Properties::GasPhaseIndex>();
281 
282  static const unsigned liquidCompIdx = getPropValue<TypeTag, Properties::LiquidComponentIndex>();
283  static const unsigned gasCompIdx = getPropValue<TypeTag, Properties::GasComponentIndex>();
284 
285  // some consistency checks
286  static_assert(numPhases == 2,
287  "Exactly two fluids are required for this model");
288  static_assert(numComponents == 2,
289  "Exactly two components are required for this model");
290  static_assert(liquidPhaseIdx != gasPhaseIdx,
291  "The liquid and the gas phases must be different");
292  static_assert(liquidCompIdx != gasCompIdx,
293  "The liquid and the gas components must be different");
294 
295 public:
296  explicit RichardsModel(Simulator& simulator)
297  : ParentType(simulator)
298  {
299  // the liquid phase must be liquid, the gas phase must be
300  // gaseous. Think about it!
301  assert(FluidSystem::isLiquid(liquidPhaseIdx));
302  assert(!FluidSystem::isLiquid(gasPhaseIdx));
303  }
304 
308  static void registerParameters()
309  {
311  }
312 
316  static std::string name()
317  { return "richards"; }
318 
322  std::string primaryVarName(unsigned pvIdx) const
323  {
324  std::ostringstream oss;
325  if (pvIdx == Indices::pressureWIdx) {
326  oss << "pressure_" << FluidSystem::phaseName(liquidPhaseIdx);
327  }
328  else {
329  assert(0);
330  }
331 
332  return oss.str();
333  }
334 
338  std::string eqName(unsigned eqIdx) const
339  {
340  std::ostringstream oss;
341  if (eqIdx == Indices::contiEqIdx) {
342  oss << "continuity_" << FluidSystem::phaseName(liquidPhaseIdx);
343  }
344  else {
345  assert(0);
346  }
347 
348  return oss.str();
349  }
350 
354  Scalar primaryVarWeight(unsigned, unsigned pvIdx) const
355  {
356  if (Indices::pressureWIdx == pvIdx) {
357  return 10 / referencePressure_;
358  }
359 
360  return 1;
361  }
362 
366  Scalar eqWeight(unsigned, [[maybe_unused]] unsigned eqIdx) const
367  {
368  assert((eqIdx - Indices::contiEqIdx) <= FluidSystem::numPhases);
369 
370  // make all kg equal
371  return 1.0;
372  }
373 
377  void updateBegin()
378  {
379  ParentType::updateBegin();
380 
381  // find the a reference pressure. The first degree of freedom
382  // might correspond to non-interior entities which would lead
383  // to an undefined value, so we have to iterate...
384  for (unsigned dofIdx = 0; dofIdx < this->numGridDof(); ++ dofIdx) {
385  if (this->isLocalDof(dofIdx)) {
386  referencePressure_ =
387  this->solution(/*timeIdx=*/0)[dofIdx][/*pvIdx=*/Indices::pressureWIdx];
388  break;
389  }
390  }
391  }
392 
396  bool phaseIsConsidered(unsigned phaseIdx) const
397  { return phaseIdx == liquidPhaseIdx; }
398 
399  void registerOutputModules_()
400  { ParentType::registerOutputModules_(); }
401 
402  Scalar referencePressure_{};
403 };
404 
405 } // namespace Opm
406 
407 #endif
Index of the fluid which represents the non-wetting phase.
Definition: richardsproperties.hh:53
Index of the component which constitutes the liquid.
Definition: richardsproperties.hh:57
static void registerParameters()
Register all run-time parameters for the model.
Definition: richardsmodel.hh:308
static std::string name()
Definition: richardsmodel.hh:316
Intensive quantities required by the Richards model.
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(...))
Definition: propertysystem.hh:233
The type of the local residual function.
Definition: fvbaseproperties.hh:94
Specifies the type of the actual Newton method.
Definition: fvbaseproblem.hh:54
Element-wise calculation of the residual for the Richards model.
Definition: richardslocalresidual.hh:46
This model implements a variant of the Richards equation for quasi-twophase flow. ...
Definition: richardsmodel.hh:56
Enumerations used by the model.
Definition: multiphasebaseproperties.hh:51
Represents the primary variables used in the Richards model.
Definition: richardsprimaryvariables.hh:52
The type tag for problems discretized using the Richards model.
Definition: richardsmodel.hh:66
Element-wise calculation of the residual for the Richards model.
The fluid used as the wetting phase (by default, we set the fluid system to the immiscible one...
Definition: richardsproperties.hh:40
The fluid used as the non-wetting phase (by default, we set the fluid system to the immiscible one...
Definition: richardsproperties.hh:45
Scalar eqWeight(unsigned, [[maybe_unused]] unsigned eqIdx) const
Returns the relative weight of an equation.
Definition: richardsmodel.hh:366
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
Implements a vector representing mass, molar or volumetric rates.
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition: richardsmodel.hh:338
Vector containing volumetric or areal rates of quantities.
Definition: fvbaseproperties.hh:116
Implements a boundary vector for the fully implicit Richards model.
Definition: richardsboundaryratevector.hh:48
Type of object for specifying boundary conditions.
Definition: fvbaseproperties.hh:119
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:79
A Richards model specific Newton method.
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:197
void updateBegin()
Called by the update() method before it tries to apply the newton method.
Definition: richardsmodel.hh:377
Data required to calculate a flux over a face.
Definition: fvbaseproperties.hh:153
A Richards model specific Newton method.
Definition: richardsnewtonmethod.hh:49
Contains the property declarations for the Richards model.
Implements a boundary vector for the fully implicit Richards model.
The secondary variables within a sub-control volume.
Definition: fvbaseproperties.hh:133
Index of the component which constitutes the gas.
Definition: richardsproperties.hh:61
This class calculates the pressure potential gradients and the filter velocities for multi-phase flow...
Definition: multiphasebaseextensivequantities.hh:50
The type of the model.
Definition: basicproperties.hh:92
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: richardsmodel.hh:322
Calculates and stores the data which is required to calculate the flux of fluid over a face of a fini...
Intensive quantities required by the Richards model.
Definition: richardsintensivequantities.hh:51
Scalar primaryVarWeight(unsigned, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition: richardsmodel.hh:354
Represents the primary variables used in the Richards model.
Implements a vector representing mass, molar or volumetric rates.
Definition: richardsratevector.hh:51
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
bool phaseIsConsidered(unsigned phaseIdx) const
Definition: richardsmodel.hh:396
Indices for the primary variables/conservation equations of the Richards model.
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:83
Definition: blackoilmodel.hh:80
Indices for the primary variables/conservation equations of the Richards model.
Definition: richardsindices.hh:38
A vector of primary variables within a sub-control volume.
Definition: fvbaseproperties.hh:130
Index of the fluid which represents the wetting phase.
Definition: richardsproperties.hh:49
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:57