version 3.10-dev
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_ZEROEQ_VOLUME_VARIABLES_HH
13#define DUMUX_ZEROEQ_VOLUME_VARIABLES_HH
14
15#include <string>
16
17#include <dune/common/exceptions.hh>
19
20namespace Dumux {
21
26template <class Traits, class NSVolumeVariables>
28: public RANSVolumeVariables< Traits, NSVolumeVariables>
29{
31
32 using Scalar = typename Traits::PrimaryVariables::value_type;
33
34public:
36 using Indices = typename Traits::ModelTraits::Indices;
37
47 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
48 void update(const ElementSolution &elemSol,
49 const Problem &problem,
50 const Element &element,
51 const SubControlVolume& scv)
52 {
53 RANSParentType::updateNavierStokesVolVars(elemSol, problem, element, scv);
54 updateRANSProperties(elemSol, problem, element, scv);
55 }
56
65 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
66 void updateRANSProperties(const ElementSolution &elemSol,
67 const Problem &problem,
68 const Element &element,
69 const SubControlVolume& scv)
70 {
71 RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
72 additionalRoughnessLength_ = problem.additionalRoughnessLength(RANSParentType::elementIdx());
74 RANSParentType::setDynamicEddyViscosity_(calculateEddyViscosity(elemSol, problem, element, scv, problem.eddyViscosityModel()));
77 }
78
88 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
89 Scalar calculateEddyViscosity(const ElementSolution &elemSol,
90 const Problem &problem,
91 const Element &element,
92 const SubControlVolume& scv,
93 const std::string modelName)
94 {
95 using std::abs;
96 using std::exp;
97 using std::sqrt;
98 Scalar kinematicEddyViscosity = 0.0;
99 unsigned int flowDirectionAxis = problem.flowDirectionAxis(RANSParentType::elementIdx());
100 unsigned int wallNormalAxis = problem.wallNormalAxis(RANSParentType::elementIdx());
101 Scalar velGrad = abs(RANSParentType::velocityGradients()[flowDirectionAxis][wallNormalAxis]);
102
103 if (modelName.compare("none") == 0)
104 {
105 // kinematicEddyViscosity = 0.0
106 }
107 else if (modelName.compare("prandtl") == 0)
108 {
109 Scalar mixingLength = problem.karmanConstant() * wallDistanceRough();
110 kinematicEddyViscosity = mixingLength * mixingLength * velGrad;
111 }
112 else if (modelName.compare("vanDriest") == 0)
113 {
114 Scalar mixingLength = problem.karmanConstant() * wallDistanceRough()
115 * (1.0 - exp(-yPlusRough() / 26.0))
116 / sqrt(1.0 - exp(-0.26 * yPlusRough()));
117 kinematicEddyViscosity = mixingLength * mixingLength * velGrad;
118 }
119 else if (modelName.compare("baldwinLomax") == 0)
120 {
121 kinematicEddyViscosity = problem.kinematicEddyViscosity(RANSParentType::elementIdx());
122 }
123 else
124 {
125 DUNE_THROW(Dune::NotImplemented,
126 "The eddy viscosity model \"" << modelName << "\" is not implemented.");
127 }
128
130 }
131
135 Scalar wallDistanceRough() const
137
141 Scalar yPlusRough() const
142 { return yPlusRough_; }
143
144protected:
146 Scalar yPlusRough_ = 0.0;
147};
148
149} // end namespace Dumux
150
151#endif
Volume variables for the isothermal single-phase Reynolds-Averaged Navier-Stokes models.
Definition: freeflow/rans/volumevariables.hh:30
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:53
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:73
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:108
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:29
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:48
Scalar wallDistanceRough() const
Return the wall distance including an additional roughness length.
Definition: freeflow/rans/zeroeq/volumevariables.hh:135
typename Traits::ModelTraits::Indices Indices
export the indices type
Definition: freeflow/rans/zeroeq/volumevariables.hh:36
Scalar yPlusRough() const
Return the dimensionless wall distance including an additional roughness length.
Definition: freeflow/rans/zeroeq/volumevariables.hh:141
Scalar additionalRoughnessLength_
Definition: freeflow/rans/zeroeq/volumevariables.hh:145
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:66
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:89
Scalar yPlusRough_
Definition: freeflow/rans/zeroeq/volumevariables.hh:146
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Definition: adapt.hh:17