version 3.8
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// 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_2P1C_LOCAL_RESIDUAL_HH
15#define DUMUX_2P1C_LOCAL_RESIDUAL_HH
16
19
20namespace Dumux {
25template<class TypeTag>
27{
32 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
34 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
35 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
36 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
37 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
39 using Element = typename GridView::template Codim<0>::Entity;
42
44
45public:
47 using ParentType::ParentType;
48
50 NumEqVector computeStorage(const Problem& problem,
51 const SubControlVolume& scv,
52 const VolumeVariables& volVars) const
53 {
54 NumEqVector storage(0.0);
55 // Compute storage term of all components within all phases
56 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
57 {
58 storage[Indices::conti0EqIdx] +=
59 volVars.porosity()
60 * volVars.saturation(phaseIdx) * volVars.density(phaseIdx);
61
62 EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars, phaseIdx);
63 }
64
65 // The energy storage in the solid matrix
66 EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
67
68 return storage;
69 }
70
72 NumEqVector computeFlux(const Problem& problem,
73 const Element& element,
74 const FVElementGeometry& fvGeometry,
75 const ElementVolumeVariables& elemVolVars,
76 const SubControlVolumeFace& scvf,
77 const ElementFluxVariablesCache& elemFluxVarsCache) const
78 {
79 FluxVariables fluxVars;
80 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
81
82 NumEqVector flux;
83 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
84 {
85 // The physical quantities for which we perform upwinding
86 auto upwindTerm = [phaseIdx](const auto& volVars)
87 { return volVars.density(phaseIdx)*volVars.mobility(phaseIdx); };
88
89 flux[Indices::conti0EqIdx] += fluxVars.advectiveFlux(phaseIdx, upwindTerm);
90
91 // Add advective phase energy fluxes. For isothermal model the contribution is zero.
92 EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx);
93 }
94
95 // Add diffusive energy fluxes. For isothermal model the contribution is zero.
96 EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
97
98 return flux;
99 }
100};
101
102} // end namespace Dumux
103
104#endif
Element-wise calculation of the residual for problems using the n-phase immiscible fully implicit mod...
Definition: porousmediumflow/immiscible/localresidual.hh:28
Element-wise calculation of the residual for the fully implicit two-phase one-component flow model.
Definition: porousmediumflow/2p1c/localresidual.hh:27
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:72
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:50
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
Definition: adapt.hh:17
A helper to deduce a vector with the same size as numbers of equations.
Element-wise calculation of the residual for problems using the n-phase immiscible fully implicit mod...