version 3.8
freeflow/rans/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_RANS_VOLUME_VARIABLES_HH
14#define DUMUX_RANS_VOLUME_VARIABLES_HH
15
16#include <dune/common/fvector.hh>
17#include <dune/common/fmatrix.hh>
18
20
21namespace Dumux {
22
27template <class Traits, class NSVolumeVariables>
29: public NSVolumeVariables
30{
31 using NavierStokesParentType = NSVolumeVariables;
32
33 using Scalar = typename Traits::PrimaryVariables::value_type;
34
35 enum { dimWorld = Traits::ModelTraits::dim() };
36 using DimVector = Dune::FieldVector<Scalar, dimWorld>;
37 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
38
39 static constexpr bool enableEnergyBalance = Traits::ModelTraits::enableEnergyBalance();
40
41public:
42
52 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
53 void updateNavierStokesVolVars(const ElementSolution &elemSol,
54 const Problem &problem,
55 const Element &element,
56 const SubControlVolume& scv)
57 {
58 NavierStokesParentType::update(elemSol, problem, element, scv);
59 }
60
72 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
73 void updateRANSProperties(const ElementSolution &elemSol,
74 const Problem &problem,
75 const Element &element,
76 const SubControlVolume& scv)
77 {
78 using std::abs;
79 using std::max;
80 using std::sqrt;
81
82 // calculate characteristic properties of the turbulent flow
83 elementIdx_ = problem.gridGeometry().elementMapper().index(element);
84 wallDistance_ = problem.wallDistance(elementIdx_);
85 ccVelocityVector_ = problem.ccVelocityVector(elementIdx_);
86 velocityGradientTensor_ = problem.velocityGradientTensor(elementIdx_);
87
88 karmanConstant_ = problem.karmanConstant();
89 velocityMaximum_ = problem.velocityMaximum(elementIdx_);
90 velocityMinimum_ = problem.velocityMinimum(elementIdx_);
91 if (problem.isFlatWallBounded())
92 {
93 const auto flowDirectionAxis = problem.flowDirectionAxis(elementIdx_);
94 const auto wallNormalAxis = problem.wallNormalAxis(elementIdx_);
95 velocityMaximum_ = problem.velocityMaximum(problem.wallElementIndex(elementIdx_));
96 velocityMinimum_ = problem.velocityMinimum(problem.wallElementIndex(elementIdx_));
97 uStar_ = sqrt(problem.kinematicViscosity(problem.wallElementIndex(elementIdx_))
98 * abs(problem.velocityGradient(problem.wallElementIndex(elementIdx_), flowDirectionAxis, wallNormalAxis)));
99 uStar_ = max(uStar_, 1e-10); // zero values lead to numerical problems in some turbulence models
100 yPlus_ = wallDistance_ * uStar_ / problem.kinematicViscosity(elementIdx_);
101 uPlus_ = problem.ccVelocity(elementIdx_, flowDirectionAxis) / uStar_;
102 }
103 }
104
108 unsigned int elementIdx() const
109 { return elementIdx_; }
110
114 DimVector ccVelocityVector() const
115 { return ccVelocityVector_; }
116
120 DimVector velocityMaximum() const
121 { return velocityMaximum_; }
122
126 DimVector velocityMinimum() const
127 { return velocityMinimum_; }
128
132 DimMatrix velocityGradients() const
133 { return velocityGradientTensor_; }
134
138 Scalar wallDistance() const
139 { return wallDistance_; }
140
144 Scalar karmanConstant() const
145 { return karmanConstant_; }
146
150 Scalar uStar() const
151 { return uStar_; }
152
156 Scalar yPlus() const
157 { return yPlus_; }
158
162 Scalar uPlus() const
163 { return uPlus_; }
164
169 Scalar dynamicEddyViscosity() const
170 { return dynamicEddyViscosity_; }
171
176 Scalar effectiveViscosity() const
178
185
190 Scalar kinematicViscosity() const
192
197 template<class Problem>
198 void calculateEddyDiffusivity(const Problem& problem)
199 {
201 / problem.turbulentSchmidtNumber();
202 }
203
208 template<class Problem, bool eB = enableEnergyBalance, typename std::enable_if_t<eB, int> = 0>
209 void calculateEddyThermalConductivity(const Problem& problem)
210 {
213 * NavierStokesParentType::heatCapacity()
214 / problem.turbulentPrandtlNumber();
215 }
216
218 template<class Problem, bool eB = enableEnergyBalance, typename std::enable_if_t<!eB, int> = 0>
219 void calculateEddyThermalConductivity(const Problem& problem)
220 { eddyThermalConductivity_ = 0.0; }
221
225 Scalar eddyDiffusivity() const
226 { return eddyDiffusivity_; }
227
232 { return eddyThermalConductivity_; }
233
237 Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
238 { return NavierStokesParentType::diffusionCoefficient(0, compIIdx, compJIdx) + eddyDiffusivity(); }
239
244 template<bool eB = enableEnergyBalance, typename std::enable_if_t<eB, int> = 0>
246 {
247 return NavierStokesParentType::thermalConductivity() + eddyThermalConductivity();
248 }
249
250protected:
254 Scalar setDynamicEddyViscosity_(Scalar value)
255 { return dynamicEddyViscosity_ = value; }
256
261 std::size_t elementIdx_;
264 Scalar uStar_ = 0.0;
265 Scalar yPlus_ = 0.0;
266 Scalar uPlus_ = 0.0;
268 Scalar eddyDiffusivity_ = 0.0;
270};
271} // end namespace Dumux
272
273#endif
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 eddyDiffusivity() const
Returns the eddy diffusivity .
Definition: freeflow/rans/volumevariables.hh:225
Scalar eddyThermalConductivity() const
Returns the eddy thermal conductivity .
Definition: freeflow/rans/volumevariables.hh:231
Scalar wallDistance() const
Return the wall distance of the control volume.
Definition: freeflow/rans/volumevariables.hh:138
Scalar yPlus_
Definition: freeflow/rans/volumevariables.hh:265
Scalar yPlus() const
Return the dimensionless wall distance .
Definition: freeflow/rans/volumevariables.hh:156
Scalar eddyThermalConductivity_
Definition: freeflow/rans/volumevariables.hh:269
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 dynamicEddyViscosity() const
Return the dynamic eddy viscosity of the flow within the control volume.
Definition: freeflow/rans/volumevariables.hh:169
DimVector velocityMaximum_
Definition: freeflow/rans/volumevariables.hh:258
Scalar uStar() const
Return the wall friction velocity .
Definition: freeflow/rans/volumevariables.hh:150
Scalar karmanConstant_
Definition: freeflow/rans/volumevariables.hh:263
DimVector ccVelocityVector() const
Return the velocity vector at the control volume center.
Definition: freeflow/rans/volumevariables.hh:114
Scalar setDynamicEddyViscosity_(Scalar value)
Sets the dynamic eddy viscosity .
Definition: freeflow/rans/volumevariables.hh:254
Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition: freeflow/rans/volumevariables.hh:237
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
Scalar uStar_
Definition: freeflow/rans/volumevariables.hh:264
std::size_t elementIdx_
Definition: freeflow/rans/volumevariables.hh:261
Scalar eddyDiffusivity_
Definition: freeflow/rans/volumevariables.hh:268
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
DimVector velocityMaximum() const
Return the maximum velocity vector of the wall segment.
Definition: freeflow/rans/volumevariables.hh:120
Scalar kinematicEddyViscosity() const
Return the kinematic eddy viscosity of the flow within the control volume.
Definition: freeflow/rans/volumevariables.hh:183
Scalar effectiveThermalConductivity() const
Returns the effective thermal conductivity of the fluid-flow in the sub-control volume.
Definition: freeflow/rans/volumevariables.hh:245
DimVector velocityMinimum() const
Return the minimum velocity vector of the wall segment.
Definition: freeflow/rans/volumevariables.hh:126
DimVector ccVelocityVector_
Definition: freeflow/rans/volumevariables.hh:257
Scalar effectiveViscosity() const
Return the effective dynamic viscosity of the fluid within the control volume.
Definition: freeflow/rans/volumevariables.hh:176
Scalar dynamicEddyViscosity_
Definition: freeflow/rans/volumevariables.hh:267
Scalar wallDistance_
Definition: freeflow/rans/volumevariables.hh:262
unsigned int elementIdx() const
Return the element Idx of the control volume.
Definition: freeflow/rans/volumevariables.hh:108
Scalar uPlus_
Definition: freeflow/rans/volumevariables.hh:266
Scalar uPlus() const
Return the dimensionless velocity .
Definition: freeflow/rans/volumevariables.hh:162
DimVector velocityMinimum_
Definition: freeflow/rans/volumevariables.hh:259
DimMatrix velocityGradientTensor_
Definition: freeflow/rans/volumevariables.hh:260
DimMatrix velocityGradients() const
Return the velocity gradients at the control volume center.
Definition: freeflow/rans/volumevariables.hh:132
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:62
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.