GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/freeflow/volumevariables.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 27 27 100.0%
Functions: 0 0 -%
Branches: 33 57 57.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-FileCopyrightText: 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
1/2
✓ Branch 1 taken 113708 times.
✗ Branch 2 not taken.
228121 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 109958820 void update(const ElementSolution &elemSol,
63 const Problem &problem,
64 const Element &element,
65 const SubControlVolume& scv)
66 {
67
8/15
✓ Branch 1 taken 735280 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3475880 times.
✓ Branch 5 taken 20 times.
✓ Branch 7 taken 18260 times.
✓ Branch 8 taken 105 times.
✓ Branch 10 taken 1393340 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 37120 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 334400 times.
✗ Branch 17 not taken.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
109956870 priVars_ = elemSol[scv.localDofIndex()];
68
10/19
✗ Branch 3 not taken.
✓ Branch 4 taken 3475880 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 18260 times.
✓ Branch 9 taken 105 times.
✓ Branch 10 taken 1393340 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 37120 times.
✓ Branch 15 taken 20 times.
✓ Branch 16 taken 334400 times.
✓ Branch 18 taken 105 times.
✗ Branch 19 not taken.
✓ Branch 1 taken 735280 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✗ Branch 8 not taken.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
109958820 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 2176089156 Scalar extrusionFactor() const
81
8/9
✓ Branch 3 taken 73365082 times.
✓ Branch 4 taken 84327518 times.
✓ Branch 5 taken 2732579 times.
✓ Branch 6 taken 46609670 times.
✓ Branch 0 taken 927985116 times.
✓ Branch 1 taken 21589404 times.
✓ Branch 2 taken 163996024 times.
✓ Branch 8 taken 2528 times.
✗ Branch 9 not taken.
2170686346 { 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 66063900 static Scalar temperature(const ElementSolution &elemSol,
94 const Problem& problem,
95 const Element &element,
96 const SubControlVolume &scv)
97 {
98 66063900 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
1/2
✓ Branch 1 taken 20640 times.
✗ Branch 2 not taken.
21997 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 43894920 void update(const ElemSol &elemSol,
148 const Problem &problem,
149 const Element &element,
150 const Scv &scv)
151 {
152
2/6
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 105 times.
✗ Branch 9 not taken.
43894920 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 22259304 Scalar internalEnergy(int phaseIdx = 0) const
160 22259304 { 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 62317674 Scalar enthalpy(int phaseIdx = 0) const
167
3/4
✓ Branch 0 taken 12248 times.
✓ Branch 1 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48356 times.
62317674 { 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 52439436 Scalar componentEnthalpy(unsigned int compIdx) const
173 52439436 { 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 50597852 Scalar thermalConductivity() const
180 119139412 { 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 2846868 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 43053422 Scalar heatCapacity() const
196 43053422 { 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 43894920 static Scalar temperature(const ElemSol &elemSol,
201 const Problem& problem,
202 const Element &element,
203 const Scv &scv)
204 {
205 43894920 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 43894920 static Scalar enthalpy(const FluidState& fluidState,
212 const ParameterCache& paramCache)
213 {
214 43894920 return FluidSystem::enthalpy(fluidState, paramCache, 0);
215 }
216 };
217 } // end namespace Dumux
218
219 #endif
220