GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/nonisothermal/localresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 13 29 44.8%
Functions: 0 969 0.0%
Branches: 12 28 42.9%

Line Branch Exec Source
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 //
7 /*!
8 * \file
9 * \ingroup NIModel
10 * \brief Element-wise calculation of the local residual for non-isothermal
11 * fully implicit models.
12 */
13
14 #ifndef DUMUX_ENERGY_LOCAL_RESIDUAL_HH
15 #define DUMUX_ENERGY_LOCAL_RESIDUAL_HH
16
17 #include <dumux/common/properties.hh>
18 #include <dumux/common/numeqvector.hh>
19
20 namespace Dumux {
21
22 // forward declaration
23 template<class TypeTag, bool enableEneryBalance>
24 class EnergyLocalResidualImplementation;
25
26 template<class TypeTag>
27 using EnergyLocalResidual = EnergyLocalResidualImplementation<TypeTag, GetPropType<TypeTag, Properties::ModelTraits>::enableEnergyBalance()>;
28
29 /*!
30 * \ingroup NIModel
31 * \brief Element-wise calculation of the energy residual for non-isothermal problems.
32 */
33 template<class TypeTag>
34 class EnergyLocalResidualImplementation<TypeTag, false>
35 {
36 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
37 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
38 using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>;
39 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
40 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
41 using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
42
43 public:
44 /*!
45 * \brief The energy storage in the fluid phase with index phaseIdx.
46 *
47 * \param storage The mass of the component within the sub-control volume
48 * \param scv The sub-control volume
49 * \param volVars The volume variables
50 * \param phaseIdx The phase index
51 */
52 static void fluidPhaseStorage(NumEqVector& storage,
53 const SubControlVolume& scv,
54 const VolumeVariables& volVars,
55 int phaseIdx)
56 {}
57
58 /*!
59 * \brief The energy storage in the solid matrix.
60 *
61 * \param storage The mass of the component within the sub-control volume
62 * \param scv The sub-control volume
63 * \param volVars The volume variables
64 */
65 static void solidPhaseStorage(NumEqVector& storage,
66 const SubControlVolume& scv,
67 const VolumeVariables& volVars)
68 {}
69
70 /*!
71 * \brief The advective phase energy fluxes.
72 *
73 * \param flux The flux
74 * \param fluxVars The flux variables.
75 * \param phaseIdx The phase index
76 */
77 static void heatConvectionFlux(NumEqVector& flux,
78 FluxVariables& fluxVars,
79 int phaseIdx)
80 {}
81
82 /*!
83 * \brief The diffusive energy fluxes
84 *
85 * \param flux The flux
86 * \param fluxVars The flux variables.
87 */
88 static void heatConductionFlux(NumEqVector& flux,
89 FluxVariables& fluxVars)
90 {}
91
92 /*!
93 * \brief The dispersive energy fluxes
94 *
95 * \param flux The flux
96 * \param fluxVars The flux variables.
97 */
98 static void heatDispersionFlux(NumEqVector& flux,
99 FluxVariables& fluxVars)
100 {}
101 };
102
103 /*!
104 * \ingroup NIModel
105 * \brief TODO docme!
106 */
107 template<class TypeTag>
108 class EnergyLocalResidualImplementation<TypeTag, true>
109 {
110 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
111 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
112 using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>;
113 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
114 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
115 using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
116 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
117 using Element = typename GridView::template Codim<0>::Entity;
118 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
119 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
120 using Indices = typename ModelTraits::Indices;
121
122 static constexpr int numPhases = ModelTraits::numFluidPhases();
123 enum { energyEqIdx = Indices::energyEqIdx };
124
125 public:
126
127 /*!
128 * \brief The energy storage in the fluid phase with index phaseIdx
129 *
130 * \param storage The mass of the component within the sub-control volume
131 * \param scv The sub-control volume
132 * \param volVars The volume variables
133 * \param phaseIdx The phase index
134 */
135 static void fluidPhaseStorage(NumEqVector& storage,
136 const SubControlVolume& scv,
137 const VolumeVariables& volVars,
138 int phaseIdx)
139 {
140 594741928 storage[energyEqIdx] += volVars.porosity()
141 1182688616 * volVars.density(phaseIdx)
142 594741928 * volVars.internalEnergy(phaseIdx)
143 1148340632 * volVars.saturation(phaseIdx);
144 }
145
146 /*!
147 * \brief The energy storage in the solid matrix
148 *
149 * \param storage The mass of the component within the sub-control volume
150 * \param scv The sub-control volume
151 * \param volVars The volume variables
152 */
153 static void solidPhaseStorage(NumEqVector& storage,
154 const SubControlVolume& scv,
155 const VolumeVariables& volVars)
156 {
157 576405752 storage[energyEqIdx] += volVars.temperature()
158 864159468 * volVars.solidHeatCapacity()
159 575956592 * volVars.solidDensity()
160 575956592 * (1.0 - volVars.porosity());
161 }
162
163 /*!
164 * \brief The advective phase energy fluxes
165 *
166 * \param flux The flux
167 * \param fluxVars The flux variables.
168 * \param phaseIdx The phase index
169 */
170 static void heatConvectionFlux(NumEqVector& flux,
171 FluxVariables& fluxVars,
172 int phaseIdx)
173 {
174 2702259102 auto upwindTerm = [phaseIdx](const auto& volVars)
175
12/28
✓ Branch 0 taken 856843 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 856843 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 856843 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 856843 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 856843 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 856843 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1171412 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1171412 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1171412 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1171412 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1171412 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1171412 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
3221448528 { return volVars.density(phaseIdx)*volVars.mobility(phaseIdx)*volVars.enthalpy(phaseIdx); };
176
177 402681066 flux[energyEqIdx] += fluxVars.advectiveFlux(phaseIdx, upwindTerm);
178 }
179
180 /*!
181 * \brief The diffusive energy fluxes
182 *
183 * \param flux The flux
184 * \param fluxVars The flux variables.
185 */
186 static void heatConductionFlux(NumEqVector& flux,
187 FluxVariables& fluxVars)
188 {
189 206095285 flux[energyEqIdx] += fluxVars.heatConductionFlux();
190 }
191
192 /*!
193 * \brief The dispersive energy fluxes
194 *
195 * \param flux The flux
196 * \param fluxVars The flux variables.
197 */
198 static void heatDispersionFlux(NumEqVector& flux,
199 FluxVariables& fluxVars)
200 {
201
202 if constexpr (ModelTraits::enableThermalDispersion())
203 {
204 5600000 flux[energyEqIdx] += fluxVars.thermalDispersionFlux();
205 }
206 }
207
208
209 /*!
210 * \brief heat transfer between the phases for nonequilibrium models
211 *
212 * \param source The source which ought to be simulated
213 * \param element An element which contains part of the control volume
214 * \param fvGeometry The finite-volume geometry
215 * \param elemVolVars The volume variables of the current element
216 * \param scv The sub-control volume over which we integrate the source term
217 */
218 static void computeSourceEnergy(NumEqVector& source,
219 const Element& element,
220 const FVElementGeometry& fvGeometry,
221 const ElementVolumeVariables& elemVolVars,
222 const SubControlVolume &scv)
223 {}
224 };
225
226 } // end namespace Dumux
227
228 #endif
229