3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/immiscible/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 *****************************************************************************/
25#ifndef DUMUX_IMMISCIBLE_LOCAL_RESIDUAL_HH
26#define DUMUX_IMMISCIBLE_LOCAL_RESIDUAL_HH
27
29
30namespace Dumux {
31
37template<class TypeTag>
38class ImmiscibleLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual>
39{
45 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
47 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
48 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
49 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
50 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
52 using Element = typename GridView::template Codim<0>::Entity;
54
56 static constexpr int numPhases = ModelTraits::numFluidPhases();
57 static constexpr int conti0EqIdx = ModelTraits::Indices::conti0EqIdx;
58
59public:
60 using ParentType::ParentType;
61
74 NumEqVector computeStorage(const Problem& problem,
75 const SubControlVolume& scv,
76 const VolumeVariables& volVars) const
77 {
78 // partial time derivative of the phase mass
79 NumEqVector storage;
80 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
81 {
82 auto eqIdx = conti0EqIdx + phaseIdx;
83 storage[eqIdx] = volVars.porosity()
84 * volVars.density(phaseIdx)
85 * volVars.saturation(phaseIdx);
86
88 EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars, phaseIdx);
89 }
90
92 EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
93
94 return storage;
95 }
96
97
108 NumEqVector computeFlux(const Problem& problem,
109 const Element& element,
110 const FVElementGeometry& fvGeometry,
111 const ElementVolumeVariables& elemVolVars,
112 const SubControlVolumeFace& scvf,
113 const ElementFluxVariablesCache& elemFluxVarsCache) const
114 {
115 FluxVariables fluxVars;
116 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
117
118 NumEqVector flux;
119 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
120 {
121 // the physical quantities for which we perform upwinding
122 auto upwindTerm = [phaseIdx](const auto& volVars)
123 { return volVars.density(phaseIdx)*volVars.mobility(phaseIdx); };
124
125 auto eqIdx = conti0EqIdx + phaseIdx;
126 flux[eqIdx] = fluxVars.advectiveFlux(phaseIdx, upwindTerm);
127
129 EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx);
130 }
131
133 EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
134
135 return flux;
136 }
137};
138
139} // end namespace Dumux
140
141#endif
Definition: adapt.hh:29
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:149
Element-wise calculation of the residual for problems using the n-phase immiscible fully implicit mod...
Definition: porousmediumflow/immiscible/localresidual.hh:39
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluatex the mass flux over a face of a sub control volume.
Definition: porousmediumflow/immiscible/localresidual.hh:108
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Evaluatex the rate of change of all conservation quantites (e.g. phase mass) within a sub-control vol...
Definition: porousmediumflow/immiscible/localresidual.hh:74
Declares all properties used in Dumux.