3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
freeflow/rans/zeroeq/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 *****************************************************************************/
24#ifndef DUMUX_ZEROEQ_VOLUME_VARIABLES_HH
25#define DUMUX_ZEROEQ_VOLUME_VARIABLES_HH
26
27#include <string>
28
29#include <dune/common/exceptions.hh>
31
32namespace Dumux {
33
38template <class Traits, class NSVolumeVariables>
40: public RANSVolumeVariables< Traits, NSVolumeVariables>
41{
43
44 using Scalar = typename Traits::PrimaryVariables::value_type;
45
46public:
48 using Indices = typename Traits::ModelTraits::Indices;
49
59 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
60 void update(const ElementSolution &elemSol,
61 const Problem &problem,
62 const Element &element,
63 const SubControlVolume& scv)
64 {
65 RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv);
66 updateRANSProperties(elemSol, problem, element, scv);
67 }
68
77 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
78 void updateRANSProperties(const ElementSolution &elemSol,
79 const Problem &problem,
80 const Element &element,
81 const SubControlVolume& scv)
82 {
83 RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
84 additionalRoughnessLength_ = problem.additionalRoughnessLength_[RANSParentType::elementIdx()];
86 RANSParentType::setDynamicEddyViscosity_(calculateEddyViscosity(elemSol, problem, element, scv, problem.eddyViscosityModel_));
89 }
90
100 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
101 Scalar calculateEddyViscosity(const ElementSolution &elemSol,
102 const Problem &problem,
103 const Element &element,
104 const SubControlVolume& scv,
105 const std::string modelName)
106 {
107 using std::abs;
108 using std::exp;
109 using std::sqrt;
110 Scalar kinematicEddyViscosity = 0.0;
111 unsigned int flowNormalAxis = problem.flowNormalAxis_[RANSParentType::elementIdx()];
112 unsigned int wallNormalAxis = problem.wallNormalAxis_[RANSParentType::elementIdx()];
113 Scalar velGrad = abs(RANSParentType::velocityGradients()[flowNormalAxis][wallNormalAxis]);
114
115 if (modelName.compare("none") == 0)
116 {
117 // kinematicEddyViscosity = 0.0
118 }
119 else if (modelName.compare("prandtl") == 0)
120 {
121 Scalar mixingLength = problem.karmanConstant() * wallDistanceRough();
122 kinematicEddyViscosity = mixingLength * mixingLength * velGrad;
123 }
124 else if (modelName.compare("vanDriest") == 0)
125 {
126 Scalar mixingLength = problem.karmanConstant() * wallDistanceRough()
127 * (1.0 - exp(-yPlusRough() / 26.0))
128 / sqrt(1.0 - exp(-0.26 * yPlusRough()));
129 kinematicEddyViscosity = mixingLength * mixingLength * velGrad;
130 }
131 else if (modelName.compare("baldwinLomax") == 0)
132 {
133 kinematicEddyViscosity = problem.kinematicEddyViscosity_[RANSParentType::elementIdx()];
134 }
135 else
136 {
137 DUNE_THROW(Dune::NotImplemented,
138 "The eddy viscosity model \"" << modelName << "\" is not implemented.");
139 }
140
142 }
143
147 Scalar wallDistanceRough() const
149
153 Scalar yPlusRough() const
154 { return yPlusRough_; }
155
156protected:
158 Scalar yPlusRough_ = 0.0;
159};
160
161} // end namespace Dumux
162
163#endif // DUMUX_ZEROEQ_VOLUME_VARIABLES_HH
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 Reynolds-Averaged Navier-Stokes models.
Definition: freeflow/rans/volumevariables.hh:42
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 uStar() const
Return the wall friction velocity .
Definition: freeflow/rans/volumevariables.hh:150
Scalar setDynamicEddyViscosity_(Scalar value)
Sets the dynamic eddy viscosity .
Definition: freeflow/rans/volumevariables.hh:254
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
Scalar kinematicEddyViscosity() const
Return the kinematic eddy viscosity of the flow within the control volume.
Definition: freeflow/rans/volumevariables.hh:183
unsigned int elementIdx() const
Return the element Idx of the control volume.
Definition: freeflow/rans/volumevariables.hh:114
DimMatrix velocityGradients() const
Return the velocity gradients at the control volume center.
Definition: freeflow/rans/volumevariables.hh:132
Volume variables for the single-phase 0-Eq. model.
Definition: freeflow/rans/zeroeq/volumevariables.hh:41
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/zeroeq/volumevariables.hh:60
Scalar wallDistanceRough() const
Return the wall distance including an additional roughness length.
Definition: freeflow/rans/zeroeq/volumevariables.hh:147
typename Traits::ModelTraits::Indices Indices
export the indices type
Definition: freeflow/rans/zeroeq/volumevariables.hh:48
Scalar yPlusRough() const
Return the dimensionless wall distance including an additional roughness length.
Definition: freeflow/rans/zeroeq/volumevariables.hh:153
Scalar additionalRoughnessLength_
Definition: freeflow/rans/zeroeq/volumevariables.hh:157
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/zeroeq/volumevariables.hh:78
Scalar calculateEddyViscosity(const ElementSolution &elemSol, const Problem &problem, const Element &element, const SubControlVolume &scv, const std::string modelName)
Calculate and set the dynamic eddy viscosity.
Definition: freeflow/rans/zeroeq/volumevariables.hh:101
Scalar yPlusRough_
Definition: freeflow/rans/zeroeq/volumevariables.hh:158