3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_ONEEQ_VOLUME_VARIABLES_HH
26#define DUMUX_ONEEQ_VOLUME_VARIABLES_HH
27
30
31namespace Dumux {
32
38template <class Traits, class NSVolumeVariables>
40: public RANSVolumeVariables<Traits, NSVolumeVariables>
41{
43
44 using Scalar = typename Traits::PrimaryVariables::value_type;
45 using DimVector = Dune::FieldVector<Scalar, Traits::ModelTraits::dim()>;
46
47public:
50
60 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
61 void update(const ElementSolution &elemSol,
62 const Problem &problem,
63 const Element &element,
64 const SubControlVolume& scv)
65 {
66 RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv);
67 updateRANSProperties(elemSol, problem, element, scv);
68 }
69
80 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
81 void updateRANSProperties(const ElementSolution &elemSol,
82 const Problem &problem,
83 const Element &element,
84 const SubControlVolume& scv)
85 {
86 RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
87 viscosityTilde_ = elemSol[0][Indices::viscosityTildeIdx];
88 storedViscosityTilde_ = problem.storedViscosityTilde_[RANSParentType::elementIdx()];
89 storedViscosityTildeGradient_ = problem.storedViscosityTildeGradient_[RANSParentType::elementIdx()];
90 stressTensorScalarProduct_ = problem.stressTensorScalarProduct_[RANSParentType::elementIdx()];
91 vorticityTensorScalarProduct_ = problem.vorticityTensorScalarProduct_[RANSParentType::elementIdx()];
92 if (problem.useStoredEddyViscosity_)
93 RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity_[RANSParentType::elementIdx()]);
94 else
98 }
99
104 {
106 }
107
111 Scalar viscosityTilde() const
112 {
113 return viscosityTilde_;
114 }
115
119 Scalar storedViscosityTilde() const
120 {
122 }
123
128 {
130 }
131
136 {
138 }
139
143 Scalar fv1() const
144 {
147 + cv1() * cv1() * cv1());
148 }
149
151 Scalar fv2() const
152 { return 1.0 - viscosityRatio() / (1.0 + viscosityRatio() * fv1()); }
153
155 Scalar ft2() const
156 {
157 using std::exp;
158 // the trip correction term is dropped according to Versteeg2009 and Wilcox2006
159 // return ct3() * exp(-ct4() * viscosityRatio() * viscosityRatio());
160 return 0.0;
161 }
162
164 Scalar fW() const
165 {
166 using std::pow;
167 return g() * pow(1.0 + pow(cw3(), 6.0) / (pow(g(), 6.0) + pow(cw3(), 6.0)), 1.0/6.0);
168 }
169
171 Scalar g() const
172 {
173 using std::pow;
174 return r() + cw2() * (pow(r(), 6.0) - r());
175 }
176
178 Scalar r() const
179 {
180 using std::min;
181 return min(10.0,
185 }
186
188 Scalar viscosityRatio() const
190
191 /*
192 * ! \brief Returns a modified version of the stress tensor scalar product
193 *
194 * According to <a href="https://turbmodels.larc.nasa.gov/spalart.html">NASA</a>
195 * this term should never be zero and different limiters might be used.
196 * The Implementation uses the one proposed in:
197 * Allmaras, S. R., Johnson, F. T., and Spalart, P. R.,
198 * "Modifications and Clarifications for the Implementation of the Spalart-Allmaras Turbulence Model," ICCFD7-1902
199 */
201 {
202 // original form
203 // return vorticityMagnitude()
204 // + viscosityTilde() * fv2()
205 // / RANSParentType::karmanConstant() / RANSParentType::karmanConstant()
206 // / RANSParentType::wallDistance() / RANSParentType::wallDistance();
207
208 // limiter form, literature source see above
209 Scalar sBar = viscosityTilde() * fv2()
212 return sBar < -c2() * vorticityMagnitude()
214 + (vorticityMagnitude() * (c2() * c2() * vorticityMagnitude() + c3() * sBar))
215 / ((c3() - 2.0 * c2()) * vorticityMagnitude() - sBar)
216 : vorticityMagnitude() + sBar;
217 }
218
220 Scalar vorticityMagnitude() const
221 {
222 using std::sqrt;
223 return sqrt(2.0 * vorticityTensorScalarProduct_);
224 }
225
227 Scalar c2() const
228 { return 0.7; }
229
231 Scalar c3() const
232 { return 0.9; }
233
235 Scalar sigma() const
236 { return 2.0/3.0; }
237
239 Scalar cb1() const
240 { return 0.1355; }
241
243 Scalar cb2() const
244 { return 0.622; }
245
247 Scalar cv1() const
248 { return 7.1; }
249
251 Scalar ct3() const
252 { return 1.2; }
253
255 Scalar ct4() const
256 { return 0.5; }
257
259 Scalar cw1() const
260 {
262 + (1.0 + cb2()) / sigma();
263 }
264
266 Scalar cw2() const
267 { return 0.3; }
268
270 Scalar cw3() const
271 { return 2.0; }
272
273protected:
274 Scalar viscosityTilde_ = 0.0;
276 DimVector storedViscosityTildeGradient_ = DimVector(0.0);
279};
280
281} // end namespace Dumux
282
283#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Volume variables for the isothermal single-phase one-equation turbulence model by Spalart-Allmaras.
Definition: freeflow/rans/oneeq/volumevariables.hh:41
Scalar c2() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:227
Scalar fv2() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:151
Scalar vorticityMagnitude() const
Returns the magnitude of the vorticity.
Definition: freeflow/rans/oneeq/volumevariables.hh:220
Scalar cb2() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:243
Scalar fv1() const
Returns damping function for the eddy viscosity.
Definition: freeflow/rans/oneeq/volumevariables.hh:143
DimVector storedViscosityTildeGradient() const
Returns the gradient of the viscosity parameter.
Definition: freeflow/rans/oneeq/volumevariables.hh:127
Scalar viscosityTilde_
Definition: freeflow/rans/oneeq/volumevariables.hh:274
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:61
Scalar sigma() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:235
Scalar viscosityRatio() const
Returns the ratio of the kinematic viscosity and the viscosity parameter.
Definition: freeflow/rans/oneeq/volumevariables.hh:188
typename Traits::ModelTraits::Indices Indices
export the indices type
Definition: freeflow/rans/oneeq/volumevariables.hh:49
Scalar storedViscosityTilde_
Definition: freeflow/rans/oneeq/volumevariables.hh:275
Scalar vorticityTensorScalarProduct_
Definition: freeflow/rans/oneeq/volumevariables.hh:278
Scalar ft2() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:155
Scalar g() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:171
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:81
Scalar stressTensorScalarProductTilde() const
Definition: freeflow/rans/oneeq/volumevariables.hh:200
DimVector storedViscosityTildeGradient_
Definition: freeflow/rans/oneeq/volumevariables.hh:276
Scalar fW() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:164
Scalar c3() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:231
Scalar calculateEddyViscosity()
Returns the dynamic eddy viscosity .
Definition: freeflow/rans/oneeq/volumevariables.hh:103
Scalar storedViscosityTilde() const
Returns the viscosity parameter from the last iteration .
Definition: freeflow/rans/oneeq/volumevariables.hh:119
Scalar cw1() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:259
Scalar cb1() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:239
Scalar ct3() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:251
Scalar cv1() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:247
Scalar r() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:178
Scalar ct4() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:255
Scalar viscosityTilde() const
Returns the viscosity parameter .
Definition: freeflow/rans/oneeq/volumevariables.hh:111
Scalar stressTensorScalarProduct() const
Returns the scalar product of the stress tensor.
Definition: freeflow/rans/oneeq/volumevariables.hh:135
Scalar stressTensorScalarProduct_
Definition: freeflow/rans/oneeq/volumevariables.hh:277
Scalar cw2() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:266
Scalar cw3() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:270
Volume variables for the isothermal single-phase Reynolds-Averaged Navier-Stokes models.
Definition: freeflow/rans/volumevariables.hh:42
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:65
Scalar setDynamicEddyViscosity_(Scalar value)
Sets the dynamic eddy viscosity .
Definition: freeflow/rans/volumevariables.hh:259
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:85
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:114