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 as copy setting internal field reference
176  (
179  );
180 
181  //- Return a clone
182  virtual tmp<fvPatchField<scalar>> clone() const
183  {
184  return fvPatchField<scalar>::Clone(*this);
185  }
186 
187  //- Clone with an internal field reference
189  (
191  ) const
192  {
193  return fvPatchField<scalar>::Clone(*this, iF);
194  }
195 
196 
197  // Member Functions
198 
199  // Access
200 
201  //- Return the roughness height
202  scalar roughnessHeight() const noexcept
203  {
204  return roughnessHeight_;
205  }
206 
207  //- Return reference to the roughness height to allow adjustment
208  scalar& roughnessHeight() noexcept
209  {
210  return roughnessHeight_;
211  }
212 
213  //- Return the roughness constant scale
214  scalar roughnessConstant() const noexcept
215  {
216  return roughnessConstant_;
217  }
218 
219  //- Return reference to the roughness constant to allow adjustment
220  scalar& roughnessConstant() noexcept
221  {
222  return roughnessConstant_;
223  }
224 
225  //- Return the roughness scale factor
226  scalar roughnessFactor() const noexcept
227  {
228  return roughnessFactor_;
229  }
230 
231  //- Return reference to the roughness scale factor to allow
232  //- adjustment
233  scalar& roughnessFactor() noexcept
234  {
235  return roughnessFactor_;
236  }
237 
238 
239  // Evaluation
240 
241  //- Calculate and return the yPlus at the boundary
242  virtual tmp<scalarField> yPlus() const;
243 
244 
245  // I-O
246 
247  //- Write
248  virtual void write(Ostream& os) const;
249 };
250 
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 } // End namespace Foam
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 #endif
259 
260 // ************************************************************************* //
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.
scalar magUp
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
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.
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...
virtual tmp< scalarField > yPlus() const
Calculate and return the yPlus at the boundary.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual tmp< fvPatchField< scalar > > clone() const
Return a clone.
Namespace for OpenFOAM.