GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/lowrekepsilon/volumevariables.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 31 50 62.0%
Functions: 20 80 25.0%
Branches: 4 22 18.2%

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 LowReKEpsilonModel
10 *
11 * \copydoc Dumux::LowReKEpsilonVolumeVariables
12 */
13 #ifndef DUMUX_LOWREKEPSILON_VOLUME_VARIABLES_HH
14 #define DUMUX_LOWREKEPSILON_VOLUME_VARIABLES_HH
15
16 #include <dumux/common/parameters.hh>
17 #include <dumux/freeflow/rans/volumevariables.hh>
18
19 namespace Dumux {
20
21 /*!
22 * \ingroup LowReKEpsilonModel
23 * \brief Volume variables for the isothermal single-phase low-Re k-epsilons model.
24 */
25 template <class Traits, class NSVolumeVariables>
26
3/20
✓ Branch 3 taken 75572 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 34264 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 34264 times.
✗ Branch 12 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.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
144980 class LowReKEpsilonVolumeVariables
27 : public RANSVolumeVariables<Traits, NSVolumeVariables>
28 {
29 using RANSParentType = RANSVolumeVariables<Traits, NSVolumeVariables>;
30
31 using Scalar = typename Traits::PrimaryVariables::value_type;
32
33 public:
34 //! export the indices type
35 using Indices = typename Traits::ModelTraits::Indices;
36
37 /*!
38 * \brief Update all quantities for a given control volume
39 *
40 * \param elemSol A vector containing all primary variables connected to the element
41 * \param problem The object specifying the problem which ought to
42 * be simulated
43 * \param element An element which contains part of the control volume
44 * \param scv The sub-control volume
45 */
46 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
47 14087628 void update(const ElementSolution &elemSol,
48 const Problem &problem,
49 const Element &element,
50 const SubControlVolume& scv)
51 {
52 14087628 RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv);
53 14087628 updateRANSProperties(elemSol, problem, element, scv);
54 14087628 }
55
56 /*!
57 * \brief Update all turbulent quantities for a given control volume
58 *
59 * Wall and roughness related quantities are stored. Eddy viscosity is set.
60 *
61 * \param elemSol A vector containing all primary variables connected to the element
62 * \param problem The object specifying the problem which ought to be simulated
63 * \param element An element which contains part of the control volume
64 * \param scv The sub-control volume
65 */
66 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
67 14087628 void updateRANSProperties(const ElementSolution &elemSol,
68 const Problem &problem,
69 const Element &element,
70 const SubControlVolume& scv)
71 {
72 14087628 RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
73 14087628 turbulentKineticEnergy_ = elemSol[0][Indices::turbulentKineticEnergyIdx];
74 14087628 dissipationTilde_ = elemSol[0][Indices::dissipationIdx];
75 14087628 storedDissipationTilde_ = problem.storedDissipationTilde(RANSParentType::elementIdx());
76 14087628 storedTurbulentKineticEnergy_ = problem.storedTurbulentKineticEnergy(RANSParentType::elementIdx());
77 14087628 stressTensorScalarProduct_ = problem.stressTensorScalarProduct(RANSParentType::elementIdx());
78
1/2
✓ Branch 1 taken 14087628 times.
✗ Branch 2 not taken.
14087628 if (problem.useStoredEddyViscosity())
79 28175256 RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity(RANSParentType::elementIdx()));
80 else
81 RANSParentType::setDynamicEddyViscosity_(calculateEddyViscosity());
82 14087628 RANSParentType::calculateEddyDiffusivity(problem);
83 14087628 RANSParentType::calculateEddyThermalConductivity(problem);
84 14087628 }
85
86 /*!
87 * \brief Returns the dynamic eddy viscosity \f$\mathrm{[Pa s]}\f$.
88 */
89 34264 Scalar calculateEddyViscosity()
90 {
91 68528 return cMu() * fMu() * turbulentKineticEnergy() * turbulentKineticEnergy()
92 68528 / dissipationTilde() * RANSParentType::density();
93 }
94
95 /*!
96 * \brief Returns the turbulent kinetic energy \f$ m^2/s^2 \f$
97 */
98 Scalar turbulentKineticEnergy() const
99 { return turbulentKineticEnergy_; }
100
101 /*!
102 * \brief Returns an effective dissipation \f$ m^2/s^3 \f$
103 */
104 Scalar dissipationTilde() const
105 { return dissipationTilde_; }
106
107 /*!
108 * \brief Returns the turbulent kinetic energy \f$ m^2/s^2 \f$
109 */
110 Scalar storedTurbulentKineticEnergy() const
111 { return storedTurbulentKineticEnergy_; }
112
113 /*!
114 * \brief Returns an effective dissipation \f$ m^2/s^3 \f$
115 */
116 Scalar storedDissipationTilde() const
117 { return storedDissipationTilde_; }
118
119 /*!
120 * \brief Returns the scalar product of the stress tensor
121 */
122 Scalar stressTensorScalarProduct() const
123 { return stressTensorScalarProduct_; }
124
125 //! \brief Returns the \f$ Re_\textrm{T} \f$ value
126 const Scalar reT() const
127 {
128 10133760 return turbulentKineticEnergy() * turbulentKineticEnergy()
129 20267520 / RANSParentType::kinematicViscosity() / dissipationTilde();
130 }
131
132 //! \brief Returns the \f$ Re_\textrm{y} \f$ value
133 const Scalar reY() const
134 {
135 using std::sqrt;
136 return sqrt(turbulentKineticEnergy()) * RANSParentType::wallDistance()
137 / RANSParentType::kinematicViscosity();
138 }
139
140 //! \brief Returns the \f$ C_\mu \f$ constant
141 const Scalar cMu() const
142 { return 0.09; }
143
144 //! \brief Returns the \f$ \sigma_\textrm{k} \f$ constant
145 const Scalar sigmaK() const
146 { return 1.0; }
147
148 //! \brief Returns the \f$ \sigma_\varepsilon \f$ constant
149 const Scalar sigmaEpsilon() const
150 { return 1.3; }
151
152 //! \brief Returns the \f$ C_{1\tilde{\varepsilon}} \f$ constant
153 const Scalar cOneEpsilon() const
154 { return 1.35; }
155
156 //! \brief Returns the \f$ C_{2\tilde{\varepsilon}} \f$ constant
157 const Scalar cTwoEpsilon() const
158 { return 1.8; }
159
160 //! \brief Returns the \f$ D \f$ value
161 const Scalar dValue() const
162 {
163 5066880 return 2.0 * RANSParentType::kinematicViscosity() * turbulentKineticEnergy()
164 5066880 / RANSParentType::wallDistance() / RANSParentType::wallDistance();
165 }
166
167 //! \brief Returns the \f$ f_\mu \f$ value
168 const Scalar fMu() const
169 {
170 using std::exp;
171 34264 return 1.0 - exp(-0.0115 * RANSParentType::yPlus());
172 }
173
174 //! \brief Returns the \f$ f_1 \f$ value
175 const Scalar fOne() const
176 { return 1.0; }
177
178 //! \brief Returns the \f$ f_2 \f$ value
179 5066880 const Scalar fTwo() const
180 {
181 using std::exp;
182 15200640 return 1.0 - 0.22 * exp(-1.0 * (reT() * reT() / 6.0 / 6.0));
183 }
184
185 //! \brief Returns the \f$ E \f$ value
186 5066880 const Scalar eValue() const
187 {
188 using std::exp;
189 10133760 return -2.0 * RANSParentType::kinematicViscosity() * dissipationTilde()
190 5066880 / RANSParentType::wallDistance() / RANSParentType::wallDistance()
191 5066880 * exp(-0.5 * RANSParentType::yPlus());
192 }
193
194 protected:
195 Scalar turbulentKineticEnergy_ = 0.0;
196 Scalar dissipationTilde_ = 0.0;
197 Scalar storedTurbulentKineticEnergy_ = 0.0;
198 Scalar storedDissipationTilde_ = 0.0;
199 Scalar stressTensorScalarProduct_ = 0.0;
200 };
201
202 } // end namespace Dumux
203
204 #endif
205