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"
37#include "richardsratevector.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
50#include <sstream>
51#include <string>
52
53namespace Opm {
54template <class TypeTag>
55class RichardsModel;
56}
57
58namespace Opm::Properties {
59
60// Create new type tags
61namespace TTag {
63struct Richards { using InheritsFrom = std::tuple<MultiPhaseBaseModel>; };
64} // end namespace TTag
65
67template<class TypeTag>
68struct LiquidPhaseIndex<TypeTag, TTag::Richards> { static constexpr int value = 0; };
69
71template<class TypeTag>
72struct GasPhaseIndex<TypeTag, TTag::Richards> { static constexpr int value = 1 - getPropValue<TypeTag, Properties::LiquidPhaseIndex>(); };
73
83template<class TypeTag>
84struct LiquidComponentIndex<TypeTag, TTag::Richards> { static constexpr int value = getPropValue<TypeTag, Properties::LiquidPhaseIndex>(); };
85
87template<class TypeTag>
88struct GasComponentIndex<TypeTag, TTag::Richards> { static constexpr int value = 1 - getPropValue<TypeTag, Properties::LiquidComponentIndex>(); };
89
91template<class TypeTag>
92struct LocalResidual<TypeTag, TTag::Richards> { using type = Opm::RichardsLocalResidual<TypeTag>; };
93
95template<class TypeTag>
96struct Model<TypeTag, TTag::Richards> { using type = Opm::RichardsModel<TypeTag>; };
97
99template<class TypeTag>
100struct RateVector<TypeTag, TTag::Richards> { using type = Opm::RichardsRateVector<TypeTag>; };
101
103template<class TypeTag>
104struct BoundaryRateVector<TypeTag, TTag::Richards> { using type = Opm::RichardsBoundaryRateVector<TypeTag>; };
105
107template<class TypeTag>
108struct PrimaryVariables<TypeTag, TTag::Richards> { using type = Opm::RichardsPrimaryVariables<TypeTag>; };
109
111template<class TypeTag>
112struct IntensiveQuantities<TypeTag, TTag::Richards> { using type = Opm::RichardsIntensiveQuantities<TypeTag>; };
113
115template<class TypeTag>
116struct ExtensiveQuantities<TypeTag, TTag::Richards> { using type = Opm::RichardsExtensiveQuantities<TypeTag>; };
117
119template<class TypeTag>
120struct NewtonMethod<TypeTag, TTag::Richards> { using type = Opm::RichardsNewtonMethod<TypeTag>; };
121
123template<class TypeTag>
124struct Indices<TypeTag, TTag::Richards> { using type = Opm::RichardsIndices; };
125
136template<class TypeTag>
137struct WettingFluid<TypeTag, TTag::Richards>
138{
139private:
141
142public:
143 using type = Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> >;
144};
145
154template<class TypeTag>
155struct NonWettingFluid<TypeTag, TTag::Richards>
156{
157private:
159
160public:
161 using type = Opm::GasPhase<Scalar, Opm::NullComponent<Scalar> >;
162};
163
173template<class TypeTag>
174struct FluidSystem<TypeTag, TTag::Richards>
175{
176private:
180
181public:
182 using type = Opm::TwoPhaseImmiscibleFluidSystem<Scalar, WettingFluid, NonWettingFluid>;
183};
184
185
186} // namespace Opm::Properties
187
188namespace Opm {
189
247template <class TypeTag>
249 : public MultiPhaseBaseModel<TypeTag>
250{
251 using ParentType = MultiPhaseBaseModel<TypeTag>;
252
254
258
259 static const unsigned numPhases = FluidSystem::numPhases;
260 static const unsigned numComponents = FluidSystem::numComponents;
261
262 static const unsigned liquidPhaseIdx = getPropValue<TypeTag, Properties::LiquidPhaseIndex>();
263 static const unsigned gasPhaseIdx = getPropValue<TypeTag, Properties::GasPhaseIndex>();
264
265 static const unsigned liquidCompIdx = getPropValue<TypeTag, Properties::LiquidComponentIndex>();
266 static const unsigned gasCompIdx = getPropValue<TypeTag, Properties::GasComponentIndex>();
267
268
269 // some consistency checks
270 static_assert(numPhases == 2,
271 "Exactly two fluids are required for this model");
272 static_assert(numComponents == 2,
273 "Exactly two components are required for this model");
274 static_assert(liquidPhaseIdx != gasPhaseIdx,
275 "The liquid and the gas phases must be different");
276 static_assert(liquidCompIdx != gasCompIdx,
277 "The liquid and the gas components must be different");
278
279public:
280 RichardsModel(Simulator& simulator)
281 : ParentType(simulator)
282 {
283 // the liquid phase must be liquid, the gas phase must be
284 // gaseous. Think about it!
285 assert(FluidSystem::isLiquid(liquidPhaseIdx));
286 assert(!FluidSystem::isLiquid(gasPhaseIdx));
287 }
288
292 static void registerParameters()
293 {
295 }
296
300 static std::string name()
301 { return "richards"; }
302
306 std::string primaryVarName(unsigned pvIdx) const
307 {
308 std::ostringstream oss;
309 if (pvIdx == Indices::pressureWIdx)
310 oss << "pressure_" << FluidSystem::phaseName(liquidPhaseIdx);
311 else
312 assert(0);
313
314 return oss.str();
315 }
316
320 std::string eqName(unsigned eqIdx) const
321 {
322 std::ostringstream oss;
323 if (eqIdx == Indices::contiEqIdx)
324 oss << "continuity_" << FluidSystem::phaseName(liquidPhaseIdx);
325 else
326 assert(0);
327
328 return oss.str();
329 }
330
334 Scalar primaryVarWeight(unsigned, unsigned pvIdx) const
335 {
336 if (Indices::pressureWIdx == pvIdx) {
337 return 10 / referencePressure_;
338 }
339
340 return 1;
341 }
342
346 Scalar eqWeight(unsigned, [[maybe_unused]] unsigned eqIdx) const
347 {
348 assert((eqIdx - Indices::contiEqIdx) <= FluidSystem::numPhases);
349
350 // make all kg equal
351 return 1.0;
352 }
353
358 {
359 ParentType::updateBegin();
360
361 // find the a reference pressure. The first degree of freedom
362 // might correspond to non-interior entities which would lead
363 // to an undefined value, so we have to iterate...
364 for (unsigned dofIdx = 0; dofIdx < this->numGridDof(); ++ dofIdx) {
365 if (this->isLocalDof(dofIdx)) {
367 this->solution(/*timeIdx=*/0)[dofIdx][/*pvIdx=*/Indices::pressureWIdx];
368 break;
369 }
370 }
371 }
372
376 bool phaseIsConsidered(unsigned phaseIdx) const
377 { return phaseIdx == liquidPhaseIdx; }
378
380 {
382 }
383
384 mutable Scalar referencePressure_;
385};
386} // namespace Opm
387
388#endif
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:153
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:179
void registerOutputModules_()
Definition: multiphasebasemodel.hh:254
Implements a boundary vector for the fully implicit Richards model.
Definition: richardsboundaryratevector.hh:45
Calculates and stores the data which is required to calculate the flux of fluid over a face of a fini...
Definition: richardsextensivequantities.hh:47
Intensive quantities required by the Richards model.
Definition: richardsintensivequantities.hh:50
Element-wise calculation of the residual for the Richards model.
Definition: richardslocalresidual.hh:43
This model implements a variant of the Richards equation for quasi-twophase flow.
Definition: richardsmodel.hh:250
void updateBegin()
Called by the update() method before it tries to apply the newton method. This is primary a hook whic...
Definition: richardsmodel.hh:357
bool phaseIsConsidered(unsigned phaseIdx) const
Definition: richardsmodel.hh:376
Scalar referencePressure_
Definition: richardsmodel.hh:384
Scalar eqWeight(unsigned, unsigned eqIdx) const
Returns the relative weight of an equation.
Definition: richardsmodel.hh:346
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition: richardsmodel.hh:320
RichardsModel(Simulator &simulator)
Definition: richardsmodel.hh:280
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: richardsmodel.hh:306
static void registerParameters()
Register all run-time parameters for the model.
Definition: richardsmodel.hh:292
void registerOutputModules_()
Definition: richardsmodel.hh:379
static std::string name()
Definition: richardsmodel.hh:300
Scalar primaryVarWeight(unsigned, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition: richardsmodel.hh:334
A Richards model specific Newton method.
Definition: richardsnewtonmethod.hh:46
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:52
Definition: blackoilmodel.hh:72
Definition: blackoilboundaryratevector.hh:37
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:242
Contains the property declarations for the Richards model.
Type of object for specifying boundary conditions.
Definition: fvbaseproperties.hh:136
Data required to calculate a flux over a face.
Definition: fvbaseproperties.hh:166
Opm::TwoPhaseImmiscibleFluidSystem< Scalar, WettingFluid, NonWettingFluid > type
Definition: richardsmodel.hh:182
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:69
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:48
The secondary variables within a sub-control volume.
Definition: fvbaseproperties.hh:150
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:111
The type of the model.
Definition: basicproperties.hh:81
Specifies the type of the actual Newton method.
Definition: newtonmethodproperties.hh:32
Opm::GasPhase< Scalar, Opm::NullComponent< Scalar > > type
Definition: richardsmodel.hh:161
Definition: richardsproperties.hh:45
A vector of primary variables within a sub-control volume.
Definition: fvbaseproperties.hh:147
Vector containing volumetric or areal rates of quantities.
Definition: fvbaseproperties.hh:133
The type tag for problems discretized using the Richards model.
Definition: richardsmodel.hh:63
std::tuple< MultiPhaseBaseModel > InheritsFrom
Definition: richardsmodel.hh:63
Opm::LiquidPhase< Scalar, Opm::NullComponent< Scalar > > type
Definition: richardsmodel.hh:143
Definition: richardsproperties.hh:40
Indices for the primary variables/conservation equations of the Richards model.
Definition: richardsindices.hh:39