3.1-git
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 wallElementIdx_ = problem.wallElementIdx_[elementIdx_];
97 wallDistance_ = problem.wallDistance_[elementIdx_];
98 velocity_ = problem.velocity_[elementIdx_];
99 velocityMaximum_ = problem.velocityMaximum_[wallElementIdx_];
100 velocityGradients_ = problem.velocityGradients_[elementIdx_];
101 const auto flowNormalAxis = problem.flowNormalAxis_[elementIdx_];
102 const auto wallNormalAxis = problem.wallNormalAxis_[elementIdx_];
103 uStar_ = sqrt(problem.kinematicViscosity_[wallElementIdx_]
104 * abs(problem.velocityGradients_[wallElementIdx_][flowNormalAxis][wallNormalAxis]));
105 uStar_ = max(uStar_, 1e-10); // zero values lead to numerical problems in some turbulence models
106 yPlus_ = wallDistance_ * uStar_ / problem.kinematicViscosity_[elementIdx_];
107 uPlus_ = velocity_[flowNormalAxis] / uStar_;
108 karmanConstant_ = problem.karmanConstant();
109 }
110
114 unsigned int elementIdx() const
115 { return elementIdx_; }
116
120 DimVector velocity() const
121 { return velocity_; }
122
126 DimVector velocityMaximum() const
127 { return velocityMaximum_; }
128
132 DimMatrix velocityGradients() const
133 { return velocityGradients_; }
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
240 Scalar effectiveDiffusivity(int compIIdx, int compJIdx) const
241 {
242 return NavierStokesParentType::diffusionCoefficient(compIIdx, compJIdx) + eddyDiffusivity();
243 }
244
249 template<bool eB = enableEnergyBalance, typename std::enable_if_t<eB, int> = 0>
251 {
252 return NavierStokesParentType::thermalConductivity() + eddyThermalConductivity();
253 }
254
255protected:
259 Scalar setDynamicEddyViscosity_(Scalar value)
260 { return dynamicEddyViscosity_ = value; }
261
262 DimVector velocity_;
265 std::size_t elementIdx_;
266 std::size_t wallElementIdx_;
269 Scalar uStar_;
270 Scalar yPlus_;
271 Scalar uPlus_;
273 Scalar eddyDiffusivity_ = 0.0;
275};
276} // end namespace Dumux
277
278#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
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: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:270
Scalar yPlus() const
Return the dimensionless wall distance .
Definition: freeflow/rans/volumevariables.hh:156
Scalar eddyThermalConductivity_
Definition: freeflow/rans/volumevariables.hh:274
DimMatrix velocityGradients_
Definition: freeflow/rans/volumevariables.hh:264
Scalar effectiveDiffusivity(int compIIdx, int compJIdx) const
Returns the effective diffusion coefficient .
Definition: freeflow/rans/volumevariables.hh:240
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:169
DimVector velocityMaximum_
Definition: freeflow/rans/volumevariables.hh:263
DimVector velocity() const
Return the velocity vector at the control volume center.
Definition: freeflow/rans/volumevariables.hh:120
Scalar uStar() const
Return the wall friction velocity .
Definition: freeflow/rans/volumevariables.hh:150
Scalar karmanConstant_
Definition: freeflow/rans/volumevariables.hh:268
Scalar setDynamicEddyViscosity_(Scalar value)
Sets the dynamic eddy viscosity .
Definition: freeflow/rans/volumevariables.hh:259
DimVector velocity_
Definition: freeflow/rans/volumevariables.hh:262
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
Scalar uStar_
Definition: freeflow/rans/volumevariables.hh:269
std::size_t elementIdx_
Definition: freeflow/rans/volumevariables.hh:265
Scalar eddyDiffusivity_
Definition: freeflow/rans/volumevariables.hh:273
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:126
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:250
std::size_t wallElementIdx_
Definition: freeflow/rans/volumevariables.hh:266
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:272
Scalar wallDistance_
Definition: freeflow/rans/volumevariables.hh:267
unsigned int elementIdx() const
Return the element Idx of the control volume.
Definition: freeflow/rans/volumevariables.hh:114
Scalar uPlus_
Definition: freeflow/rans/volumevariables.hh:271
Scalar uPlus() const
Return the dimensionless velocity .
Definition: freeflow/rans/volumevariables.hh:162
DimMatrix velocityGradients() const
Return the velocity gradients at the control volume center.
Definition: freeflow/rans/volumevariables.hh:132