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 SSTModel | ||
10 | * | ||
11 | * \copydoc Dumux::SSTVolumeVariables | ||
12 | */ | ||
13 | #ifndef DUMUX_SST_VOLUME_VARIABLES_HH | ||
14 | #define DUMUX_SST_VOLUME_VARIABLES_HH | ||
15 | |||
16 | #include <dumux/common/properties.hh> | ||
17 | #include <dumux/common/parameters.hh> | ||
18 | #include <dumux/freeflow/turbulencemodel.hh> | ||
19 | #include <dumux/freeflow/rans/volumevariables.hh> | ||
20 | |||
21 | namespace Dumux { | ||
22 | |||
23 | /*! | ||
24 | * \ingroup SSTModel | ||
25 | * \brief Volume variables for the isothermal single-phase SST 2-Eq model. | ||
26 | */ | ||
27 | template <class Traits, class NSVolumeVariables> | ||
28 | class SSTVolumeVariables | ||
29 | : public RANSVolumeVariables<Traits, NSVolumeVariables> | ||
30 | { | ||
31 | using RANSParentType = RANSVolumeVariables<Traits, NSVolumeVariables>; | ||
32 | |||
33 | using Scalar = typename Traits::PrimaryVariables::value_type; | ||
34 | using DimVector = Dune::FieldVector<Scalar, Traits::ModelTraits::dim()>; | ||
35 | |||
36 | public: | ||
37 | //! export the indices type | ||
38 | using Indices = typename Traits::ModelTraits::Indices; | ||
39 | |||
40 | /*! | ||
41 | * \brief Update all quantities for a given control volume | ||
42 | * | ||
43 | * \param elemSol A vector containing all primary variables connected to the element | ||
44 | * \param problem The object specifying the problem which ought to be simulated | ||
45 | * \param element An element which contains part of the control volume | ||
46 | * \param scv The sub-control volume | ||
47 | */ | ||
48 | template<class ElementSolution, class Problem, class Element, class SubControlVolume> | ||
49 | 16416128 | void update(const ElementSolution &elemSol, | |
50 | const Problem &problem, | ||
51 | const Element &element, | ||
52 | const SubControlVolume& scv) | ||
53 | { | ||
54 | 16416128 | RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv); | |
55 | 16416128 | updateRANSProperties(elemSol, problem, element, scv); | |
56 | 16416128 | } | |
57 | |||
58 | /*! | ||
59 | * \brief Update all turbulent quantities for a given control volume | ||
60 | * | ||
61 | * Wall and roughness related quantities are stored. Eddy viscosity is set. | ||
62 | * | ||
63 | * \param elemSol A vector containing all primary variables connected to the element | ||
64 | * \param problem The object specifying the problem which ought to be simulated | ||
65 | * \param element An element which contains part of the control volume | ||
66 | * \param scv The sub-control volume | ||
67 | */ | ||
68 | template<class ElementSolution, class Problem, class Element, class SubControlVolume> | ||
69 | 16416128 | void updateRANSProperties(const ElementSolution &elemSol, | |
70 | const Problem &problem, | ||
71 | const Element &element, | ||
72 | const SubControlVolume& scv) | ||
73 | { | ||
74 | 16416128 | RANSParentType::updateRANSProperties(elemSol, problem, element, scv); | |
75 | |||
76 | 16416128 | turbulentKineticEnergy_ = elemSol[0][Indices::turbulentKineticEnergyIdx]; | |
77 | 16416128 | dissipation_ = elemSol[0][Indices::dissipationIdx]; | |
78 | |||
79 | 16416128 | storedDissipation_ = problem.storedDissipation(RANSParentType::elementIdx()); | |
80 | 16416128 | storedTurbulentKineticEnergy_ = problem.storedTurbulentKineticEnergy(RANSParentType::elementIdx()); | |
81 | |||
82 | 16416128 | storedDissipationGradient_ = problem.storedDissipationGradient(RANSParentType::elementIdx()); | |
83 | 16416128 | storedTurbulentKineticEnergyGradient_ = problem.storedTurbulentKineticEnergyGradient(RANSParentType::elementIdx()); | |
84 | |||
85 | 16416128 | stressTensorScalarProduct_ = problem.stressTensorScalarProduct(RANSParentType::elementIdx()); | |
86 | 16416128 | vorticityTensorScalarProduct_ = problem.vorticityTensorScalarProduct(RANSParentType::elementIdx()); | |
87 | 16416128 | wallDistance_ = problem.wallDistance(RANSParentType::elementIdx()); | |
88 | 16416128 | kinematicViscosity_ = problem.kinematicViscosity(RANSParentType::elementIdx()); | |
89 | |||
90 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16416128 times.
|
16416128 | if (problem.useStoredEddyViscosity()) |
91 | ✗ | RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity(RANSParentType::elementIdx())); | |
92 | else | ||
93 | 16416128 | RANSParentType::setDynamicEddyViscosity_(calculateEddyViscosity(problem)); | |
94 | |||
95 | 16416128 | RANSParentType::calculateEddyDiffusivity(problem); | |
96 | 16416128 | RANSParentType::calculateEddyThermalConductivity(problem); | |
97 | 16416128 | } | |
98 | |||
99 | /*! | ||
100 | * \brief Returns the dynamic eddy viscosity \f$\mathrm{[Pa s]}\f$ for the SST-model. | ||
101 | */ | ||
102 | template<class Problem> | ||
103 | 32901984 | Scalar calculateEddyViscosity(const Problem& problem) | |
104 | { | ||
105 | using std::sqrt; | ||
106 | using std::max; | ||
107 | |||
108 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 16450992 times.
|
32901984 | if(problem.sstModelVersion() == SSTModel::BSL) |
109 | ✗ | return turbulentKineticEnergy() / dissipation() * RANSParentType::density(); | |
110 |
1/2✓ Branch 0 taken 16450992 times.
✗ Branch 1 not taken.
|
32901984 | else if(problem.sstModelVersion() == SSTModel::SST) |
111 | { | ||
112 | 32901984 | const Scalar dividend = a1SST() * turbulentKineticEnergy(); | |
113 | 32901984 | const Scalar possibleMax1 = a1SST()*dissipation(); | |
114 | 98705952 | const Scalar possibleMax2 = absoluteValueVorticity() * F2(); | |
115 |
2/2✓ Branch 0 taken 2794025 times.
✓ Branch 1 taken 13656967 times.
|
32901984 | const Scalar divisor = std::max(possibleMax1,possibleMax2); |
116 | 65803968 | return dividend / divisor * RANSParentType::density(); | |
117 | } | ||
118 | else | ||
119 | ✗ | DUNE_THROW(Dune::NotImplemented, "\nThis SST Model is not implemented.\n"); | |
120 | } | ||
121 | |||
122 | |||
123 | //! \brief Returns the turbulent kinetic energy \f$ m^2/s^2 \f$ | ||
124 | ✗ | Scalar turbulentKineticEnergy() const | |
125 | ✗ | { return turbulentKineticEnergy_; } | |
126 | |||
127 | //! \brief Returns an effective dissipation \f$ m^2/s^3 \f$ | ||
128 | ✗ | Scalar dissipation() const | |
129 | ✗ | { return dissipation_; } | |
130 | |||
131 | //! \brief Returns the turbulent kinetic energy \f$ m^2/s^2 \f$ | ||
132 | ✗ | Scalar storedTurbulentKineticEnergy() const | |
133 | ✗ | { return storedTurbulentKineticEnergy_; } | |
134 | |||
135 | //! \brief Returns an effective dissipation \f$ m^2/s^3 \f$ | ||
136 | ✗ | Scalar storedDissipation() const | |
137 | ✗ | { return storedDissipation_; } | |
138 | |||
139 | //! \brief Returns the gradient of the turbulent kinetic energy \f$ m^2/s^2 \f$ | ||
140 | ✗ | DimVector storedTurbulentKineticEnergyGradient() const | |
141 | ✗ | { return storedTurbulentKineticEnergyGradient_; } | |
142 | |||
143 | //! \brief Returns the gradient of the effective dissipation \f$ m^2/s^3 \f$ | ||
144 | ✗ | DimVector storedDissipationGradient() const | |
145 | ✗ | { return storedDissipationGradient_; } | |
146 | |||
147 | //! \brief Returns the scalar product of the stress tensor | ||
148 | ✗ | Scalar stressTensorScalarProduct() const | |
149 | ✗ | { return stressTensorScalarProduct_; } | |
150 | |||
151 | //! \brief Returns the scalar product of the vorticity tensor | ||
152 | ✗ | Scalar vorticityTensorScalarProduct() const | |
153 | ✗ | { return vorticityTensorScalarProduct_; } | |
154 | |||
155 | //! \brief Returns the kinematic viscosity | ||
156 | ✗ | Scalar kinematicViscosity() const | |
157 | ✗ | { return kinematicViscosity_; } | |
158 | |||
159 | ✗ | Scalar wallDistance() const | |
160 | ✗ | { return wallDistance_; } | |
161 | |||
162 | //! \brief Returns the \f$ \beta_{\omega} \f$ constant | ||
163 | const Scalar betaOmega() const | ||
164 | { return 0.0708; } | ||
165 | |||
166 | //! \brief Returns the \f$ \alpha \f$ value | ||
167 | const Scalar alpha() const | ||
168 | { return 0.52; } | ||
169 | |||
170 | //! \brief Returns the \f$ \sigma_k \f$ constant | ||
171 | const Scalar sigmaK() const | ||
172 | { return 0.6; } | ||
173 | |||
174 | //! \brief Returns the \f$ \sigma_{\omega} \f$ constant | ||
175 | const Scalar sigmaOmega() const | ||
176 | { return 0.5; } | ||
177 | |||
178 | //! \brief Returns the \f$ \beta_k \f$ constant | ||
179 | const Scalar betaK() const | ||
180 | { return 0.09; } | ||
181 | |||
182 | //! \brief Returns the \f$ \sigma_{k1,BSL} \f$ constant | ||
183 | ✗ | const Scalar sigmaK1BSL() const | |
184 | ✗ | { return 0.5; } | |
185 | |||
186 | //! \brief Returns the \f$ \sigma_{k1,SST} \f$ constant | ||
187 | ✗ | const Scalar sigmaK1SST() const | |
188 | ✗ | { return 0.85; } | |
189 | |||
190 | //! \brief Returns the \f$ \sigma_{k2} \f$ constant | ||
191 | ✗ | const Scalar sigmaK2() const | |
192 | ✗ | { return 1.0; } | |
193 | |||
194 | //! \brief Returns the \f$ \sigma_{\omega1,BSL} \f$ constant | ||
195 | ✗ | const Scalar sigmaOmega1BSL() const | |
196 | ✗ | { return 0.5; } | |
197 | |||
198 | //! \brief Returns the \f$ \sigma_{\omega1,SST} \f$ constant | ||
199 | ✗ | const Scalar sigmaOmega1SST() const | |
200 | ✗ | { return 0.5; } | |
201 | |||
202 | //! \brief Returns the \f$ \sigma_{\omega2} \f$ constant | ||
203 | ✗ | const Scalar sigmaOmega2() const | |
204 | ✗ | { return 0.856; } | |
205 | |||
206 | //! \brief Returns the \f$ \beta_{1,BSL} \f$ constant | ||
207 | ✗ | const Scalar beta1BSL() const | |
208 | ✗ | { return 0.0750; } | |
209 | |||
210 | //! \brief Returns the \f$ \beta_{1,SST} \f$ constant | ||
211 | ✗ | const Scalar beta1SST() const | |
212 | ✗ | { return 0.0750; } | |
213 | |||
214 | //! \brief Returns the \f$ \beta_{2} \f$ constant | ||
215 | ✗ | const Scalar beta2() const | |
216 | ✗ | { return 0.0820; } | |
217 | |||
218 | //! \brief Returns the \f$ \beta^{*}_{1,BSL} \f$ constant | ||
219 | ✗ | const Scalar betaStar1BSL() const | |
220 | ✗ | { return 0.09; } | |
221 | |||
222 | //! \brief Returns the \f$ \beta^{*}_{1,SST} \f$ constant | ||
223 | ✗ | const Scalar betaStar1SST() const | |
224 | ✗ | { return 0.09; } | |
225 | |||
226 | //! \brief Returns the \f$ \beta^{*}_{2} \f$ constant | ||
227 | ✗ | const Scalar betaStar2() const | |
228 | ✗ | { return 0.09; } | |
229 | |||
230 | //! \brief Returns the \f$ \kappa_{1,BSL} \f$ constant | ||
231 | ✗ | const Scalar kappa1BSL() const | |
232 | ✗ | { return 0.41; } | |
233 | |||
234 | //! \brief Returns the \f$ \kappa_{1,SST} \f$ constant | ||
235 | ✗ | const Scalar kappa1SST() const | |
236 | ✗ | { return 0.41; } | |
237 | |||
238 | //! \brief Returns the \f$ \kappa_{2} \f$ constant | ||
239 | ✗ | const Scalar kappa2() const | |
240 | ✗ | { return 0.41; } | |
241 | |||
242 | //! \brief Returns the \f$ \gamma_{1,BSL} \f$ constant | ||
243 | ✗ | const Scalar gamma1BSL() const | |
244 | ✗ | { return (beta1BSL()/betaStar1BSL()) - ((sigmaOmega1BSL()*kappa1BSL()*kappa1BSL())/(std::sqrt(betaStar1BSL()))); } | |
245 | |||
246 | //! \brief Returns the \f$ \gamma_{1,SST} \f$ constant | ||
247 | ✗ | const Scalar gamma1SST() const | |
248 | 5879680 | { return (beta1SST()/betaStar1SST()) - ((sigmaOmega1SST()*kappa1SST()*kappa1SST())/(std::sqrt(betaStar1SST()))); } | |
249 | |||
250 | //! \brief Returns the \f$ \gamma_{2} \f$ constant | ||
251 | ✗ | const Scalar gamma2() const | |
252 | 5879680 | { return (beta2()/betaStar2()) - ((sigmaOmega2()*kappa2()*kappa2())/(std::sqrt(betaStar2()))); } | |
253 | |||
254 | //! \brief Returns the \f$ a_{1,SST} \f$ constant | ||
255 | ✗ | const Scalar a1SST() const | |
256 | ✗ | { return 0.31; } | |
257 | |||
258 | //! \brief Returns the absolute value of the vorticity\f$ \Omega \f$ | ||
259 | Scalar absoluteValueVorticity() const | ||
260 | 16450992 | { return std::sqrt(2.0 * vorticityTensorScalarProduct()); } | |
261 | |||
262 | //! \brief Returns the transformation function \f$ F_{1} \f$ for the constants of the BSL- and SST-model | ||
263 | 228417472 | Scalar F1() const | |
264 | { | ||
265 | 228417472 | Scalar gradientProduct = 0.0; | |
266 |
2/2✓ Branch 0 taken 456834944 times.
✓ Branch 1 taken 228417472 times.
|
685252416 | for (unsigned int i = 0; i < Traits::ModelTraits::dim(); ++i){ |
267 | 1370504832 | gradientProduct += storedTurbulentKineticEnergyGradient()[i] * storedDissipationGradient()[i];} | |
268 | |||
269 |
2/2✓ Branch 0 taken 157204553 times.
✓ Branch 1 taken 71212919 times.
|
228417472 | Scalar positiveCrossDiffusion = 2.0 * RANSParentType::density() * sigmaOmega2() / storedDissipation() * gradientProduct; |
270 |
2/2✓ Branch 0 taken 157204553 times.
✓ Branch 1 taken 71212919 times.
|
228417472 | positiveCrossDiffusion = std::max(positiveCrossDiffusion, 1e-20); |
271 | |||
272 |
2/2✓ Branch 0 taken 121796602 times.
✓ Branch 1 taken 106620870 times.
|
228417472 | const Scalar possibleMin2 = (4.0 * RANSParentType::density() * sigmaOmega2() * storedTurbulentKineticEnergy()) |
273 | 228417472 | / (positiveCrossDiffusion * wallDistance() * wallDistance()); | |
274 | |||
275 | 228417472 | const Scalar possibleMax1 = (std::sqrt(storedTurbulentKineticEnergy())) / (0.09 * storedDissipation() * wallDistance()); | |
276 | 228417472 | const Scalar possibleMax2 = (500.00 * kinematicViscosity()) / (wallDistance() * wallDistance() * storedDissipation()); | |
277 |
2/2✓ Branch 0 taken 121796602 times.
✓ Branch 1 taken 106620870 times.
|
228417472 | const Scalar possibleMin1 = std::max(possibleMax1, possibleMax2); |
278 | |||
279 |
2/2✓ Branch 0 taken 20268796 times.
✓ Branch 1 taken 208148676 times.
|
228417472 | const Scalar argument = std::min(possibleMin1,possibleMin2); |
280 | |||
281 | 228417472 | return tanh(argument * argument * argument * argument); | |
282 | } | ||
283 | |||
284 | |||
285 | //! \brief Returns the transformation function \f$ F_{2} \f$ for the eddy viscosity of the SST-model | ||
286 | 16450992 | Scalar F2() const | |
287 | { | ||
288 | 16450992 | const Scalar possibleMax1 = 2.0 * (std::sqrt(storedTurbulentKineticEnergy())) / (0.09 * storedDissipation() * wallDistance()); | |
289 | 16450992 | const Scalar possibleMax2 = (500.0 * kinematicViscosity()) / (wallDistance() * wallDistance() * storedDissipation()); | |
290 |
2/2✓ Branch 0 taken 7432368 times.
✓ Branch 1 taken 9018624 times.
|
16450992 | const Scalar argument = std::max(possibleMax1, possibleMax2); |
291 | |||
292 | 16450992 | return tanh(argument * argument); | |
293 | } | ||
294 | |||
295 | //------------------------Constants for SST-------------------------------- | ||
296 | //! \brief Returns the \f$ \sigma_{k,SST} \f$ constant for the SST-model | ||
297 | 46814928 | const Scalar sigmaKSST() const | |
298 | 46814928 | { return F1()*sigmaK1SST() + (1-F1())*sigmaK2(); } | |
299 | |||
300 | //! \brief Returns the \f$ \sigma_{\omega,SST} \f$ constant for the SST-model | ||
301 | 46814928 | const Scalar sigmaOmegaSST() const | |
302 | 46814928 | { return F1()*sigmaOmega1SST() + (1-F1())*sigmaOmega2(); } | |
303 | |||
304 | //! \brief Returns the \f$ \beta_{SST} \f$ constant for the SST-model | ||
305 | 5879680 | const Scalar betaSST() const | |
306 | 5879680 | { return F1()*beta1SST() + (1-F1())*beta2(); } | |
307 | |||
308 | //! \brief Returns the \f$ \beta^{*}_{SST} \f$ constant for the SST-model. \f$ \beta^{*} \f$ is the same for all models. | ||
309 | 5879680 | const Scalar betaStarSST() const | |
310 | 5879680 | { return F1()*betaStar1SST() + (1-F1())*betaStar2(); } | |
311 | |||
312 | //! \brief Returns the \f$ \kappa_{SST} \f$ constant for the SST-model. \f$ \kappa \f$ is the same for all models. | ||
313 | const Scalar kappaSST() const | ||
314 | { return F1()*kappa1SST() + (1-F1())*kappa2(); } | ||
315 | |||
316 | //! \brief Returns the \f$ \gamma_{SST} \f$ constant for the SST-model | ||
317 | 5879680 | const Scalar gammaSST() const | |
318 | 5879680 | { return F1()*gamma1SST() + (1-F1())*gamma2(); } | |
319 | |||
320 | |||
321 | |||
322 | //------------------------Constants for BSL-------------------------------- | ||
323 | //! \brief Returns the \f$ \sigma_{k,BSL} \f$ constant for the BSL-model | ||
324 | ✗ | const Scalar sigmaKBSL() const | |
325 | ✗ | { return F1()*sigmaK1BSL() + (1-F1())*sigmaK2(); } | |
326 | |||
327 | //! \brief Returns the \f$ \sigma_{\omega,BSL} \f$ constant for the BSL-model | ||
328 | ✗ | const Scalar sigmaOmegaBSL() const | |
329 | ✗ | { return F1()*sigmaOmega1BSL() + (1-F1())*sigmaOmega2(); } | |
330 | |||
331 | //! \brief Returns the \f$ \beta_{BSL} \f$ constant for the BSL-model | ||
332 | ✗ | const Scalar betaBSL() const | |
333 | ✗ | { return F1()*beta1BSL() + (1-F1())*beta2(); } | |
334 | |||
335 | //! \brief Returns the \f$ \beta^{*}_{BSL} \f$ constant for the BSL-model. \f$ \beta^{*} \f$ is the same for all models. | ||
336 | ✗ | const Scalar betaStarBSL() const | |
337 | ✗ | { return F1()*betaStar1BSL() + (1-F1())*betaStar2(); } | |
338 | |||
339 | //! \brief Returns the \f$ \kappa_{BSL} \f$ constant for the BSL-model. \f$ \kappa \f$ is the same for all models. | ||
340 | const Scalar kappaBSL() const | ||
341 | { return F1()*kappa1BSL() + (1-F1())*kappa2(); } | ||
342 | |||
343 | //! \brief Returns the \f$ \gamma_{BSL} \f$ constant for the BSL-model | ||
344 | ✗ | const Scalar gammaBSL() const | |
345 | ✗ | { return F1()*gamma1BSL() + (1-F1())*gamma2(); } | |
346 | |||
347 | |||
348 | protected: | ||
349 | Scalar betaOmega_ = 0.0; | ||
350 | |||
351 | Scalar dissipation_ = 0.0; | ||
352 | Scalar storedDissipation_ = 0.0; | ||
353 | DimVector storedDissipationGradient_ = DimVector(0.0); | ||
354 | Scalar turbulentKineticEnergy_ = 0.0; | ||
355 | Scalar storedTurbulentKineticEnergy_ = 0.0; | ||
356 | DimVector storedTurbulentKineticEnergyGradient_ = DimVector(0.0); | ||
357 | |||
358 | Scalar stressTensorScalarProduct_ = 0.0; | ||
359 | Scalar vorticityTensorScalarProduct_ = 0.0; | ||
360 | Scalar wallDistance_ = 0.0; | ||
361 | Scalar kinematicViscosity_ = 0.0; | ||
362 | }; | ||
363 | } | ||
364 | |||
365 | #endif | ||
366 |