GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/solidenergy/volumevariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 14 32 43.8%
Functions: 0 18 0.0%
Branches: 10 22 45.5%

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 SolidEnergyModel
10 * \brief Class for computation of all volume averaged quantities
11 */
12 #ifndef DUMUX_SOLID_ENERGY_VOLUME_VARIABLES_HH
13 #define DUMUX_SOLID_ENERGY_VOLUME_VARIABLES_HH
14
15 #include <type_traits>
16
17 #include <dumux/material/solidstates/updatesolidvolumefractions.hh>
18 #include <dumux/porousmediumflow/volumevariables.hh>
19 #include <dumux/porousmediumflow/nonisothermal/volumevariables.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup SolidEnergyModel
25 * \brief Class for computation of all volume averaged quantities
26 */
27 template<class Traits>
28
0/4
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4189084 class SolidEnergyVolumeVariables : public PorousMediumFlowVolumeVariables<Traits>
29 {
30 using ParentType = PorousMediumFlowVolumeVariables<Traits>;
31 using Scalar = typename Traits::PrimaryVariables::value_type;
32 static constexpr int temperatureIdx = Traits::ModelTraits::Indices::temperatureIdx;
33
34 public:
35 //! export the type used for the solid state
36 using SolidState = typename Traits::SolidState;
37 //! export the type used for the solid system
38 using SolidSystem = typename Traits::SolidSystem;
39
40 /*!
41 * \brief Update all quantities for a given control volume
42 *
43 * \param elemSol A vector containing all primary variables connected to the element
44 * \param problem The object specifying the problem which ought to
45 * be simulated
46 * \param element An element which contains part of the control volume
47 * \param scv The sub-control volume
48 */
49 template<class ElemSol, class Problem, class Element, class Scv>
50 void update(const ElemSol& elemSol,
51 const Problem& problem,
52 const Element& element,
53 const Scv& scv)
54 {
55
1/2
✓ Branch 3 taken 792000 times.
✗ Branch 4 not taken.
1502000 ParentType::update(elemSol, problem, element, scv);
56 3004000 updateTemperature(elemSol, problem, element, scv, solidState_);
57 3004000 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, 0);
58
1/2
✓ Branch 3 taken 792000 times.
✗ Branch 4 not taken.
1502000 updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
59 }
60
61 //! Fill temperature in the solid state
62 template<class ElemSol, class Problem, class Element, class Scv>
63 void updateTemperature(const ElemSol& elemSol,
64 const Problem& problem,
65 const Element& element,
66 const Scv& scv,
67 SolidState& solidState)
68 {
69
1/2
✓ Branch 3 taken 792000 times.
✗ Branch 4 not taken.
1502000 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
70
2/4
✓ Branch 5 taken 792000 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 792000 times.
✗ Branch 9 not taken.
3004000 solidState.setTemperature(T);
71 }
72
73 //! Fill solid matrix parameters in the solid state
74 template<class ElemSol, class Problem, class Element, class Scv>
75 void updateSolidEnergyParams(const ElemSol &elemSol,
76 const Problem& problem,
77 const Element &element,
78 const Scv &scv,
79 SolidState & solidState)
80 {
81 Scalar cs = solidHeatCapacity_(elemSol, problem, element, scv, solidState);
82 solidState.setHeatCapacity(cs);
83
84 Scalar rhos = solidDensity_(elemSol, problem, element, scv, solidState);
85 solidState.setDensity(rhos);
86
87 Scalar lambdas = solidThermalConductivity_(elemSol, problem, element, scv, solidState);
88 solidState.setThermalConductivity(lambdas);
89 }
90
91 /*!
92 * \brief Returns the temperature in the sub-control volume.
93 */
94 Scalar temperatureSolid() const
95 1242128 { return solidState_.temperature(); }
96
97 /*!
98 * \brief Returns the temperature in the sub-control volume.
99 */
100 Scalar temperature() const
101
1/2
✓ Branch 0 taken 3168000 times.
✗ Branch 1 not taken.
6742616 { return solidState_.temperature(); }
102
103 /*!
104 * \brief Returns the total heat capacity \f$\mathrm{[J/(kg K)]}\f$ of the rock matrix in
105 * the sub-control volume.
106 */
107 Scalar solidHeatCapacity() const
108 1238048 { return solidState_.heatCapacity(); }
109
110 /*!
111 * \brief Returns the mass density \f$\mathrm{[kg/m^3]}\f$ of the rock matrix in
112 * the sub-control volume.
113 */
114 Scalar solidDensity() const
115 1238048 { return solidState_.density(); }
116
117 /*!
118 * \brief Returns the thermal conductivity \f$\mathrm{[W/(m*K)]}\f$ of the solid phase in the sub-control volume.
119 */
120 Scalar solidThermalConductivity() const
121
2/4
✓ Branch 0 taken 112320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112320 times.
✗ Branch 3 not taken.
6642160 { return solidState_.thermalConductivity(); }
122
123 /*!
124 * \brief Returns the effective thermal conductivity \f$\mathrm{[W/(m*K)]}\f$
125 * of the solid phase in the sub-control volume. In this case (non-porous) identical to the solidThermalCondutivity.
126 */
127 Scalar effectiveThermalConductivity() const
128
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 75275 times.
6463842 { return solidThermalConductivity(); }
129
130 /*!
131 * \brief Return the average porosity \f$\mathrm{[-]}\f$ within the control volume.
132 */
133 Scalar porosity() const
134 2476096 { return solidState_.porosity(); }
135
136 private:
137 //! the solid state
138 SolidState solidState_;
139
140 /*!
141 * It has to be decided if the full solid system / solid state interface is used (general option, but more complicated),
142 * or the simple nonisothermal spatial params interface (simpler but less general).
143 * In the simple nonisothermal spatial params interface the functions solidHeatCapacity, solidDensity, and solidThermalConductivity
144 * in the spatial params overwrite the parameters given in the solid system. This only makes sense in combination
145 * with the simplest solid system InertSolidPhase, and can be used to quickly change parameters in certain domain regions.
146 * For setups with more general solids with several components these functions should not exist. Instead, the solid system
147 * determines the values for solidHeatCapacity, solidDensity, and solidThermalConductivity depending on the given composition.
148 */
149
150 /*!
151 * \name Access functions for the solidsystem / solidstate interface
152 */
153 // \{
154
155 /*!
156 * \brief get the solid heat capacity in an scv
157 * \param elemSol the element solution vector
158 * \param problem the problem to solve
159 * \param element the element (codim-0-entity) the scv belongs to
160 * \param scv the sub control volume
161 * \param solidState the solid state
162 * \note this gets selected if the user uses the solidsystem / solidstate interface
163 */
164 template<class ElemSol, class Problem, class Element, class Scv,
165 std::enable_if_t<!Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(), int> = 0>
166 Scalar solidHeatCapacity_(const ElemSol& elemSol,
167 const Problem& problem,
168 const Element& element,
169 const Scv& scv,
170 const SolidState& solidState)
171 {
172 return SolidSystem::heatCapacity(solidState);
173 }
174
175 /*!
176 * \brief get the solid density in an scv
177 * \param elemSol the element solution vector
178 * \param problem the problem to solve
179 * \param element the element (codim-0-entity) the scv belongs to
180 * \param scv the sub control volume
181 * \param solidState the solid state
182 * \note this gets selected if the user uses the solidsystem / solidstate interface
183 */
184 template<class ElemSol, class Problem, class Element, class Scv,
185 std::enable_if_t<!Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(), int> = 0>
186 Scalar solidDensity_(const ElemSol& elemSol,
187 const Problem& problem,
188 const Element& element,
189 const Scv& scv,
190 const SolidState& solidState)
191 {
192 return SolidSystem::density(solidState);
193 }
194
195 /*!
196 * \brief get the solid's thermal conductivity in an scv
197 * \param elemSol the element solution vector
198 * \param problem the problem to solve
199 * \param element the element (codim-0-entity) the scv belongs to
200 * \param scv the sub control volume
201 * \param solidState the solid state
202 * \note this gets selected if the user uses the solidsystem / solidstate interface
203 */
204 template<class ElemSol, class Problem, class Element, class Scv,
205 std::enable_if_t<!Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(), int> = 0>
206 Scalar solidThermalConductivity_(const ElemSol& elemSol,
207 const Problem& problem,
208 const Element& element,
209 const Scv& scv,
210 const SolidState& solidState)
211 {
212 return SolidSystem::thermalConductivity(solidState);
213 }
214
215 // \}
216
217 /*!
218 * \name Access functions for the simple nonisothermal spatial params interface in
219 * combination with an InertSolidPhase as solid system
220 */
221 // \{
222
223 /*!
224 * \brief get the solid heat capacity in an scv
225 * \param elemSol the element solution vector
226 * \param problem the problem to solve
227 * \param element the element (codim-0-entity) the scv belongs to
228 * \param scv the sub control volume
229 * \param solidState the solid state
230 * \note this gets selected if the user uses the simple spatial params interface in
231 * combination with an InertSolidPhase as solid system
232 */
233 template<class ElemSol, class Problem, class Element, class Scv,
234 std::enable_if_t<Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(), int> = 0>
235 Scalar solidHeatCapacity_(const ElemSol& elemSol,
236 const Problem& problem,
237 const Element& element,
238 const Scv& scv,
239 const SolidState& solidState)
240 {
241 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
242 "solidHeatCapacity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
243 "If you select a proper solid system, the solid heat capacity will be computed as stated in the solid system!");
244 return problem.spatialParams().solidHeatCapacity(element, scv, elemSol, solidState);
245 }
246
247 /*!
248 * \brief get the solid density in an scv
249 * \param elemSol the element solution vector
250 * \param problem the problem to solve
251 * \param element the element (codim-0-entity) the scv belongs to
252 * \param scv the sub control volume
253 * \param solidState the solid state
254 * \note this gets selected if the user uses the simple spatial params interface in
255 * combination with an InertSolidPhase as solid system
256 */
257 template<class ElemSol, class Problem, class Element, class Scv,
258 std::enable_if_t<Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(), int> = 0>
259 Scalar solidDensity_(const ElemSol& elemSol,
260 const Problem& problem,
261 const Element& element,
262 const Scv& scv,
263 const SolidState& solidState)
264 {
265 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
266 "solidDensity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
267 "If you select a proper solid system, the solid density will be computed as stated in the solid system!");
268 return problem.spatialParams().solidDensity(element, scv, elemSol, solidState);
269 }
270
271 /*!
272 * \brief get the solid's heat capacity in an scv
273 * \param elemSol the element solution vector
274 * \param problem the problem to solve
275 * \param element the element (codim-0-entity) the scv belongs to
276 * \param scv the sub control volume
277 * \param solidState the solid state
278 * \note this gets selected if the user uses the simple spatial params interface in
279 * combination with an InertSolidPhase as solid system
280 */
281 template<class ElemSol, class Problem, class Element, class Scv,
282 std::enable_if_t<Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(), int> = 0>
283 Scalar solidThermalConductivity_(const ElemSol& elemSol,
284 const Problem& problem,
285 const Element& element,
286 const Scv& scv,
287 const SolidState& solidState)
288 {
289 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
290 "solidThermalConductivity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
291 "If you select a proper solid system, the solid thermal conductivity will be computed as stated in the solid system!");
292 return problem.spatialParams().solidThermalConductivity(element, scv, elemSol, solidState);
293 }
294
295 // \}
296
297 };
298
299 } // end namespace Dumux
300
301 #endif
302