version 3.8
porousmediumflow/richardsextended/localresidual.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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
14#ifndef DUMUX_RICHARDSEXTENDED_LOCAL_RESIDUAL_HH
15#define DUMUX_RICHARDSEXTENDED_LOCAL_RESIDUAL_HH
16
24
25namespace Dumux {
26
32template<class TypeTag>
34{
36
37 using ParentType = RichardsLocalResidual<TypeTag>;
42 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
44 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
46 using FVElementGeometry = typename GridGeometry::LocalView;
47 using SubControlVolume = typename GridGeometry::SubControlVolume;
48 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
49 using GridView = typename GridGeometry::GridView;
50 using Element = typename GridView::template Codim<0>::Entity;
54 // first index for the mass balance
55 enum { conti0EqIdx = Indices::conti0EqIdx };
56
57 // phase & component indices
58 static constexpr auto liquidPhaseIdx = FluidSystem::phase0Idx;
59 static constexpr auto gasPhaseIdx = FluidSystem::phase1Idx;
60 static constexpr auto liquidCompIdx = FluidSystem::comp0Idx;
61
62public:
63 using ParentType::ParentType;
64
73 NumEqVector computeStorage(const Problem& problem,
74 const SubControlVolume& scv,
75 const VolumeVariables& volVars) const
76 {
77 NumEqVector storage = ParentType::computeStorage(problem, scv, volVars);
78 // for extended Richards we consider water in air
79 storage[conti0EqIdx] += volVars.porosity()
80 * volVars.molarDensity(gasPhaseIdx)
81 * volVars.moleFraction(gasPhaseIdx, liquidCompIdx)
82 * FluidSystem::molarMass(liquidCompIdx)
83 * volVars.saturation(gasPhaseIdx);
84
85 return storage;
86 }
87
88
99 NumEqVector computeFlux(const Problem& problem,
100 const Element& element,
101 const FVElementGeometry& fvGeometry,
102 const ElementVolumeVariables& elemVolVars,
103 const SubControlVolumeFace& scvf,
104 const ElementFluxVariablesCache& elemFluxVarsCache) const
105 {
106 FluxVariables fluxVars;
107 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
108 NumEqVector flux = ParentType::computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
109
110 // for extended Richards we consider water vapor diffusion in air
111 //check for the reference system and adapt units of the diffusive flux accordingly.
112 if (FluxVariables::MolecularDiffusionType::referenceSystemFormulation() == ReferenceSystemFormulation::massAveraged)
113 flux[conti0EqIdx] += fluxVars.molecularDiffusionFlux(gasPhaseIdx)[liquidCompIdx];
114 else
115 flux[conti0EqIdx] += fluxVars.molecularDiffusionFlux(gasPhaseIdx)[liquidCompIdx]*FluidSystem::molarMass(liquidCompIdx);
116
117 return flux;
118 }
119};
120
121} // end namespace Dumux
122
123#endif
Element-wise calculation of the Jacobian matrix for problems using the extended Richards fully implic...
Definition: porousmediumflow/richardsextended/localresidual.hh:34
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Evaluates the rate of change of all conservation quantites (e.g. phase mass) within a sub-control vol...
Definition: porousmediumflow/richardsextended/localresidual.hh:73
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluates the mass flux over a face of a sub control volume.
Definition: porousmediumflow/richardsextended/localresidual.hh:99
Element-wise calculation of the Jacobian matrix for problems using the Richards fully implicit models...
Definition: porousmediumflow/richards/localresidual.hh:46
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Evaluates the rate of change of all conservation quantites (e.g. phase mass) within a sub-control vol...
Definition: porousmediumflow/richards/localresidual.hh:100
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluates the mass flux over a face of a sub control volume.
Definition: porousmediumflow/richards/localresidual.hh:129
Defines all properties used in Dumux.
Type traits.
Helper classes to compute the integration elements.
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition: numeqvector.hh:34
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
The available discretization methods in Dumux.
Definition: adapt.hh:17
A helper to deduce a vector with the same size as numbers of equations.
Element-wise calculation of the Jacobian matrix for problems using the Richards fully implicit models...
The reference frameworks and formulations available for splitting total fluxes into a advective and d...