3.1-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
30
31namespace Dumux {
36template<class TypeTag>
38{
43 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
45 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
46 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
47 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
48 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
50 using Element = typename GridView::template Codim<0>::Entity;
53
55
56public:
58 using ParentType::ParentType;
59
61 NumEqVector computeStorage(const Problem& problem,
62 const SubControlVolume& scv,
63 const VolumeVariables& volVars) const
64 {
65 NumEqVector storage(0.0);
66 // Compute storage term of all components within all phases
67 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
68 {
69 storage[Indices::conti0EqIdx] +=
70 volVars.porosity()
71 * volVars.saturation(phaseIdx) * volVars.density(phaseIdx);
72
73 EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars, phaseIdx);
74 }
75
76 // The energy storage in the solid matrix
77 EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
78
79 return storage;
80 }
81
83 NumEqVector computeFlux(const Problem& problem,
84 const Element& element,
85 const FVElementGeometry& fvGeometry,
86 const ElementVolumeVariables& elemVolVars,
87 const SubControlVolumeFace& scvf,
88 const ElementFluxVariablesCache& elemFluxVarsCache) const
89 {
90 FluxVariables fluxVars;
91 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
92
93 NumEqVector flux;
94 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
95 {
96 // The physical quantities for which we perform upwinding
97 auto upwindTerm = [phaseIdx](const auto& volVars)
98 { return volVars.density(phaseIdx)*volVars.mobility(phaseIdx); };
99
100 flux[Indices::conti0EqIdx] += fluxVars.advectiveFlux(phaseIdx, upwindTerm);
101
102 // Add advective phase energy fluxes. For isothermal model the contribution is zero.
103 EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx);
104 }
105
106 // Add diffusive energy fluxes. For isothermal model the contribution is zero.
107 EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
108
109 return flux;
110 }
111};
112
113} // end namespace Dumux
114
115#endif
make the local view function available whenever we use the grid geometry
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 the fully implicit two-phase one-component flow model.
Definition: porousmediumflow/2p1c/localresidual.hh:38
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:83
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:61
Element-wise calculation of the residual for problems using the n-phase immiscible fully implicit mod...
Definition: porousmediumflow/immiscible/localresidual.hh:39
Element-wise calculation of the residual for problems using the n-phase immiscible fully implicit mod...