GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/volumevariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 14 29 48.3%
Functions: 0 269 0.0%
Branches: 45 147 30.6%

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 FreeflowModels
10 *
11 * \copydoc Dumux::FreeFlowVolumeVariables
12 */
13 #ifndef DUMUX_FREEFLOW_VOLUME_VARIABLES_HH
14 #define DUMUX_FREEFLOW_VOLUME_VARIABLES_HH
15
16 #include <dumux/material/fluidstates/immiscible.hh>
17
18 namespace Dumux {
19
20 // forward declaration
21 template <class Traits, class Impl, bool enableEnergyBalance>
22 class FreeFlowVolumeVariablesImplementation;
23
24 /*!
25 * \ingroup FreeflowModels
26 * \brief Volume variables for free-flow models.
27 * The class is specialized for isothermal and non-isothermal models.
28 */
29 template <class Traits, class Impl>
30 using FreeFlowVolumeVariables = FreeFlowVolumeVariablesImplementation<Traits, Impl, Traits::ModelTraits::enableEnergyBalance()>;
31
32 /*!
33 * \ingroup FreeflowModels
34 * \brief Volume variables for isothermal free-flow models.
35 */
36 template <class Traits, class Impl>
37
2/4
✓ Branch 1 taken 113612 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 113612 times.
✗ Branch 5 not taken.
295226 class FreeFlowVolumeVariablesImplementation<Traits, Impl, false>
38 {
39 using Scalar = typename Traits::PrimaryVariables::value_type;
40
41 public:
42 //! export the type used for the primary variables
43 using PrimaryVariables = typename Traits::PrimaryVariables;
44 //! export the type encapsulating primary variable indices
45 using Indices = typename Traits::ModelTraits::Indices;
46
47 //! return number of phases considered by the model
48 static constexpr int numFluidPhases() { return Traits::ModelTraits::numFluidPhases(); }
49 //! return number of components considered by the model
50 static constexpr int numFluidComponents() { return Traits::ModelTraits::numFluidComponents(); }
51
52 /*!
53 * \brief Update all quantities for a given control volume
54 *
55 * \param elemSol A vector containing all primary variables connected to the element
56 * \param problem The object specifying the problem which ought to
57 * be simulated
58 * \param element An element which contains part of the control volume
59 * \param scv The sub-control volume
60 */
61 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
62 void update(const ElementSolution &elemSol,
63 const Problem &problem,
64 const Element &element,
65 const SubControlVolume& scv)
66 {
67 109924412 priVars_ = elemSol[scv.localDofIndex()];
68
28/52
✓ Branch 1 taken 735280 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 735280 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 735280 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 307760 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 307760 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 307760 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3186380 times.
✓ Branch 20 taken 20 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 3186380 times.
✓ Branch 23 taken 20 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 3186380 times.
✓ Branch 26 taken 20 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1319840 times.
✓ Branch 29 taken 105 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 1393340 times.
✓ Branch 32 taken 105 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 1393340 times.
✓ Branch 35 taken 105 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 110620 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 37120 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 37120 times.
✓ Branch 44 taken 20 times.
✗ Branch 45 not taken.
✓ Branch 47 taken 20 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 334400 times.
✓ Branch 50 taken 105 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 334400 times.
✓ Branch 53 taken 105 times.
✗ Branch 54 not taken.
✓ Branch 55 taken 334400 times.
✗ Branch 56 not taken.
285878316 extrusionFactor_ = problem.spatialParams().extrusionFactor(element, scv, elemSol);
69 }
70
71 /*!
72 * \brief Return how much the sub-control volume is extruded.
73 *
74 * This means the factor by which a lower-dimensional (1D or 2D)
75 * entity needs to be expanded to get a full dimensional cell. The
76 * default is 1.0 which means that 1D problems are actually
77 * thought as pipes with a cross section of 1 m^2 and 2D problems
78 * are assumed to extend 1 m to the back.
79 */
80 Scalar extrusionFactor() const
81 { return extrusionFactor_; }
82
83 /*!
84 * \brief Return a component of primary variable vector
85 *
86 * \param pvIdx The index of the primary variable of interest
87 */
88 Scalar priVar(const int pvIdx) const
89 { return priVars_[pvIdx]; }
90
91 //! The temperature is obtained from the problem as a constant for isothermal models
92 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
93 static Scalar temperature(const ElementSolution &elemSol,
94 const Problem& problem,
95 const Element &element,
96 const SubControlVolume &scv)
97 {
98
0/27
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
43811290 return problem.spatialParams().temperature(element, scv, elemSol);
99 }
100
101 //! The phase enthalpy is zero for isothermal models
102 //! This is needed for completing the fluid state
103 template<class FluidState, class ParameterCache>
104 static Scalar enthalpy(const FluidState& fluidState,
105 const ParameterCache& paramCache)
106 {
107 return 0;
108 }
109
110 protected:
111 const Impl &asImp_() const { return *static_cast<const Impl*>(this); }
112 Impl &asImp_() { return *static_cast<Impl*>(this); }
113 PrimaryVariables priVars_;
114 Scalar extrusionFactor_;
115 };
116
117 /*!
118 * \ingroup FreeflowModels
119 * \brief Volume variables for the non-isothermal free-flow models.
120 */
121 template <class Traits, class Impl>
122
2/4
✓ Branch 1 taken 20640 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20640 times.
✗ Branch 5 not taken.
43986 class FreeFlowVolumeVariablesImplementation<Traits, Impl, true>
123 : public FreeFlowVolumeVariablesImplementation<Traits, Impl, false>
124 {
125 using ParentType = FreeFlowVolumeVariablesImplementation<Traits, Impl, false>;
126 using Scalar = typename Traits::PrimaryVariables::value_type;
127
128 public:
129 //! export the type used for the primary variables
130 using PrimaryVariables = typename Traits::PrimaryVariables;
131 //! export the underlying fluid system
132 using FluidSystem = typename Traits::FluidSystem;
133 //! export the type encapsulating primary variable indices
134 using Indices = typename Traits::ModelTraits::Indices;
135
136
137 /*!
138 * \brief Update all quantities for a given control volume
139 *
140 * \param elemSol A vector containing all primary variables connected to the element
141 * \param problem The object specifying the problem which ought to
142 * be simulated
143 * \param element An element which contains part of the control volume
144 * \param scv The sub control volume which is inside the element
145 */
146 template<class ElemSol, class Problem, class Element, class Scv>
147 void update(const ElemSol &elemSol,
148 const Problem &problem,
149 const Element &element,
150 const Scv &scv)
151 {
152
4/12
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 11 taken 20 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 20 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 105 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 105 times.
✗ Branch 21 not taken.
87789840 ParentType::update(elemSol, problem, element, scv);
153 }
154
155 /*!
156 * \brief Returns the total internal energy of a phase in the
157 * sub-control volume.
158 */
159 Scalar internalEnergy(int phaseIdx = 0) const
160 54055920 { return ParentType::asImp_().fluidState().internalEnergy(0); }
161
162 /*!
163 * \brief Returns the total enthalpy of a phase in the sub-control
164 * volume.
165 */
166 Scalar enthalpy(int phaseIdx = 0) const
167
9/12
✓ Branch 0 taken 12248 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 12248 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 12248 times.
✓ Branch 5 taken 72 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 48356 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 48356 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 48356 times.
301649456 { return ParentType::asImp_().fluidState().enthalpy(0); }
168
169 /*!
170 * \brief Returns the component enthalpy \f$\mathrm{[J/(kg*K)]}\f$ in the sub-control volume.
171 */
172 Scalar componentEnthalpy(unsigned int compIdx) const
173 104878872 { return FluidSystem::componentEnthalpy(ParentType::asImp_().fluidState(), 0, compIdx); }
174
175 /*!
176 * \brief Returns the thermal conductivity \f$\mathrm{[W/(m*K)]}\f$
177 * of the fluid phase in the sub-control volume.
178 */
179 Scalar thermalConductivity() const
180 285751086 { return FluidSystem::thermalConductivity(ParentType::asImp_().fluidState(), 0); }
181
182 /*!
183 * \brief Returns the effective thermal conductivity \f$\mathrm{[W/(m*K)]}\f$
184 * of the fluid-flow in the sub-control volume.
185 */
186 Scalar effectiveThermalConductivity() const
187 {
188 2846868 return thermalConductivity();
189 }
190
191 /*!
192 * \brief Return the specific isobaric heat capacity \f$\mathrm{[J/(kg*K)]}\f$
193 * in the sub-control volume.
194 */
195 Scalar heatCapacity() const
196 110970776 { return FluidSystem::heatCapacity(ParentType::asImp_().fluidState(), 0); }
197
198 //! The temperature is a primary variable for non-isothermal models
199 template<class ElemSol, class Problem, class Element, class Scv>
200 static Scalar temperature(const ElemSol &elemSol,
201 const Problem& problem,
202 const Element &element,
203 const Scv &scv)
204 {
205
0/24
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
38060026 return elemSol[scv.localDofIndex()][Indices::temperatureIdx];
206 }
207
208 //! The phase enthalpy is zero for isothermal models
209 //! This is needed for completing the fluid state
210 template<class FluidState, class ParameterCache>
211 static Scalar enthalpy(const FluidState& fluidState,
212 const ParameterCache& paramCache)
213 {
214
0/12
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
19030013 return FluidSystem::enthalpy(fluidState, paramCache, 0);
215 }
216 };
217 } // end namespace Dumux
218
219 #endif
220