3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program 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 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
26#ifndef DUMUX_RICHARDSEXTENDED_LOCAL_RESIDUAL_HH
27#define DUMUX_RICHARDSEXTENDED_LOCAL_RESIDUAL_HH
28
36
37namespace Dumux {
38
44template<class TypeTag>
46{
48
49 using ParentType = RichardsLocalResidual<TypeTag>;
54 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
56 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
58 using FVElementGeometry = typename GridGeometry::LocalView;
59 using SubControlVolume = typename GridGeometry::SubControlVolume;
60 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
61 using GridView = typename GridGeometry::GridView;
62 using Element = typename GridView::template Codim<0>::Entity;
66 // first index for the mass balance
67 enum { conti0EqIdx = Indices::conti0EqIdx };
68
69 // phase & component indices
70 static constexpr auto liquidPhaseIdx = FluidSystem::phase0Idx;
71 static constexpr auto gasPhaseIdx = FluidSystem::phase1Idx;
72 static constexpr auto liquidCompIdx = FluidSystem::comp0Idx;
73
74public:
75 using ParentType::ParentType;
76
85 NumEqVector computeStorage(const Problem& problem,
86 const SubControlVolume& scv,
87 const VolumeVariables& volVars) const
88 {
89 // TODO: replace by a call to the bass class plus code specific to extended model after release (3.6)
90 // partial time derivative of the phase mass
91 NumEqVector storage(0.0);
92 storage[conti0EqIdx] = volVars.porosity()
93 * volVars.density(liquidPhaseIdx)
94 * volVars.saturation(liquidPhaseIdx);
95
96 // for extended Richards we consider water in air
97 storage[conti0EqIdx] += volVars.porosity()
98 * volVars.molarDensity(gasPhaseIdx)
99 * volVars.moleFraction(gasPhaseIdx, liquidCompIdx)
100 * FluidSystem::molarMass(liquidCompIdx)
101 * volVars.saturation(gasPhaseIdx);
102
104 EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars, liquidPhaseIdx);
105 EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars, gasPhaseIdx);
106 EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
107
108 return storage;
109 }
110
111
122 NumEqVector computeFlux(const Problem& problem,
123 const Element& element,
124 const FVElementGeometry& fvGeometry,
125 const ElementVolumeVariables& elemVolVars,
126 const SubControlVolumeFace& scvf,
127 const ElementFluxVariablesCache& elemFluxVarsCache) const
128 {
129 // TODO: replace by a call to the bass class plus code specific to extended model after release (3.6)
130 FluxVariables fluxVars;
131 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
132
133 NumEqVector flux(0.0);
134 // the physical quantities for which we perform upwinding
135 auto upwindTerm = [](const auto& volVars)
136 { return volVars.density(liquidPhaseIdx)*volVars.mobility(liquidPhaseIdx); };
137
138 flux[conti0EqIdx] = fluxVars.advectiveFlux(liquidPhaseIdx, upwindTerm);
139
140 // for extended Richards we consider water vapor diffusion in air
141 //check for the reference system and adapt units of the diffusive flux accordingly.
142 if (FluxVariables::MolecularDiffusionType::referenceSystemFormulation() == ReferenceSystemFormulation::massAveraged)
143 flux[conti0EqIdx] += fluxVars.molecularDiffusionFlux(gasPhaseIdx)[liquidCompIdx];
144 else
145 flux[conti0EqIdx] += fluxVars.molecularDiffusionFlux(gasPhaseIdx)[liquidCompIdx]*FluidSystem::molarMass(liquidCompIdx);
146
148 EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, liquidPhaseIdx);
149
152 EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
153
154 return flux;
155 }
156};
157
158} // end namespace Dumux
159
160#endif
The reference frameworks and formulations available for splitting total fluxes into a advective and d...
A helper to deduce a vector with the same size as numbers of equations.
Type traits.
The available discretization methods in Dumux.
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:46
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
Element-wise calculation of the Jacobian matrix for problems using the Richards fully implicit models...
Definition: porousmediumflow/richards/localresidual.hh:58
Element-wise calculation of the Jacobian matrix for problems using the extended Richards fully implic...
Definition: porousmediumflow/richardsextended/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/richardsextended/localresidual.hh:85
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:122
Declares all properties used in Dumux.
Element-wise calculation of the Jacobian matrix for problems using the Richards fully implicit models...