version 3.8
freeflow/rans/oneeq/volumevariables.hh
Go to the documentation of this file.
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//
13#ifndef DUMUX_ONEEQ_VOLUME_VARIABLES_HH
14#define DUMUX_ONEEQ_VOLUME_VARIABLES_HH
15
16#include <dune/common/math.hh>
19
20namespace Dumux {
21
27template <class Traits, class NSVolumeVariables>
29: public RANSVolumeVariables<Traits, NSVolumeVariables>
30{
32
33 using Scalar = typename Traits::PrimaryVariables::value_type;
34 using DimVector = Dune::FieldVector<Scalar, Traits::ModelTraits::dim()>;
35
36public:
38 using Indices = typename Traits::ModelTraits::Indices;
39
49 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
50 void update(const ElementSolution &elemSol,
51 const Problem &problem,
52 const Element &element,
53 const SubControlVolume& scv)
54 {
55 RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv);
56 updateRANSProperties(elemSol, problem, element, scv);
57 }
58
69 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
70 void updateRANSProperties(const ElementSolution &elemSol,
71 const Problem &problem,
72 const Element &element,
73 const SubControlVolume& scv)
74 {
75 RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
76 viscosityTilde_ = elemSol[0][Indices::viscosityTildeIdx];
77 storedViscosityTilde_ = problem.storedViscosityTilde(RANSParentType::elementIdx());
78 storedViscosityTildeGradient_ = problem.storedViscosityTildeGradient(RANSParentType::elementIdx());
79 stressTensorScalarProduct_ = problem.stressTensorScalarProduct(RANSParentType::elementIdx());
80 vorticityTensorScalarProduct_ = problem.vorticityTensorScalarProduct(RANSParentType::elementIdx());
81 if (problem.useStoredEddyViscosity())
82 RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity(RANSParentType::elementIdx()));
83 else
87 }
88
93 { return viscosityTilde() * fv1() * RANSParentType::density(); }
94
98 Scalar viscosityTilde() const
99 { return viscosityTilde_; }
100
104 Scalar storedViscosityTilde() const
105 { return storedViscosityTilde_; }
106
112
118
122 Scalar fv1() const
123 {
126 + cv1() * cv1() * cv1());
127 }
128
130 Scalar fv2() const
131 { return 1.0 - viscosityRatio() / (1.0 + viscosityRatio() * fv1()); }
132
134 Scalar ft2() const
135 {
136 using std::exp;
137 // the trip correction term is dropped according to Versteeg2009 and Wilcox2006
138 // return ct3() * exp(-ct4() * viscosityRatio() * viscosityRatio());
139 return 0.0;
140 }
141
143 Scalar fW() const
144 {
145 using std::pow;
146 using Dune::power;
147 return g() * pow(1.0 + power(cw3(), 6) / (power(g(), 6) + power(cw3(), 6)), 1.0/6.0);
148 }
149
151 Scalar g() const
152 {
153 using Dune::power;
154 return r() + cw2() * (power(r(), 6) - r());
155 }
156
158 Scalar r() const
159 {
160 using std::min;
161 return min(10.0,
165 }
166
168 Scalar viscosityRatio() const
170
171 /*
172 * ! \brief Returns a modified version of the stress tensor scalar product
173 *
174 * According to <a href="https://turbmodels.larc.nasa.gov/spalart.html">NASA</a>
175 * this term should never be zero and different limiters might be used.
176 * The Implementation uses the one proposed in:
177 * Allmaras, S. R., Johnson, F. T., and Spalart, P. R.,
178 * "Modifications and Clarifications for the Implementation of the Spalart-Allmaras Turbulence Model," ICCFD7-1902
179 */
181 {
182 // original form
183 // return vorticityMagnitude()
184 // + viscosityTilde() * fv2()
185 // / RANSParentType::karmanConstant() / RANSParentType::karmanConstant()
186 // / RANSParentType::wallDistance() / RANSParentType::wallDistance();
187
188 // limiter form, literature source see above
189 Scalar sBar = viscosityTilde() * fv2()
192 return sBar < -c2() * vorticityMagnitude()
194 + (vorticityMagnitude() * (c2() * c2() * vorticityMagnitude() + c3() * sBar))
195 / ((c3() - 2.0 * c2()) * vorticityMagnitude() - sBar)
196 : vorticityMagnitude() + sBar;
197 }
198
200 Scalar vorticityMagnitude() const
201 {
202 using std::sqrt;
203 return sqrt(2.0 * vorticityTensorScalarProduct_);
204 }
205
207 Scalar c2() const
208 { return 0.7; }
209
211 Scalar c3() const
212 { return 0.9; }
213
215 Scalar sigma() const
216 { return 2.0/3.0; }
217
219 Scalar cb1() const
220 { return 0.1355; }
221
223 Scalar cb2() const
224 { return 0.622; }
225
227 Scalar cv1() const
228 { return 7.1; }
229
231 Scalar ct3() const
232 { return 1.2; }
233
235 Scalar ct4() const
236 { return 0.5; }
237
239 Scalar cw1() const
240 {
242 + (1.0 + cb2()) / sigma();
243 }
244
246 Scalar cw2() const
247 { return 0.3; }
248
250 Scalar cw3() const
251 { return 2.0; }
252
253protected:
254 Scalar viscosityTilde_ = 0.0;
256 DimVector storedViscosityTildeGradient_ = DimVector(0.0);
259};
260
261} // end namespace Dumux
262
263#endif
Volume variables for the isothermal single-phase one-equation turbulence model by Spalart-Allmaras.
Definition: freeflow/rans/oneeq/volumevariables.hh:30
Scalar c2() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:207
Scalar fv2() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:130
Scalar vorticityMagnitude() const
Returns the magnitude of the vorticity.
Definition: freeflow/rans/oneeq/volumevariables.hh:200
Scalar cb2() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:223
Scalar fv1() const
Returns damping function for the eddy viscosity.
Definition: freeflow/rans/oneeq/volumevariables.hh:122
DimVector storedViscosityTildeGradient() const
Returns the gradient of the viscosity parameter.
Definition: freeflow/rans/oneeq/volumevariables.hh:110
Scalar viscosityTilde_
Definition: freeflow/rans/oneeq/volumevariables.hh:254
void update(const ElementSolution &elemSol, const Problem &problem, const Element &element, const SubControlVolume &scv)
Update all quantities for a given control volume.
Definition: freeflow/rans/oneeq/volumevariables.hh:50
Scalar sigma() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:215
Scalar viscosityRatio() const
Returns the ratio of the kinematic viscosity and the viscosity parameter.
Definition: freeflow/rans/oneeq/volumevariables.hh:168
typename Traits::ModelTraits::Indices Indices
export the indices type
Definition: freeflow/rans/oneeq/volumevariables.hh:38
Scalar storedViscosityTilde_
Definition: freeflow/rans/oneeq/volumevariables.hh:255
Scalar vorticityTensorScalarProduct_
Definition: freeflow/rans/oneeq/volumevariables.hh:258
Scalar ft2() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:134
Scalar g() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:151
void updateRANSProperties(const ElementSolution &elemSol, const Problem &problem, const Element &element, const SubControlVolume &scv)
Update all turbulent quantities for a given control volume.
Definition: freeflow/rans/oneeq/volumevariables.hh:70
Scalar stressTensorScalarProductTilde() const
Definition: freeflow/rans/oneeq/volumevariables.hh:180
DimVector storedViscosityTildeGradient_
Definition: freeflow/rans/oneeq/volumevariables.hh:256
Scalar fW() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:143
Scalar c3() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:211
Scalar calculateEddyViscosity()
Returns the dynamic eddy viscosity .
Definition: freeflow/rans/oneeq/volumevariables.hh:92
Scalar storedViscosityTilde() const
Returns the viscosity parameter from the last iteration .
Definition: freeflow/rans/oneeq/volumevariables.hh:104
Scalar cw1() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:239
Scalar cb1() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:219
Scalar ct3() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:231
Scalar cv1() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:227
Scalar r() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:158
Scalar ct4() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:235
Scalar viscosityTilde() const
Returns the viscosity parameter .
Definition: freeflow/rans/oneeq/volumevariables.hh:98
Scalar stressTensorScalarProduct() const
Returns the scalar product of the stress tensor.
Definition: freeflow/rans/oneeq/volumevariables.hh:116
Scalar stressTensorScalarProduct_
Definition: freeflow/rans/oneeq/volumevariables.hh:257
Scalar cw2() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:246
Scalar cw3() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:250
Volume variables for the isothermal single-phase Reynolds-Averaged Navier-Stokes models.
Definition: freeflow/rans/volumevariables.hh:30
Scalar karmanConstant() const
Return the Karman constant.
Definition: freeflow/rans/volumevariables.hh:144
void calculateEddyThermalConductivity(const Problem &problem)
Calculates the eddy thermal conductivity based on the kinematic eddy viscosity and the turbulent Pra...
Definition: freeflow/rans/volumevariables.hh:209
Scalar wallDistance() const
Return the wall distance of the control volume.
Definition: freeflow/rans/volumevariables.hh:138
void updateNavierStokesVolVars(const ElementSolution &elemSol, const Problem &problem, const Element &element, const SubControlVolume &scv)
Update all quantities for a given control volume.
Definition: freeflow/rans/volumevariables.hh:53
Scalar setDynamicEddyViscosity_(Scalar value)
Sets the dynamic eddy viscosity .
Definition: freeflow/rans/volumevariables.hh:254
Scalar kinematicViscosity() const
Return the kinematic viscosity of the fluid within the control volume.
Definition: freeflow/rans/volumevariables.hh:190
void updateRANSProperties(const ElementSolution &elemSol, const Problem &problem, const Element &element, const SubControlVolume &scv)
Update all turbulent quantities for a given control volume.
Definition: freeflow/rans/volumevariables.hh:73
void calculateEddyDiffusivity(const Problem &problem)
Calculates the eddy diffusivity based on the kinematic eddy viscosity and the turbulent Schmidt numb...
Definition: freeflow/rans/volumevariables.hh:198
unsigned int elementIdx() const
Return the element Idx of the control volume.
Definition: freeflow/rans/volumevariables.hh:108
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Definition: adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.