version 3.10-dev
porousmediumflow/nonisothermal/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_ENERGY_LOCAL_RESIDUAL_HH
15#define DUMUX_ENERGY_LOCAL_RESIDUAL_HH
16
19
20namespace Dumux {
21
22// forward declaration
23template<class TypeTag, bool enableEneryBalance>
25
26template<class TypeTag>
28
33template<class TypeTag>
35{
40 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
41 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
43
44public:
45 static void fluidPhaseStorage(NumEqVector& storage,
46 const SubControlVolume& scv,
47 const VolumeVariables& volVars,
48 int phaseIdx)
49 {
50 static_assert("Deprecated interface that has been removed!");
51 }
52
56 static void fluidPhaseStorage(NumEqVector& storage,
57 const Problem& problem,
58 const SubControlVolume& scv,
59 const VolumeVariables& volVars,
60 int phaseIdx)
61 {}
62
70 static void solidPhaseStorage(NumEqVector& storage,
71 const SubControlVolume& scv,
72 const VolumeVariables& volVars)
73 {}
74
82 static void heatConvectionFlux(NumEqVector& flux,
83 FluxVariables& fluxVars,
84 int phaseIdx)
85 {}
86
93 static void heatConductionFlux(NumEqVector& flux,
94 FluxVariables& fluxVars)
95 {}
96
103 static void heatDispersionFlux(NumEqVector& flux,
104 FluxVariables& fluxVars)
105 {}
106};
107
112template<class TypeTag>
114{
119 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
120 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
123 using Element = typename GridView::template Codim<0>::Entity;
124 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
126 using Indices = typename ModelTraits::Indices;
127
128 static constexpr int numPhases = ModelTraits::numFluidPhases();
129 enum { energyEqIdx = Indices::energyEqIdx };
130
131public:
132
136 static void fluidPhaseStorage(NumEqVector& storage,
137 const Problem& problem,
138 const SubControlVolume& scv,
139 const VolumeVariables& volVars,
140 int phaseIdx)
141 {
142 // this implementation of the potential energy contribution is only correct
143 // if gravity vector is constant in space and time
144 const auto& x = scv.dofPosition();
145 const auto gravityPotential = x*problem.spatialParams().gravity(x);
146
147 storage[energyEqIdx] += volVars.porosity()
148 * volVars.density(phaseIdx)
149 * volVars.saturation(phaseIdx)
150 * (volVars.internalEnergy(phaseIdx) - gravityPotential);
151 }
152
153 static void fluidPhaseStorage(NumEqVector& storage,
154 const SubControlVolume& scv,
155 const VolumeVariables& volVars,
156 int phaseIdx)
157 {
158 static_assert("Deprecated interface that has been removed!");
159 }
160
168 static void solidPhaseStorage(NumEqVector& storage,
169 const SubControlVolume& scv,
170 const VolumeVariables& volVars)
171 {
172 storage[energyEqIdx] += volVars.temperature()
173 * volVars.solidHeatCapacity()
174 * volVars.solidDensity()
175 * (1.0 - volVars.porosity());
176 }
177
185 static void heatConvectionFlux(NumEqVector& flux,
186 FluxVariables& fluxVars,
187 int phaseIdx)
188 {
189 // this implementation of the potential energy contribution is only correct
190 // if gravity vector is constant in space and time
191 const auto& x = fluxVars.scvFace().ipGlobal();
192 const auto gravityPotential = x*fluxVars.problem().spatialParams().gravity(x);
193
194 auto upwindTerm = [=](const auto& volVars){
195 return volVars.density(phaseIdx)*volVars.mobility(phaseIdx)
196 * (volVars.enthalpy(phaseIdx) - gravityPotential);
197 };
198
199 flux[energyEqIdx] += fluxVars.advectiveFlux(phaseIdx, upwindTerm);
200 }
201
208 static void heatConductionFlux(NumEqVector& flux,
209 FluxVariables& fluxVars)
210 {
211 flux[energyEqIdx] += fluxVars.heatConductionFlux();
212 }
213
220 static void heatDispersionFlux(NumEqVector& flux,
221 FluxVariables& fluxVars)
222 {
223
224 if constexpr (ModelTraits::enableThermalDispersion())
225 {
226 flux[energyEqIdx] += fluxVars.thermalDispersionFlux();
227 }
228 }
229
230
240 static void computeSourceEnergy(NumEqVector& source,
241 const Element& element,
242 const FVElementGeometry& fvGeometry,
243 const ElementVolumeVariables& elemVolVars,
244 const SubControlVolume &scv)
245 {}
246};
247
248} // end namespace Dumux
249
250#endif
static void heatDispersionFlux(NumEqVector &flux, FluxVariables &fluxVars)
The dispersive energy fluxes.
Definition: porousmediumflow/nonisothermal/localresidual.hh:103
static void heatConductionFlux(NumEqVector &flux, FluxVariables &fluxVars)
The diffusive energy fluxes.
Definition: porousmediumflow/nonisothermal/localresidual.hh:93
static void fluidPhaseStorage(NumEqVector &storage, const SubControlVolume &scv, const VolumeVariables &volVars, int phaseIdx)
Definition: porousmediumflow/nonisothermal/localresidual.hh:45
static void fluidPhaseStorage(NumEqVector &storage, const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars, int phaseIdx)
The energy storage in the fluid phase with index phaseIdx.
Definition: porousmediumflow/nonisothermal/localresidual.hh:56
static void heatConvectionFlux(NumEqVector &flux, FluxVariables &fluxVars, int phaseIdx)
The advective phase energy fluxes.
Definition: porousmediumflow/nonisothermal/localresidual.hh:82
static void solidPhaseStorage(NumEqVector &storage, const SubControlVolume &scv, const VolumeVariables &volVars)
The energy storage in the solid matrix.
Definition: porousmediumflow/nonisothermal/localresidual.hh:70
static void solidPhaseStorage(NumEqVector &storage, const SubControlVolume &scv, const VolumeVariables &volVars)
The energy storage in the solid matrix.
Definition: porousmediumflow/nonisothermal/localresidual.hh:168
static void fluidPhaseStorage(NumEqVector &storage, const SubControlVolume &scv, const VolumeVariables &volVars, int phaseIdx)
Definition: porousmediumflow/nonisothermal/localresidual.hh:153
static void heatConductionFlux(NumEqVector &flux, FluxVariables &fluxVars)
The diffusive energy fluxes.
Definition: porousmediumflow/nonisothermal/localresidual.hh:208
static void heatDispersionFlux(NumEqVector &flux, FluxVariables &fluxVars)
The dispersive energy fluxes.
Definition: porousmediumflow/nonisothermal/localresidual.hh:220
static void fluidPhaseStorage(NumEqVector &storage, const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars, int phaseIdx)
The energy storage in the fluid phase with index phaseIdx.
Definition: porousmediumflow/nonisothermal/localresidual.hh:136
static void computeSourceEnergy(NumEqVector &source, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv)
heat transfer between the phases for nonequilibrium models
Definition: porousmediumflow/nonisothermal/localresidual.hh:240
static void heatConvectionFlux(NumEqVector &flux, FluxVariables &fluxVars, int phaseIdx)
The advective phase energy fluxes.
Definition: porousmediumflow/nonisothermal/localresidual.hh:185
Definition: porousmediumflow/nonisothermal/localresidual.hh:24
Defines all properties used in Dumux.
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.