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
53namespace Opm {
54
55template <class TypeTag>
56class RichardsModel;
57
58}
59
60namespace Opm::Properties {
61
62// Create new type tags
63namespace TTag {
64
66struct Richards { using InheritsFrom = std::tuple<MultiPhaseBaseModel>; };
67
68} // end namespace TTag
69
71template<class TypeTag>
72struct LiquidPhaseIndex<TypeTag, TTag::Richards>
73{ static constexpr int value = 0; };
74
76template<class TypeTag>
77struct GasPhaseIndex<TypeTag, TTag::Richards>
78{ static constexpr int value = 1 - getPropValue<TypeTag, Properties::LiquidPhaseIndex>(); };
79
89template<class TypeTag>
90struct LiquidComponentIndex<TypeTag, TTag::Richards>
91{ static constexpr int value = getPropValue<TypeTag, Properties::LiquidPhaseIndex>(); };
92
94template<class TypeTag>
95struct GasComponentIndex<TypeTag, TTag::Richards>
96{ static constexpr int value = 1 - getPropValue<TypeTag, Properties::LiquidComponentIndex>(); };
97
99template<class TypeTag>
100struct LocalResidual<TypeTag, TTag::Richards>
102
104template<class TypeTag>
105struct Model<TypeTag, TTag::Richards>
107
109template<class TypeTag>
110struct RateVector<TypeTag, TTag::Richards>
112
114template<class TypeTag>
115struct BoundaryRateVector<TypeTag, TTag::Richards>
117
119template<class TypeTag>
120struct PrimaryVariables<TypeTag, TTag::Richards>
122
124template<class TypeTag>
125struct IntensiveQuantities<TypeTag, TTag::Richards>
127
129template<class TypeTag>
130struct ExtensiveQuantities<TypeTag, TTag::Richards>
132
134template<class TypeTag>
135struct NewtonMethod<TypeTag, TTag::Richards>
137
139template<class TypeTag>
140struct Indices<TypeTag, TTag::Richards>
142
153template<class TypeTag>
154struct WettingFluid<TypeTag, TTag::Richards>
155{
156private:
158
159public:
160 using type = LiquidPhase<Scalar, NullComponent<Scalar>>;
161};
162
171template<class TypeTag>
172struct NonWettingFluid<TypeTag, TTag::Richards>
173{
174private:
176
177public:
178 using type = GasPhase<Scalar, NullComponent<Scalar>>;
179};
180
190template<class TypeTag>
191struct FluidSystem<TypeTag, TTag::Richards>
192{
193private:
197
198public:
199 using type = TwoPhaseImmiscibleFluidSystem<Scalar, WettingFluid, NonWettingFluid>;
200};
201
202
203} // namespace Opm::Properties
204
205namespace Opm {
206
264template <class TypeTag>
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
295public:
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
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)) {
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
401
403};
404
405} // namespace Opm
406
407#endif
This class calculates the pressure potential gradients and the filter velocities for multi-phase flow...
Definition: multiphasebaseextensivequantities.hh:53
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:168
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:194
void registerOutputModules_()
Definition: multiphasebasemodel.hh:270
Implements a boundary vector for the fully implicit Richards model.
Definition: richardsboundaryratevector.hh:49
Intensive quantities required by the Richards model.
Definition: richardsintensivequantities.hh:54
Element-wise calculation of the residual for the Richards model.
Definition: richardslocalresidual.hh:47
This model implements a variant of the Richards equation for quasi-twophase flow.
Definition: richardsmodel.hh:267
void updateBegin()
Called by the update() method before it tries to apply the newton method. This is primary a hook whic...
Definition: richardsmodel.hh:377
bool phaseIsConsidered(unsigned phaseIdx) const
Definition: richardsmodel.hh:396
Scalar referencePressure_
Definition: richardsmodel.hh:402
Scalar eqWeight(unsigned, unsigned eqIdx) const
Returns the relative weight of an equation.
Definition: richardsmodel.hh:366
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition: richardsmodel.hh:338
RichardsModel(Simulator &simulator)
Definition: richardsmodel.hh:296
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: richardsmodel.hh:322
static void registerParameters()
Register all run-time parameters for the model.
Definition: richardsmodel.hh:308
void registerOutputModules_()
Definition: richardsmodel.hh:399
static std::string name()
Definition: richardsmodel.hh:316
Scalar primaryVarWeight(unsigned, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition: richardsmodel.hh:354
A Richards model specific Newton method.
Definition: richardsnewtonmethod.hh:50
Represents the primary variables used in the Richards model.
Definition: richardsprimaryvariables.hh:53
Implements a vector representing mass, molar or volumetric rates.
Definition: richardsratevector.hh:54
Definition: blackoilmodel.hh:79
Definition: blackoilboundaryratevector.hh:39
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
Contains the property declarations for the Richards model.
Type of object for specifying boundary conditions.
Definition: fvbaseproperties.hh:119
Data required to calculate a flux over a face.
Definition: fvbaseproperties.hh:149
TwoPhaseImmiscibleFluidSystem< Scalar, WettingFluid, NonWettingFluid > type
Definition: richardsmodel.hh:199
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:79
Index of the component which constitutes the gas.
Definition: richardsproperties.hh:61
Index of the fluid which represents the non-wetting phase.
Definition: richardsproperties.hh:53
Enumerations used by the model.
Definition: multiphasebaseproperties.hh:51
The secondary variables within a sub-control volume.
Definition: fvbaseproperties.hh:133
Index of the component which constitutes the liquid.
Definition: richardsproperties.hh:57
Index of the fluid which represents the wetting phase.
Definition: richardsproperties.hh:49
The type of the local residual function.
Definition: fvbaseproperties.hh:94
The type of the model.
Definition: basicproperties.hh:88
Specifies the type of the actual Newton method.
Definition: newtonmethodproperties.hh:32
GasPhase< Scalar, NullComponent< Scalar > > type
Definition: richardsmodel.hh:178
Definition: richardsproperties.hh:45
A vector of primary variables within a sub-control volume.
Definition: fvbaseproperties.hh:130
Vector containing volumetric or areal rates of quantities.
Definition: fvbaseproperties.hh:116
The type tag for problems discretized using the Richards model.
Definition: richardsmodel.hh:66
std::tuple< MultiPhaseBaseModel > InheritsFrom
Definition: richardsmodel.hh:66
LiquidPhase< Scalar, NullComponent< Scalar > > type
Definition: richardsmodel.hh:160
Definition: richardsproperties.hh:40
Indices for the primary variables/conservation equations of the Richards model.
Definition: richardsindices.hh:39