3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/2p1c/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_2P1C_LOCAL_RESIDUAL_HH
27#define DUMUX_2P1C_LOCAL_RESIDUAL_HH
28
31
32namespace Dumux {
37template<class TypeTag>
39{
44 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
46 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
47 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
48 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
49 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
51 using Element = typename GridView::template Codim<0>::Entity;
54
56
57public:
59 using ParentType::ParentType;
60
62 NumEqVector computeStorage(const Problem& problem,
63 const SubControlVolume& scv,
64 const VolumeVariables& volVars) const
65 {
66 NumEqVector storage(0.0);
67 // Compute storage term of all components within all phases
68 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
69 {
70 storage[Indices::conti0EqIdx] +=
71 volVars.porosity()
72 * volVars.saturation(phaseIdx) * volVars.density(phaseIdx);
73
74 EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars, phaseIdx);
75 }
76
77 // The energy storage in the solid matrix
78 EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
79
80 return storage;
81 }
82
84 NumEqVector computeFlux(const Problem& problem,
85 const Element& element,
86 const FVElementGeometry& fvGeometry,
87 const ElementVolumeVariables& elemVolVars,
88 const SubControlVolumeFace& scvf,
89 const ElementFluxVariablesCache& elemFluxVarsCache) const
90 {
91 FluxVariables fluxVars;
92 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
93
94 NumEqVector flux;
95 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
96 {
97 // The physical quantities for which we perform upwinding
98 auto upwindTerm = [phaseIdx](const auto& volVars)
99 { return volVars.density(phaseIdx)*volVars.mobility(phaseIdx); };
100
101 flux[Indices::conti0EqIdx] += fluxVars.advectiveFlux(phaseIdx, upwindTerm);
102
103 // Add advective phase energy fluxes. For isothermal model the contribution is zero.
104 EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx);
105 }
106
107 // Add diffusive energy fluxes. For isothermal model the contribution is zero.
108 EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
109
110 return flux;
111 }
112};
113
114} // end namespace Dumux
115
116#endif
A helper to deduce a vector with the same size as numbers of equations.
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
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
Element-wise calculation of the residual for the fully implicit two-phase one-component flow model.
Definition: porousmediumflow/2p1c/localresidual.hh:39
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluate the fluxes over a face of a sub control volume.
Definition: porousmediumflow/2p1c/localresidual.hh:84
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Evaluate the storage term within a given scv.
Definition: porousmediumflow/2p1c/localresidual.hh:62
Element-wise calculation of the residual for problems using the n-phase immiscible fully implicit mod...
Definition: porousmediumflow/immiscible/localresidual.hh:40
Element-wise calculation of the residual for problems using the n-phase immiscible fully implicit mod...