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 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::nutUSpaldingWallFunctionFvPatchScalarField
29 
30 Group
31  grpWallFunctions
32 
33 Description
34  This boundary condition provides a wall constraint on the turbulent
35  kinematic viscosity, i.e. \c nut, when using wall functions for rough walls,
36  based on velocity, \c U, using Spalding's law to give a continuous \c nut
37  profile to the wall (y+ = 0)
38 
39  \f[
40  y^+ = u^+ + \frac{1}{E} \left[exp(\kappa u^+) - 1 - \kappa u^+\,
41  - 0.5 (\kappa u^+)^2 - \frac{1}{6} (\kappa u^+)^3\right]
42  \f]
43 
44  where
45  \vartable
46  y^+ | non-dimensional position
47  u^+ | non-dimensional velocity
48  \kappa | Von Karman constant
49  \endvartable
50 
51 Usage
52  \table
53  Property | Description | Required | Default value
54  Cmu | Model coefficient | no | 0.09
55  kappa | Von Karman constant | no | 0.41
56  E | Model coefficient | no | 9.8
57  maxIter | Number of Newton-Raphson iterations | no | 10
58  tolerance | Convergence tolerance | no | 0.0001
59  \endtable
60 
61  Example of the boundary condition specification:
62  \verbatim
63  <patchName>
64  {
65  // Mandatory entries
66  type nutUSpaldingWallFunction;
67 
68  // Optional entries
69  }
70  \endverbatim
71 
72 See also
73  Foam::nutWallFunctionFvPatchScalarField
74 
75 Note
76  Suffers from non-exact restart since correctNut() (called through
77  turbulence->validate) returns a slightly different value every time
78  it is called. This is since the seed for the Newton-Raphson iteration
79  uses the current value of *this (= nut).
80 
81  This can be avoided by overriding the tolerance. This also switches on
82  a pre-detection whether the current nut already satisfies the turbulence
83  conditions and if so does not change it at all. This means that the nut
84  only changes if it 'has really changed'. This probably should be used with
85  a tight tolerance, e.g.
86 
87  maxIter 100;
88  tolerance 1e-7;
89 
90  to make sure to kick every iteration.
91 
92 SourceFiles
93  nutUSpaldingWallFunctionFvPatchScalarField.C
94 
95 \*---------------------------------------------------------------------------*/
96 
97 #ifndef nutUSpaldingWallFunctionFvPatchScalarField_H
98 #define nutUSpaldingWallFunctionFvPatchScalarField_H
99 
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 namespace Foam
105 {
106 
107 /*---------------------------------------------------------------------------*\
108  Class nutUSpaldingWallFunctionFvPatchScalarField Declaration
109 \*---------------------------------------------------------------------------*/
110 
111 class nutUSpaldingWallFunctionFvPatchScalarField
112 :
113  public nutWallFunctionFvPatchScalarField
114 {
115 protected:
116 
117  // Protected Data
118 
119  //- Max iterations in calcNut
120  const label maxIter_;
121 
122  //- Convergence tolerance
123  const scalar tolerance_;
124 
125  //- Uncomment in case of intrumentation
126  //mutable uint64_t invocations_;
127  //mutable uint64_t nontrivial_;
128  //mutable uint64_t nonconvergence_;
129  //mutable uint64_t iterations_;
130 
131 
132  // Protected Member Functions
133 
134  //- Calculate the turbulence viscosity
135  virtual tmp<scalarField> calcNut() const;
136 
137  //- Calculate the friction velocity
138  virtual tmp<scalarField> calcUTau(const scalarField& magGradU) const;
139 
140  //- Calculate the friction velocity and number of iterations for
141  //- convergence
142  virtual tmp<scalarField> calcUTau
143  (
144  const scalarField& magGradU,
145  const label maxIter,
146  scalarField& err
147  ) const;
148 
149  //- Write local wall function variables
150  virtual void writeLocalEntries(Ostream&) const;
151 
152 
153 public:
154 
155  //- Runtime type information
156  TypeName("nutUSpaldingWallFunction");
157 
158 
159  // Constructors
160 
161  //- Construct from patch and internal field
163  (
164  const fvPatch&,
166  );
167 
168  //- Construct from patch, internal field and dictionary
170  (
171  const fvPatch&,
173  const dictionary&
174  );
175 
176  //- Construct by mapping given
177  //- nutUSpaldingWallFunctionFvPatchScalarField
178  //- onto a new patch
180  (
182  const fvPatch&,
184  const fvPatchFieldMapper&
185  );
186 
187  //- Construct as copy
189  (
191  );
192 
193  //- Construct and return a clone
194  virtual tmp<fvPatchScalarField> clone() const
195  {
197  (
199  );
200  }
201 
202  //- Construct as copy setting internal field reference
204  (
207  );
208 
209  //- Construct and return a clone setting internal field reference
211  (
213  ) const
214  {
216  (
218  );
219  }
220 
221 
222  //- Destructor
224 
225 
226  // Member Functions
227 
228  // Evaluation functions
229 
230  //- Calculate and return the yPlus at the boundary
231  virtual tmp<scalarField> yPlus() const;
232 
233 
234  // I-O
235 
236  //- Write
237  virtual void write(Ostream& os) const;
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
Foam::nutUSpaldingWallFunctionFvPatchScalarField::tolerance_
const scalar tolerance_
Convergence tolerance.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.H:164
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::nutUSpaldingWallFunctionFvPatchScalarField::~nutUSpaldingWallFunctionFvPatchScalarField
virtual ~nutUSpaldingWallFunctionFvPatchScalarField()
Destructor.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.C:297
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
nutWallFunctionFvPatchScalarField.H
Foam::nutUSpaldingWallFunctionFvPatchScalarField::maxIter_
const label maxIter_
Max iterations in calcNut.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.H:161
Foam::nutUSpaldingWallFunctionFvPatchScalarField::yPlus
virtual tmp< scalarField > yPlus() const
Calculate and return the yPlus at the boundary.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.C:318
Foam::nutUSpaldingWallFunctionFvPatchScalarField::writeLocalEntries
virtual void writeLocalEntries(Ostream &) const
Write local wall function variables.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.C:194
Foam::nutUSpaldingWallFunctionFvPatchScalarField::calcNut
virtual tmp< scalarField > calcNut() const
Uncomment in case of intrumentation.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.C:39
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::Field< scalar >
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Foam::nutUSpaldingWallFunctionFvPatchScalarField::write
virtual void write(Ostream &os) const
Write.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.C:340
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::nutUSpaldingWallFunctionFvPatchScalarField
This boundary condition provides a wall constraint on the turbulent kinematic viscosity,...
Definition: nutUSpaldingWallFunctionFvPatchScalarField.H:152
Foam::nutUSpaldingWallFunctionFvPatchScalarField::TypeName
TypeName("nutUSpaldingWallFunction")
Runtime type information.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::nutUSpaldingWallFunctionFvPatchScalarField::clone
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.H:235
Foam::nutUSpaldingWallFunctionFvPatchScalarField::calcUTau
virtual tmp< scalarField > calcUTau(const scalarField &magGradU) const
Calculate the friction velocity.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.C:94
Foam::nutUSpaldingWallFunctionFvPatchScalarField::nutUSpaldingWallFunctionFvPatchScalarField
nutUSpaldingWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.C:209
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::nutWallFunctionFvPatchScalarField
The class nutWallFunction is a base class that parents the derived boundary conditions which provide ...
Definition: nutWallFunctionFvPatchScalarField.H:110
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54