nutUSpaldingWallFunctionFvPatchScalarField.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2019-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::nutUSpaldingWallFunctionFvPatchScalarField
29
30Group
31 grpWallFunctions
32
33Description
34 This boundary condition provides a wall function for the turbulent
35 viscosity (i.e. \c nut) based on velocity (i.e. \c U). Using Spalding's
36 law gives a continuous \c nut profile to the wall.
37
38 \f[
39 y^+ = u^+ + \frac{1}{E} \left[exp(\kappa u^+) - 1 - \kappa u^+\,
40 - 0.5 (\kappa u^+)^2 - \frac{1}{6} (\kappa u^+)^3\right]
41 \f]
42
43 where
44 \vartable
45 y^+ | Wall-normal height of a cell centre in wall units
46 u^+ | Velocity at \f$y^+\f$ in wall units
47 \kappa | von Karman constant
48 \endvartable
49
50Usage
51 Example of the boundary condition specification:
52 \verbatim
53 <patchName>
54 {
55 // Mandatory entries
56 type nutUSpaldingWallFunction;
57
58 // Optional entries
59 maxIter 10;
60 tolerance 0.0001;
61
62 // Inherited entries
63 ...
64 }
65 \endverbatim
66
67 where the entries mean:
68 \table
69 Property | Description | Type | Reqd | Deflt
70 type | Type name: nutUSpaldingWallFunction | word | yes | -
71 maxIter | Number of Newton-Raphson iterations | label | no | 10
72 tolerance | Convergence tolerance | scalar | no | 0.0001
73 \endtable
74
75 The inherited entries are elaborated in:
76 - \link nutWallFunctionFvPatchScalarField.H \endlink
77
78Note
79 - Suffers from non-exact restart since \c correctNut() (called through
80 \c turbulence->validate) returns a slightly different value every time
81 it is called. This is since the seed for the Newton-Raphson iteration
82 uses the current value of \c *this (\c =nut ).
83 - This can be avoided by overriding the tolerance. This also switches on
84 a pre-detection whether the current nut already satisfies the turbulence
85 conditions and if so does not change it at all. This means that the nut
86 only changes if it 'has really changed'. This probably should be used with
87 a tight tolerance, to make sure to kick every iteration, e.g.
88 maxIter 100;
89 tolerance 1e-7;
90
91SourceFiles
92 nutUSpaldingWallFunctionFvPatchScalarField.C
93
94\*---------------------------------------------------------------------------*/
95
96#ifndef nutUSpaldingWallFunctionFvPatchScalarField_H
97#define nutUSpaldingWallFunctionFvPatchScalarField_H
98
100
101// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102
103namespace Foam
104{
105
106/*---------------------------------------------------------------------------*\
107 Class nutUSpaldingWallFunctionFvPatchScalarField Declaration
108\*---------------------------------------------------------------------------*/
109
110class nutUSpaldingWallFunctionFvPatchScalarField
111:
112 public nutWallFunctionFvPatchScalarField
113{
114protected:
115
116 // Protected Data
117
118 //- Max iterations in calcNut
119 const label maxIter_;
120
121 //- Convergence tolerance
122 const scalar tolerance_;
123
124 //- Uncomment in case of intrumentation
125 //mutable uint64_t invocations_;
126 //mutable uint64_t nontrivial_;
127 //mutable uint64_t nonconvergence_;
128 //mutable uint64_t iterations_;
129
130
131 // Protected Member Functions
132
133 //- Calculate the turbulent viscosity
134 virtual tmp<scalarField> calcNut() const;
135
136 //- Calculate the friction velocity
137 tmp<scalarField> calcUTau(const scalarField& magGradU) const;
138
139 //- Calculate the friction velocity and number of iterations for
140 //- convergence
141 tmp<scalarField> calcUTau
142 (
143 const scalarField& magGradU,
144 const label maxIter,
146 ) const;
147
148 //- Write local wall function variables
149 void writeLocalEntries(Ostream&) const;
150
151
152public:
153
154 //- Runtime type information
155 TypeName("nutUSpaldingWallFunction");
156
158 // Constructors
159
160 //- Construct from patch and internal field
162 (
163 const fvPatch&,
165 );
166
167 //- Construct from patch, internal field and dictionary
169 (
170 const fvPatch&,
172 const dictionary&
173 );
174
175 //- Construct by mapping given
176 //- nutUSpaldingWallFunctionFvPatchScalarField
177 //- onto a new patch
179 (
181 const fvPatch&,
183 const fvPatchFieldMapper&
184 );
185
186 //- Construct as copy
188 (
190 );
191
192 //- Construct and return a clone
193 virtual tmp<fvPatchScalarField> clone() const
194 {
196 (
198 );
199 }
200
201 //- Construct as copy setting internal field reference
203 (
206 );
207
208 //- Construct and return a clone setting internal field reference
210 (
212 ) const
213 {
215 (
217 );
218 }
219
220
221 //- Destructor
223
224
225 // Member Functions
226
227 // Evaluation
229 //- Calculate and return the yPlus at the boundary
230 virtual tmp<scalarField> yPlus() const;
231
232
233 // I-O
234
235 //- Write
236 virtual void write(Ostream& os) const;
237};
238
239
240// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241
242} // End namespace Foam
243
244// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245
246#endif
247
248// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
This boundary condition provides a wall function for the turbulent viscosity (i.e....
virtual tmp< scalarField > yPlus() const
Calculate and return the yPlus at the boundary.
virtual tmp< fvPatchScalarField > clone(const DimensionedField< scalar, volMesh > &iF) const
Construct and return a clone setting internal field reference.
void writeLocalEntries(Ostream &) const
Write local wall function variables.
TypeName("nutUSpaldingWallFunction")
Runtime type information.
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
tmp< scalarField > calcUTau(const scalarField &magGradU) const
Calculate the friction velocity.
virtual tmp< scalarField > calcNut() const
Uncomment in case of intrumentation.
The class nutWallFunction is an abstract base class that hosts calculation methods and common functi...
A class for managing temporary objects.
Definition: tmp.H:65
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
runTime write()
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73