GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/kepsilon/volumevariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 28 53 52.8%
Functions: 16 92 17.4%
Branches: 22 40 55.0%

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 KEpsilonModel
10 * \copydoc Dumux::KEpsilonVolumeVariables
11 */
12 #ifndef DUMUX_KEPSILON_VOLUME_VARIABLES_HH
13 #define DUMUX_KEPSILON_VOLUME_VARIABLES_HH
14
15 #include <dumux/common/parameters.hh>
16 #include <dumux/freeflow/rans/volumevariables.hh>
17
18 namespace Dumux {
19
20 /*!
21 * \ingroup KEpsilonModel
22 * \brief Volume variables for the isothermal single-phase k-epsilon model.
23 */
24 template <class Traits, class NSVolumeVariables>
25
11/20
✓ Branch 3 taken 151088 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 25 times.
✓ Branch 7 taken 64616 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 25 times.
✓ Branch 11 taken 64616 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 25 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 25 times.
✗ Branch 19 not taken.
✓ Branch 22 taken 25 times.
✗ Branch 23 not taken.
✓ Branch 26 taken 25 times.
✗ Branch 27 not taken.
✓ Branch 30 taken 25 times.
✗ Branch 31 not taken.
✓ Branch 34 taken 25 times.
✗ Branch 35 not taken.
282700 class KEpsilonVolumeVariables
26 : public RANSVolumeVariables<Traits, NSVolumeVariables>
27 {
28 using RANSParentType = RANSVolumeVariables<Traits, NSVolumeVariables>;
29
30 using Scalar = typename Traits::PrimaryVariables::value_type;
31
32 public:
33 //! export the indices type
34 using Indices = typename Traits::ModelTraits::Indices;
35
36 /*!
37 * \brief Update all quantities for a given control volume
38 *
39 * \param elemSol A vector containing all primary variables connected to the element
40 * \param problem The object specifying the problem which ought to
41 * be simulated
42 * \param element An element which contains part of the control volume
43 * \param scv The sub-control volume
44 */
45 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
46 29758404 void update(const ElementSolution &elemSol,
47 const Problem &problem,
48 const Element &element,
49 const SubControlVolume& scv)
50 {
51 29758404 RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv);
52 29758404 updateRANSProperties(elemSol, problem, element, scv);
53 29758404 }
54
55 /*!
56 * \brief Update all turbulent quantities for a given control volume
57 *
58 * Wall and roughness related quantities are stored. Eddy viscosity is set.
59 *
60 * \param elemSol A vector containing all primary variables connected to the element
61 * \param problem The object specifying the problem which ought to be simulated
62 * \param element An element which contains part of the control volume
63 * \param scv The sub-control volume
64 */
65 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
66 29758404 void updateRANSProperties(const ElementSolution &elemSol,
67 const Problem &problem,
68 const Element &element,
69 const SubControlVolume& scv)
70 {
71 29758404 RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
72 59516808 isMatchingPoint_ = problem.isMatchingPoint(RANSParentType::elementIdx());
73 59516808 inNearWallRegion_ = problem.inNearWallRegion(RANSParentType::elementIdx());
74 29758404 turbulentKineticEnergy_ = elemSol[0][Indices::turbulentKineticEnergyIdx];
75 29758404 dissipation_ = elemSol[0][Indices::dissipationIdx];
76 59516808 storedDissipation_ = problem.storedDissipation(RANSParentType::elementIdx());
77 29758404 storedTurbulentKineticEnergy_ = problem.storedTurbulentKineticEnergy(RANSParentType::elementIdx());
78 29758404 stressTensorScalarProduct_ = problem.stressTensorScalarProduct(RANSParentType::elementIdx());
79 29758404 const Scalar uStarNominal = problem.uStarNominal(RANSParentType::elementIdx());
80 29758404 const auto flowDirectionAxis = problem.flowDirectionAxis(RANSParentType::elementIdx());
81 29758404 yPlusNominal_ = RANSParentType::wallDistance() * uStarNominal / problem.kinematicViscosity(RANSParentType::elementIdx());
82 29758404 uPlusNominal_ = RANSParentType::ccVelocityVector()[flowDirectionAxis] / uStarNominal;
83 29758404 cMu_ = problem.cMu();
84
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 29757704 times.
29758404 if (problem.useStoredEddyViscosity())
85 RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity(RANSParentType::elementIdx()));
86 else
87 59516808 RANSParentType::setDynamicEddyViscosity_(calculateEddyViscosity());
88
2/2
✓ Branch 0 taken 6516325 times.
✓ Branch 1 taken 23241379 times.
29758404 if (inNearWallRegion_)
89 {
90 13032890 RANSParentType::setDynamicEddyViscosity_(problem.zeroEqDynamicEddyViscosity(RANSParentType::elementIdx()));
91 }
92 29758404 RANSParentType::calculateEddyDiffusivity(problem);
93 29758404 RANSParentType::calculateEddyThermalConductivity(problem);
94 29758404 }
95
96 /*!
97 * \brief Returns the dynamic eddy viscosity \f$\mathrm{[Pa s]}\f$.
98 */
99 Scalar calculateEddyViscosity()
100 {
101 29822420 return cMu() * turbulentKineticEnergy() * turbulentKineticEnergy()
102
8/16
✓ Branch 0 taken 64641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64641 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 25 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 25 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 25 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
✗ Branch 15 not taken.
59644840 / dissipation() * RANSParentType::density();
103 }
104
105 /*!
106 * \brief Returns the turbulent kinetic energy \f$ m^2/s^2 \f$
107 */
108 Scalar turbulentKineticEnergy() const
109 { return turbulentKineticEnergy_; }
110
111 /*!
112 * \brief Returns an effective dissipation \f$ m^2/s^3 \f$
113 */
114 Scalar dissipation() const
115 { return dissipation_; }
116
117 /*!
118 * \brief Returns the turbulent kinetic energy \f$ m^2/s^2 \f$
119 */
120 Scalar storedTurbulentKineticEnergy() const
121 { return storedTurbulentKineticEnergy_; }
122
123 /*!
124 * \brief Returns an effective dissipation \f$ m^2/s^3 \f$
125 */
126 Scalar storedDissipation() const
127 { return storedDissipation_; }
128
129 /*!
130 * \brief Returns the scalar product of the stress tensor
131 */
132 Scalar stressTensorScalarProduct() const
133 { return stressTensorScalarProduct_; }
134
135 /*
136 * \brief Returns if an element is located in the near-wall region
137 */
138 bool inNearWallRegion() const
139 { return inNearWallRegion_; }
140
141 /*!
142 * \brief Returns if an element is the matching point
143 */
144 bool isMatchingPoint() const
145 { return isMatchingPoint_; }
146
147 //! \brief Returns the \f$ C_{\mu} \f$ constant
148 const Scalar cMu() const
149 { return cMu_; }
150
151 //! \brief Returns the \f$ \sigma_{\textrm{k}} \f$ constant
152 const Scalar sigmaK() const
153 { return 1.0; }
154
155 //! \brief Returns the \f$ \sigma_{\varepsilon} \f$ constant
156 const Scalar sigmaEpsilon() const
157 { return 1.3; }
158
159 //! \brief Returns the \f$ C_{1\varepsilon} \f$ constant
160 const Scalar cOneEpsilon() const
161 { return 1.44; }
162
163 //! \brief Returns the \f$ C_{2\varepsilon} \f$ constant
164 const Scalar cTwoEpsilon() const
165 { return 1.92; }
166
167 //! \brief Returns the nominal dimensionless wall distance \f$\mathrm{[-]}\f$.
168 Scalar yPlusNominal() const
169 { return yPlusNominal_; }
170
171 //! \brief Return the nominal dimensionless velocity \f$\mathrm{[-]}\f$.
172 Scalar uPlusNominal() const
173 { return uPlusNominal_; }
174
175 protected:
176 Scalar turbulentKineticEnergy_ = 0.0;
177 Scalar dissipation_ = 0.0;
178 Scalar storedTurbulentKineticEnergy_ = 0.0;
179 Scalar storedDissipation_ = 0.0;
180 Scalar stressTensorScalarProduct_ = 0.0;
181 Scalar yPlusNominal_ = 0.0;
182 Scalar uPlusNominal_ = 0.0;
183 Scalar cMu_ = 0.0;
184 bool inNearWallRegion_ = false;
185 bool isMatchingPoint_ = false;
186 };
187
188 } // end namespace Dumux
189
190 #endif
191