3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * 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_RANS_VOLUME_VARIABLES_HH
26#define DUMUX_RANS_VOLUME_VARIABLES_HH
27
28#include <dune/common/fvector.hh>
29#include <dune/common/fmatrix.hh>
30
32
33namespace Dumux {
34
39template <class Traits, class NSVolumeVariables>
41: public NSVolumeVariables
42{
43 using NavierStokesParentType = NSVolumeVariables;
44
45 using Scalar = typename Traits::PrimaryVariables::value_type;
46
47 enum { dimWorld = Traits::ModelTraits::dim() };
48 using DimVector = Dune::FieldVector<Scalar, dimWorld>;
49 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
50
51 static constexpr bool enableEnergyBalance = Traits::ModelTraits::enableEnergyBalance();
52
53public:
54
64 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
65 void updateNavierStokesVolVars(const ElementSolution &elemSol,
66 const Problem &problem,
67 const Element &element,
68 const SubControlVolume& scv)
69 {
70 NavierStokesParentType::update(elemSol, problem, element, scv);
71 }
72
84 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
85 void updateRANSProperties(const ElementSolution &elemSol,
86 const Problem &problem,
87 const Element &element,
88 const SubControlVolume& scv)
89 {
90 using std::abs;
91 using std::max;
92 using std::sqrt;
93
94 // calculate characteristic properties of the turbulent flow
95 elementIdx_ = problem.gridGeometry().elementMapper().index(element);
96 wallDistance_ = problem.wallDistance(elementIdx_);
97 ccVelocityVector_ = problem.ccVelocityVector(elementIdx_);
98 velocityGradientTensor_ = problem.velocityGradientTensor(elementIdx_);
99
100 karmanConstant_ = problem.karmanConstant();
101 velocityMaximum_ = problem.velocityMaximum(elementIdx_);
102 velocityMinimum_ = problem.velocityMinimum(elementIdx_);
103 if (problem.isFlatWallBounded())
104 {
105 const auto flowDirectionAxis = problem.flowDirectionAxis(elementIdx_);
106 const auto wallNormalAxis = problem.wallNormalAxis(elementIdx_);
107 velocityMaximum_ = problem.velocityMaximum(problem.wallElementIndex(elementIdx_));
108 velocityMinimum_ = problem.velocityMinimum(problem.wallElementIndex(elementIdx_));
109 uStar_ = sqrt(problem.kinematicViscosity(problem.wallElementIndex(elementIdx_))
110 * abs(problem.velocityGradient(problem.wallElementIndex(elementIdx_), flowDirectionAxis, wallNormalAxis)));
111 uStar_ = max(uStar_, 1e-10); // zero values lead to numerical problems in some turbulence models
112 yPlus_ = wallDistance_ * uStar_ / problem.kinematicViscosity(elementIdx_);
113 uPlus_ = problem.ccVelocity(elementIdx_, flowDirectionAxis) / uStar_;
114 }
115 }
116
120 unsigned int elementIdx() const
121 { return elementIdx_; }
122
126 DimVector ccVelocityVector() const
127 { return ccVelocityVector_; }
128
132 DimVector velocityMaximum() const
133 { return velocityMaximum_; }
134
138 DimVector velocityMinimum() const
139 { return velocityMinimum_; }
140
144 DimMatrix velocityGradients() const
145 { return velocityGradientTensor_; }
146
150 Scalar wallDistance() const
151 { return wallDistance_; }
152
156 Scalar karmanConstant() const
157 { return karmanConstant_; }
158
162 Scalar uStar() const
163 { return uStar_; }
164
168 Scalar yPlus() const
169 { return yPlus_; }
170
174 Scalar uPlus() const
175 { return uPlus_; }
176
181 Scalar dynamicEddyViscosity() const
182 { return dynamicEddyViscosity_; }
183
188 Scalar effectiveViscosity() const
190
197
202 Scalar kinematicViscosity() const
204
209 template<class Problem>
210 void calculateEddyDiffusivity(const Problem& problem)
211 {
213 / problem.turbulentSchmidtNumber();
214 }
215
220 template<class Problem, bool eB = enableEnergyBalance, typename std::enable_if_t<eB, int> = 0>
221 void calculateEddyThermalConductivity(const Problem& problem)
222 {
225 * NavierStokesParentType::heatCapacity()
226 / problem.turbulentPrandtlNumber();
227 }
228
230 template<class Problem, bool eB = enableEnergyBalance, typename std::enable_if_t<!eB, int> = 0>
231 void calculateEddyThermalConductivity(const Problem& problem)
232 { eddyThermalConductivity_ = 0.0; }
233
237 Scalar eddyDiffusivity() const
238 { return eddyDiffusivity_; }
239
244 { return eddyThermalConductivity_; }
245
249 Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
250 { return NavierStokesParentType::diffusionCoefficient(0, compIIdx, compJIdx) + eddyDiffusivity(); }
251
256 template<bool eB = enableEnergyBalance, typename std::enable_if_t<eB, int> = 0>
258 {
259 return NavierStokesParentType::thermalConductivity() + eddyThermalConductivity();
260 }
261
262protected:
266 Scalar setDynamicEddyViscosity_(Scalar value)
267 { return dynamicEddyViscosity_ = value; }
268
273 std::size_t elementIdx_;
276 Scalar uStar_ = 0.0;
277 Scalar yPlus_ = 0.0;
278 Scalar uPlus_ = 0.0;
280 Scalar eddyDiffusivity_ = 0.0;
282};
283} // end namespace Dumux
284
285#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Definition: adapt.hh:29
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
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 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 eddyDiffusivity() const
Returns the eddy diffusivity .
Definition: freeflow/rans/volumevariables.hh:237
Scalar eddyThermalConductivity() const
Returns the eddy thermal conductivity .
Definition: freeflow/rans/volumevariables.hh:243
Scalar wallDistance() const
Return the wall distance of the control volume.
Definition: freeflow/rans/volumevariables.hh:150
Scalar yPlus_
Definition: freeflow/rans/volumevariables.hh:277
Scalar yPlus() const
Return the dimensionless wall distance .
Definition: freeflow/rans/volumevariables.hh:168
Scalar eddyThermalConductivity_
Definition: freeflow/rans/volumevariables.hh:281
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 dynamicEddyViscosity() const
Return the dynamic eddy viscosity of the flow within the control volume.
Definition: freeflow/rans/volumevariables.hh:181
DimVector velocityMaximum_
Definition: freeflow/rans/volumevariables.hh:270
Scalar uStar() const
Return the wall friction velocity .
Definition: freeflow/rans/volumevariables.hh:162
Scalar karmanConstant_
Definition: freeflow/rans/volumevariables.hh:275
DimVector ccVelocityVector() const
Return the velocity vector at the control volume center.
Definition: freeflow/rans/volumevariables.hh:126
Scalar setDynamicEddyViscosity_(Scalar value)
Sets the dynamic eddy viscosity .
Definition: freeflow/rans/volumevariables.hh:266
Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition: freeflow/rans/volumevariables.hh:249
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
Scalar uStar_
Definition: freeflow/rans/volumevariables.hh:276
std::size_t elementIdx_
Definition: freeflow/rans/volumevariables.hh:273
Scalar eddyDiffusivity_
Definition: freeflow/rans/volumevariables.hh:280
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
DimVector velocityMaximum() const
Return the maximum velocity vector of the wall segment.
Definition: freeflow/rans/volumevariables.hh:132
Scalar kinematicEddyViscosity() const
Return the kinematic eddy viscosity of the flow within the control volume.
Definition: freeflow/rans/volumevariables.hh:195
Scalar effectiveThermalConductivity() const
Returns the effective thermal conductivity of the fluid-flow in the sub-control volume.
Definition: freeflow/rans/volumevariables.hh:257
DimVector velocityMinimum() const
Return the minimum velocity vector of the wall segment.
Definition: freeflow/rans/volumevariables.hh:138
DimVector ccVelocityVector_
Definition: freeflow/rans/volumevariables.hh:269
Scalar effectiveViscosity() const
Return the effective dynamic viscosity of the fluid within the control volume.
Definition: freeflow/rans/volumevariables.hh:188
Scalar dynamicEddyViscosity_
Definition: freeflow/rans/volumevariables.hh:279
Scalar wallDistance_
Definition: freeflow/rans/volumevariables.hh:274
unsigned int elementIdx() const
Return the element Idx of the control volume.
Definition: freeflow/rans/volumevariables.hh:120
Scalar uPlus_
Definition: freeflow/rans/volumevariables.hh:278
Scalar uPlus() const
Return the dimensionless velocity .
Definition: freeflow/rans/volumevariables.hh:174
DimVector velocityMinimum_
Definition: freeflow/rans/volumevariables.hh:271
DimMatrix velocityGradientTensor_
Definition: freeflow/rans/volumevariables.hh:272
DimMatrix velocityGradients() const
Return the velocity gradients at the control volume center.
Definition: freeflow/rans/volumevariables.hh:144