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-2020 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  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^+ | Non-dimensional position
46  u^+ | Non-dimensional velocity
47  \kappa | von Kármán constant
48  \endvartable
49 
50 Usage
51  Example of the boundary condition specification:
52  \verbatim
53  <patchName>
54  {
55  // Mandatory entries (unmodifiable)
56  type nutUSpaldingWallFunction;
57 
58  // Optional entries (unmodifiable)
59  maxIter 10;
60  tolerance 0.0001;
61 
62  // Optional (inherited) entries
63  ...
64  }
65  \endverbatim
66 
67  where the entries mean:
68  \table
69  Property | Description | Type | Req'd | Dflt
70  type | Type name: nutUBlendedWallFunction | 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 
78 Note
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 
91 SourceFiles
92  nutUSpaldingWallFunctionFvPatchScalarField.C
93 
94 \*---------------------------------------------------------------------------*/
95 
96 #ifndef nutUSpaldingWallFunctionFvPatchScalarField_H
97 #define nutUSpaldingWallFunctionFvPatchScalarField_H
98 
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 namespace Foam
104 {
105 
106 /*---------------------------------------------------------------------------*\
107  Class nutUSpaldingWallFunctionFvPatchScalarField Declaration
108 \*---------------------------------------------------------------------------*/
109 
110 class nutUSpaldingWallFunctionFvPatchScalarField
111 :
112  public nutWallFunctionFvPatchScalarField
113 {
114 protected:
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  virtual tmp<scalarField> calcUTau(const scalarField& magGradU) const;
138 
139  //- Calculate the friction velocity and number of iterations for
140  //- convergence
141  virtual tmp<scalarField> calcUTau
142  (
143  const scalarField& magGradU,
144  const label maxIter,
146  ) const;
147 
148  //- Write local wall function variables
149  virtual void writeLocalEntries(Ostream&) const;
150 
151 
152 public:
153 
154  //- Runtime type information
155  TypeName("nutUSpaldingWallFunction");
156 
157 
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 functions
228 
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 // ************************************************************************* //
Foam::nutUSpaldingWallFunctionFvPatchScalarField::tolerance_
const scalar tolerance_
Convergence tolerance.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.H:157
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:61
nutWallFunctionFvPatchScalarField.H
Foam::nutUSpaldingWallFunctionFvPatchScalarField::maxIter_
const label maxIter_
Max iterations in calcNut.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.H:154
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::Field< scalar >
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
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:123
Foam::nutUSpaldingWallFunctionFvPatchScalarField
This boundary condition provides a wall constraint on the turbulent viscosity, i.e....
Definition: nutUSpaldingWallFunctionFvPatchScalarField.H:145
Foam::nutUSpaldingWallFunctionFvPatchScalarField::TypeName
TypeName("nutUSpaldingWallFunction")
Runtime type information.
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::nutUSpaldingWallFunctionFvPatchScalarField::clone
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
Definition: nutUSpaldingWallFunctionFvPatchScalarField.H:228
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:251
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54