GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/kepsilon/volumevariables.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 28 53 52.8%
Functions: 8 92 8.7%
Branches: 8 40 20.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
3/20
✓ Branch 3 taken 151088 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64616 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 64616 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.
282000 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 29757004 void update(const ElementSolution &elemSol,
47 const Problem &problem,
48 const Element &element,
49 const SubControlVolume& scv)
50 {
51 29757004 RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv);
52 29757004 updateRANSProperties(elemSol, problem, element, scv);
53 29757004 }
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 29757004 void updateRANSProperties(const ElementSolution &elemSol,
67 const Problem &problem,
68 const Element &element,
69 const SubControlVolume& scv)
70 {
71 29757004 RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
72 59514008 isMatchingPoint_ = problem.isMatchingPoint(RANSParentType::elementIdx());
73 59514008 inNearWallRegion_ = problem.inNearWallRegion(RANSParentType::elementIdx());
74 29757004 turbulentKineticEnergy_ = elemSol[0][Indices::turbulentKineticEnergyIdx];
75 29757004 dissipation_ = elemSol[0][Indices::dissipationIdx];
76 59514008 storedDissipation_ = problem.storedDissipation(RANSParentType::elementIdx());
77 29757004 storedTurbulentKineticEnergy_ = problem.storedTurbulentKineticEnergy(RANSParentType::elementIdx());
78 29757004 stressTensorScalarProduct_ = problem.stressTensorScalarProduct(RANSParentType::elementIdx());
79 29757004 const Scalar uStarNominal = problem.uStarNominal(RANSParentType::elementIdx());
80 29757004 const auto flowDirectionAxis = problem.flowDirectionAxis(RANSParentType::elementIdx());
81 29757004 yPlusNominal_ = RANSParentType::wallDistance() * uStarNominal / problem.kinematicViscosity(RANSParentType::elementIdx());
82 29757004 uPlusNominal_ = RANSParentType::ccVelocityVector()[flowDirectionAxis] / uStarNominal;
83 29757004 cMu_ = problem.cMu();
84
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 29757004 times.
29757004 if (problem.useStoredEddyViscosity())
85 RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity(RANSParentType::elementIdx()));
86 else
87 59514008 RANSParentType::setDynamicEddyViscosity_(calculateEddyViscosity());
88
2/2
✓ Branch 0 taken 6516205 times.
✓ Branch 1 taken 23240799 times.
29757004 if (inNearWallRegion_)
89 {
90 13032410 RANSParentType::setDynamicEddyViscosity_(problem.zeroEqDynamicEddyViscosity(RANSParentType::elementIdx()));
91 }
92 29757004 RANSParentType::calculateEddyDiffusivity(problem);
93 29757004 RANSParentType::calculateEddyThermalConductivity(problem);
94 29757004 }
95
96 /*!
97 * \brief Returns the dynamic eddy viscosity \f$\mathrm{[Pa s]}\f$.
98 */
99 Scalar calculateEddyViscosity()
100 {
101 29821620 return cMu() * turbulentKineticEnergy() * turbulentKineticEnergy()
102
2/16
✓ Branch 0 taken 64616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64616 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
59643240 / 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