GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/komega/volumevariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 27 48 56.2%
Functions: 32 88 36.4%
Branches: 9 14 64.3%

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 KOmegaModel
10 *
11 * \copydoc Dumux::KOmegaVolumeVariables
12 */
13 #ifndef DUMUX_KOMEGA_VOLUME_VARIABLES_HH
14 #define DUMUX_KOMEGA_VOLUME_VARIABLES_HH
15
16 #include <dumux/common/properties.hh>
17 #include <dumux/common/parameters.hh>
18 #include <dumux/freeflow/rans/volumevariables.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup KOmegaModel
24 * \brief Volume variables for the isothermal single-phase k-omega 2-Eq model.
25 */
26 template <class Traits, class NSVolumeVariables>
27 class KOmegaVolumeVariables
28 : public RANSVolumeVariables<Traits, NSVolumeVariables>
29 {
30 using RANSParentType = RANSVolumeVariables<Traits, NSVolumeVariables>;
31
32 using Scalar = typename Traits::PrimaryVariables::value_type;
33 using DimVector = Dune::FieldVector<Scalar, Traits::ModelTraits::dim()>;
34
35 public:
36 //! export the indices type
37 using Indices = typename Traits::ModelTraits::Indices;
38
39 /*!
40 * \brief Update all quantities for a given control volume
41 *
42 * \param elemSol A vector containing all primary variables connected to the element
43 * \param problem The object specifying the problem which ought to be simulated
44 * \param element An element which contains part of the control volume
45 * \param scv The sub-control volume
46 */
47 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
48 22318504 void update(const ElementSolution &elemSol,
49 const Problem &problem,
50 const Element &element,
51 const SubControlVolume& scv)
52 {
53 22318504 RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv);
54 22318504 updateRANSProperties(elemSol, problem, element, scv);
55 22318504 }
56
57 /*!
58 * \brief Update all turbulent quantities for a given control volume
59 *
60 * Wall and roughness related quantities are stored. Eddy viscosity is set.
61 *
62 * \param elemSol A vector containing all primary variables connected to the element
63 * \param problem The object specifying the problem which ought to be simulated
64 * \param element An element which contains part of the control volume
65 * \param scv The sub-control volume
66 */
67 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
68 22318504 void updateRANSProperties(const ElementSolution &elemSol,
69 const Problem &problem,
70 const Element &element,
71 const SubControlVolume& scv)
72 {
73 22318504 RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
74 22318504 betaOmega_ = problem.betaOmega();
75 22318504 turbulentKineticEnergy_ = elemSol[0][Indices::turbulentKineticEnergyIdx];
76 22318504 dissipation_ = elemSol[0][Indices::dissipationIdx];
77 22318504 storedDissipation_ = problem.storedDissipation(RANSParentType::elementIdx());
78 22318504 storedTurbulentKineticEnergy_ = problem.storedTurbulentKineticEnergy(RANSParentType::elementIdx());
79 22318504 storedDissipationGradient_ = problem.storedDissipationGradient(RANSParentType::elementIdx());
80 22318504 storedTurbulentKineticEnergyGradient_ = problem.storedTurbulentKineticEnergyGradient(RANSParentType::elementIdx());
81 22318504 stressTensorScalarProduct_ = problem.stressTensorScalarProduct(RANSParentType::elementIdx());
82
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 22317804 times.
22318504 if (problem.useStoredEddyViscosity())
83 RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity(RANSParentType::elementIdx()));
84 else
85 22318504 RANSParentType::setDynamicEddyViscosity_(calculateEddyViscosity(problem));
86 22318504 RANSParentType::calculateEddyDiffusivity(problem);
87 22318504 RANSParentType::calculateEddyThermalConductivity(problem);
88 22318504 }
89
90 /*!
91 * \brief Returns the dynamic eddy viscosity \f$\mathrm{[Pa s]}\f$.
92 */
93 template<class Problem>
94 44734128 Scalar calculateEddyViscosity(const Problem& problem)
95 {
96 using std::sqrt;
97 using std::max;
98
99 // use the Dissipation limiter proposed in wilcox2008
100 44734128 Scalar limitiedDissipation = std::numeric_limits<Scalar>::min();
101
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 22367044 times.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
44734168 static const auto enableKOmegaDissipationLimiter
102
2/4
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
120 = getParamFromGroup<bool>(problem.paramGroup(), "KOmega.EnableDissipationLimiter", true);
103
1/2
✓ Branch 0 taken 22367064 times.
✗ Branch 1 not taken.
44734128 if (enableKOmegaDissipationLimiter)
104 {
105 44734128 limitiedDissipation = (7.0 / 8.0) * sqrt(2.0 * stressTensorScalarProduct() / betaK());
106 }
107
2/2
✓ Branch 0 taken 2342808 times.
✓ Branch 1 taken 20024256 times.
44734128 return turbulentKineticEnergy() / max(dissipation(), limitiedDissipation)
108 89468256 * RANSParentType::density();
109 }
110
111 //! \brief Returns the turbulent kinetic energy \f$ m^2/s^2 \f$
112 Scalar turbulentKineticEnergy() const
113 { return turbulentKineticEnergy_; }
114
115 //! \brief Returns an effective dissipation \f$ m^2/s^3 \f$
116 Scalar dissipation() const
117 { return dissipation_; }
118
119 //! \brief Returns the turbulent kinetic energy \f$ m^2/s^2 \f$
120 Scalar storedTurbulentKineticEnergy() const
121 { return storedTurbulentKineticEnergy_; }
122
123 //! \brief Returns an effective dissipation \f$ m^2/s^3 \f$
124 Scalar storedDissipation() const
125 { return storedDissipation_; }
126
127 //! \brief Returns the gradient of the turbulent kinetic energy \f$ m^2/s^2 \f$
128 DimVector storedTurbulentKineticEnergyGradient() const
129 { return storedTurbulentKineticEnergyGradient_; }
130
131 //! \brief Returns the gradient of the effective dissipation \f$ m^2/s^3 \f$
132 DimVector storedDissipationGradient() const
133 { return storedDissipationGradient_; }
134
135 //! \brief Returns the scalar product of the stress tensor
136 Scalar stressTensorScalarProduct() const
137 { return stressTensorScalarProduct_; }
138
139 //! \brief Returns the \f$ \alpha \f$ value
140 const Scalar alpha() const
141 { return 0.52; }
142
143 //! \brief Returns the \f$ \sigma_k \f$ constant
144 const Scalar sigmaK() const
145 { return 0.6; }
146
147 //! \brief Returns the \f$ \sigma_{\omega} \f$ constant
148 const Scalar sigmaOmega() const
149 { return 0.5; }
150
151 //! \brief Returns the \f$ \beta_k \f$ constant
152 const Scalar betaK() const
153 { return 0.09; }
154
155 //! \brief Returns the \f$ \beta_\omega \f$ constant
156 const Scalar betaOmega() const
157 { return betaOmega_; }
158
159 protected:
160 Scalar betaOmega_ = 0.0;
161 Scalar dissipation_ = 0.0;
162 Scalar turbulentKineticEnergy_ = 0.0;
163 Scalar storedDissipation_ = 0.0;
164 DimVector storedDissipationGradient_ = DimVector(0.0);
165 Scalar storedTurbulentKineticEnergy_ = 0.0;
166 DimVector storedTurbulentKineticEnergyGradient_ = DimVector(0.0);
167 Scalar stressTensorScalarProduct_ = 0.0;
168 };
169
170 } // end namespace Dumux
171
172 #endif
173