nutURoughWallFunctionFvPatchScalarField.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 -------------------------------------------------------------------------------
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::nutURoughWallFunctionFvPatchScalarField
29 
30 Group
31  grpWallFunctions
32 
33 Description
34  This boundary condition provides a wall function on the turbulent
35  viscosity (i.e. \c nut) based on velocity (i.e. \c U) for low- and
36  high-Reynolds number applications for rough walls.
37 
38 Usage
39  Example of the boundary condition specification:
40  \verbatim
41  <patchName>
42  {
43  // Mandatory entries
44  type nutURoughWallFunction;
45  roughnessHeight 1e-5;
46  roughnessConstant 0.5;
47  roughnessFactor 1;
48 
49  // Optional entries
50  maxIter 10;
51  tolerance 0.0001;
52 
53  // Inherited entries
54  ...
55  }
56  \endverbatim
57 
58  where the entries mean:
59  \table
60  Property | Description | Type | Reqd | Deflt
61  type | Type name: nutURoughWallFunction | word | yes | -
62  roughnessHeight | Roughness height | scalar | yes | -
63  roughnessConstant | Roughness constant | scalar | yes | -
64  roughnessFactor | Scaling factor | scalar | yes | -
65  maxIter | Number of Newton-Raphson iterations | label | no | 10
66  tolerance | Convergence tolerance | scalar | no | 0.0001
67  \endtable
68 
69  The inherited entries are elaborated in:
70  - \link nutWallFunctionFvPatchScalarField.H \endlink
71 
72 Note
73  - Suffers from non-exact restart since \c correctNut() (called through
74  \c turbulence->validate) returns a slightly different value every time
75  it is called.
76  See \link nutUSpaldingWallFunctionFvPatchScalarField.C \endlink.
77 
78 SourceFiles
79  nutURoughWallFunctionFvPatchScalarField.C
80 
81 \*---------------------------------------------------------------------------*/
82 
83 #ifndef nutURoughWallFunctionFvPatchScalarField_H
84 #define nutURoughWallFunctionFvPatchScalarField_H
85 
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 
93 /*---------------------------------------------------------------------------*\
94  Class nutURoughWallFunctionFvPatchScalarField Declaration
95 \*---------------------------------------------------------------------------*/
96 
97 class nutURoughWallFunctionFvPatchScalarField
98 :
99  public nutWallFunctionFvPatchScalarField
100 {
101  // Private Data
102 
103  // Roughness model parameters
104 
105  //- Height
106  scalar roughnessHeight_;
107 
108  //- Constant
109  scalar roughnessConstant_;
110 
111  //- Scale factor
112  scalar roughnessFactor_;
113 
114 
115  //- Max iterations in calcNut
116  const label maxIter_;
117 
118  //- Convergence tolerance
119  const scalar tolerance_;
120 
121 
122  // Protected Member Functions
123 
124  //- Calculate the turbulence viscosity
125  virtual tmp<scalarField> calcNut() const;
126 
127  //- Calculate yPlus
128  tmp<scalarField> calcYPlus(const scalarField& magUp) const;
129 
130  //- Write local wall function variables
131  void writeLocalEntries(Ostream&) const;
132 
133 
134 public:
135 
136  //- Runtime type information
137  TypeName("nutURoughWallFunction");
138 
139 
140  // Constructors
141 
142  //- Construct from patch and internal field
144  (
145  const fvPatch&,
147  );
148 
149  //- Construct from patch, internal field and dictionary
151  (
152  const fvPatch&,
154  const dictionary&
155  );
156 
157  //- Construct by mapping given
158  //- nutURoughWallFunctionFvPatchScalarField
159  //- onto a new patch
161  (
163  const fvPatch&,
165  const fvPatchFieldMapper&
166  );
167 
168  //- Construct as copy
170  (
172  );
173 
174  //- Construct and return a clone
175  virtual tmp<fvPatchScalarField> clone() const
176  {
178  (
180  );
181  }
182 
183  //- Construct as copy setting internal field reference
185  (
188  );
189 
190  //- Construct and return a clone setting internal field reference
192  (
194  ) const
195  {
197  (
199  );
200  }
201 
202 
203  // Member Functions
204 
205  // Access
206 
207  //- Return the roughness height
208  scalar roughnessHeight() const noexcept
209  {
210  return roughnessHeight_;
211  }
212 
213  //- Return reference to the roughness height to allow adjustment
214  scalar& roughnessHeight() noexcept
215  {
216  return roughnessHeight_;
217  }
218 
219  //- Return the roughness constant scale
220  scalar roughnessConstant() const noexcept
221  {
222  return roughnessConstant_;
223  }
224 
225  //- Return reference to the roughness constant to allow adjustment
226  scalar& roughnessConstant() noexcept
227  {
228  return roughnessConstant_;
229  }
230 
231  //- Return the roughness scale factor
232  scalar roughnessFactor() const noexcept
233  {
234  return roughnessFactor_;
235  }
236 
237  //- Return reference to the roughness scale factor to allow
238  //- adjustment
239  scalar& roughnessFactor() noexcept
240  {
241  return roughnessFactor_;
242  }
243 
244 
245  // Evaluation
246 
247  //- Calculate and return the yPlus at the boundary
248  virtual tmp<scalarField> yPlus() const;
249 
250 
251  // I-O
252 
253  //- Write
254  virtual void write(Ostream& os) const;
255 };
256 
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 } // End namespace Foam
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
scalar roughnessFactor() const noexcept
Return the roughness scale factor.
This boundary condition provides a wall function on the turbulent viscosity (i.e. nut) based on veloc...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
TypeName("nutURoughWallFunction")
Runtime type information.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
scalar roughnessHeight() const noexcept
Return the roughness height.
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
scalar magUp
scalar roughnessConstant() const noexcept
Return the roughness constant scale.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A FieldMapper for finite-volume patch fields.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
nutURoughWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
virtual tmp< scalarField > yPlus() const
Calculate and return the yPlus at the boundary.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.