3.4
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
28#include <dune/common/math.hh>
31
32namespace Dumux {
33
39template <class Traits, class NSVolumeVariables>
41: public RANSVolumeVariables<Traits, NSVolumeVariables>
42{
44
45 using Scalar = typename Traits::PrimaryVariables::value_type;
46 using DimVector = Dune::FieldVector<Scalar, Traits::ModelTraits::dim()>;
47
48public:
50 using Indices = typename Traits::ModelTraits::Indices;
51
61 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
62 void update(const ElementSolution &elemSol,
63 const Problem &problem,
64 const Element &element,
65 const SubControlVolume& scv)
66 {
67 RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv);
68 updateRANSProperties(elemSol, problem, element, scv);
69 }
70
81 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
82 void updateRANSProperties(const ElementSolution &elemSol,
83 const Problem &problem,
84 const Element &element,
85 const SubControlVolume& scv)
86 {
87 RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
88 viscosityTilde_ = elemSol[0][Indices::viscosityTildeIdx];
89 storedViscosityTilde_ = problem.storedViscosityTilde(RANSParentType::elementIdx());
90 storedViscosityTildeGradient_ = problem.storedViscosityTildeGradient(RANSParentType::elementIdx());
91 stressTensorScalarProduct_ = problem.stressTensorScalarProduct(RANSParentType::elementIdx());
92 vorticityTensorScalarProduct_ = problem.vorticityTensorScalarProduct(RANSParentType::elementIdx());
93 if (problem.useStoredEddyViscosity())
94 RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity(RANSParentType::elementIdx()));
95 else
99 }
100
105 { return viscosityTilde() * fv1() * RANSParentType::density(); }
106
110 Scalar viscosityTilde() const
111 { return viscosityTilde_; }
112
116 Scalar storedViscosityTilde() const
117 { return storedViscosityTilde_; }
118
124
130
134 Scalar fv1() const
135 {
138 + cv1() * cv1() * cv1());
139 }
140
142 Scalar fv2() const
143 { return 1.0 - viscosityRatio() / (1.0 + viscosityRatio() * fv1()); }
144
146 Scalar ft2() const
147 {
148 using std::exp;
149 // the trip correction term is dropped according to Versteeg2009 and Wilcox2006
150 // return ct3() * exp(-ct4() * viscosityRatio() * viscosityRatio());
151 return 0.0;
152 }
153
155 Scalar fW() const
156 {
157 using std::pow;
158 using Dune::power;
159 return g() * pow(1.0 + power(cw3(), 6) / (power(g(), 6) + power(cw3(), 6)), 1.0/6.0);
160 }
161
163 Scalar g() const
164 {
165 using Dune::power;
166 return r() + cw2() * (power(r(), 6) - r());
167 }
168
170 Scalar r() const
171 {
172 using std::min;
173 return min(10.0,
177 }
178
180 Scalar viscosityRatio() const
182
183 /*
184 * ! \brief Returns a modified version of the stress tensor scalar product
185 *
186 * According to <a href="https://turbmodels.larc.nasa.gov/spalart.html">NASA</a>
187 * this term should never be zero and different limiters might be used.
188 * The Implementation uses the one proposed in:
189 * Allmaras, S. R., Johnson, F. T., and Spalart, P. R.,
190 * "Modifications and Clarifications for the Implementation of the Spalart-Allmaras Turbulence Model," ICCFD7-1902
191 */
193 {
194 // original form
195 // return vorticityMagnitude()
196 // + viscosityTilde() * fv2()
197 // / RANSParentType::karmanConstant() / RANSParentType::karmanConstant()
198 // / RANSParentType::wallDistance() / RANSParentType::wallDistance();
199
200 // limiter form, literature source see above
201 Scalar sBar = viscosityTilde() * fv2()
204 return sBar < -c2() * vorticityMagnitude()
206 + (vorticityMagnitude() * (c2() * c2() * vorticityMagnitude() + c3() * sBar))
207 / ((c3() - 2.0 * c2()) * vorticityMagnitude() - sBar)
208 : vorticityMagnitude() + sBar;
209 }
210
212 Scalar vorticityMagnitude() const
213 {
214 using std::sqrt;
215 return sqrt(2.0 * vorticityTensorScalarProduct_);
216 }
217
219 Scalar c2() const
220 { return 0.7; }
221
223 Scalar c3() const
224 { return 0.9; }
225
227 Scalar sigma() const
228 { return 2.0/3.0; }
229
231 Scalar cb1() const
232 { return 0.1355; }
233
235 Scalar cb2() const
236 { return 0.622; }
237
239 Scalar cv1() const
240 { return 7.1; }
241
243 Scalar ct3() const
244 { return 1.2; }
245
247 Scalar ct4() const
248 { return 0.5; }
249
251 Scalar cw1() const
252 {
254 + (1.0 + cb2()) / sigma();
255 }
256
258 Scalar cw2() const
259 { return 0.3; }
260
262 Scalar cw3() const
263 { return 2.0; }
264
265protected:
266 Scalar viscosityTilde_ = 0.0;
268 DimVector storedViscosityTildeGradient_ = DimVector(0.0);
271};
272
273} // end namespace Dumux
274
275#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Definition: adapt.hh:29
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:42
Scalar c2() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:219
Scalar fv2() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:142
Scalar vorticityMagnitude() const
Returns the magnitude of the vorticity.
Definition: freeflow/rans/oneeq/volumevariables.hh:212
Scalar cb2() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:235
Scalar fv1() const
Returns damping function for the eddy viscosity.
Definition: freeflow/rans/oneeq/volumevariables.hh:134
DimVector storedViscosityTildeGradient() const
Returns the gradient of the viscosity parameter.
Definition: freeflow/rans/oneeq/volumevariables.hh:122
Scalar viscosityTilde_
Definition: freeflow/rans/oneeq/volumevariables.hh:266
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:62
Scalar sigma() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:227
Scalar viscosityRatio() const
Returns the ratio of the kinematic viscosity and the viscosity parameter.
Definition: freeflow/rans/oneeq/volumevariables.hh:180
typename Traits::ModelTraits::Indices Indices
export the indices type
Definition: freeflow/rans/oneeq/volumevariables.hh:50
Scalar storedViscosityTilde_
Definition: freeflow/rans/oneeq/volumevariables.hh:267
Scalar vorticityTensorScalarProduct_
Definition: freeflow/rans/oneeq/volumevariables.hh:270
Scalar ft2() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:146
Scalar g() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:163
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:82
Scalar stressTensorScalarProductTilde() const
Definition: freeflow/rans/oneeq/volumevariables.hh:192
DimVector storedViscosityTildeGradient_
Definition: freeflow/rans/oneeq/volumevariables.hh:268
Scalar fW() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:155
Scalar c3() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:223
Scalar calculateEddyViscosity()
Returns the dynamic eddy viscosity .
Definition: freeflow/rans/oneeq/volumevariables.hh:104
Scalar storedViscosityTilde() const
Returns the viscosity parameter from the last iteration .
Definition: freeflow/rans/oneeq/volumevariables.hh:116
Scalar cw1() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:251
Scalar cb1() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:231
Scalar ct3() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:243
Scalar cv1() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:239
Scalar r() const
Returns a model function.
Definition: freeflow/rans/oneeq/volumevariables.hh:170
Scalar ct4() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:247
Scalar viscosityTilde() const
Returns the viscosity parameter .
Definition: freeflow/rans/oneeq/volumevariables.hh:110
Scalar stressTensorScalarProduct() const
Returns the scalar product of the stress tensor.
Definition: freeflow/rans/oneeq/volumevariables.hh:128
Scalar stressTensorScalarProduct_
Definition: freeflow/rans/oneeq/volumevariables.hh:269
Scalar cw2() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:258
Scalar cw3() const
Returns a model constant.
Definition: freeflow/rans/oneeq/volumevariables.hh:262
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:156
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:221
Scalar wallDistance() const
Return the wall distance of the control volume.
Definition: freeflow/rans/volumevariables.hh:150
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:266
Scalar kinematicViscosity() const
Return the kinematic viscosity of the fluid within the control volume.
Definition: freeflow/rans/volumevariables.hh:202
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:210
unsigned int elementIdx() const
Return the element Idx of the control volume.
Definition: freeflow/rans/volumevariables.hh:120