atmNutkWallFunctionFvPatchScalarField.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) 2020 ENERCON GmbH
10  Copyright (C) 2020-2022 OpenCFD Ltd.
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 Class
29  Foam::atmNutkWallFunctionFvPatchScalarField
30 
31 Group
32  grpAtmWallFunctions
33 
34 Description
35  This boundary condition provides a wall constraint on the turbulent
36  viscosity (i.e. \c nut) based on the turbulent kinetic energy (i.e. \c k)
37  for atmospheric boundary layer modelling. It is designed to be used in
38  conjunction with the \c atmBoundaryLayerInletVelocity boundary condition.
39 
40  The governing equation of the boundary condition:
41 
42  \f[
43  u = \frac{u^*}{\kappa} ln \left(\frac{z + z_0}{z_0}\right)
44  \f]
45 
46  where
47  \vartable
48  u^* | Friction velocity
49  \kappa | von Kármán constant
50  z_0 | Surface roughness length [m]
51  z | Ground-normal coordinate
52  \endvartable
53 
54  Required fields:
55  \verbatim
56  nut | Turbulent viscosity [m2/s]
57  k | Turbulent kinetic energy [m2/s2]
58  \endverbatim
59 
60  References:
61  \verbatim
62  Theoretical expressions (tag:HW):
63  Hargreaves, D. M., & Wright, N. G. (2007).
64  On the use of the k–ε model in commercial CFD software to model
65  the neutral atmospheric boundary layer.
66  J. of wind engineering and industrial aerodynamics, 95(5), 355-369.
67  DOI:10.1016/j.jweia.2006.08.002
68  \endverbatim
69 
70  Required fields:
71  \verbatim
72  nut | Turbulent viscosity [m2/s]
73  k | Turbulent kinetic energy [m2/s2]
74  \endverbatim
75 
76 Usage
77  Example of the boundary condition specification:
78  \verbatim
79  <patchName>
80  {
81  // Mandatory entries
82  type atmNutkWallFunction;
83  z0 <PatchFunction1<scalar>>;
84 
85  // Optional entries
86  boundNut <bool>;
87 
88  // Inherited entries
89  ...
90  }
91  \endverbatim
92 
93  where the entries mean:
94  \table
95  Property | Description | Type | Reqd | Deflt
96  type | Type name: atmNutkWallFunction | word | yes | -
97  z0 | Surface roughness length [m] | PatchFunction1<scalar> | yes | -
98  boundNut | Flag to zero-bound nut near wall | bool | no | false
99  \endtable
100 
101  The inherited entries are elaborated in:
102  - \link nutkWallFunctionFvPatchScalarField.H \endlink
103  - \link PatchFunction1.H \endlink
104 
105 Note
106  - \c boundNut entry is set \c false for backward compatibility reasons.
107  - \c nutkAtmRoughWallFunction was renamed to \c atmNutkWallFunction.
108 
109 SourceFiles
110  atmNutkWallFunctionFvPatchScalarField.C
111 
112 \*---------------------------------------------------------------------------*/
113 
114 #ifndef atmNutkWallFunctionFvPatchScalarField_H
115 #define atmNutkWallFunctionFvPatchScalarField_H
116 
118 #include "PatchFunction1.H"
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 namespace Foam
123 {
124 
125 /*---------------------------------------------------------------------------*\
126  Class atmNutkWallFunctionFvPatchScalarField Declaration
127 \*---------------------------------------------------------------------------*/
128 
129 class atmNutkWallFunctionFvPatchScalarField
130 :
131  public nutkWallFunctionFvPatchScalarField
132 {
133  // Private Data
134 
135  //- Flag to zero-bound nut to prevent negative nut
136  //- at the wall arising from negative heat fluxes
137  const bool boundNut_;
138 
139  //- Surface roughness length field [m]
140  autoPtr<PatchFunction1<scalar>> z0_;
141 
142 
143 protected:
144 
145  // Protected Member Functions
146 
147  //- Calculate the turbulent viscosity
148  virtual tmp<scalarField> calcNut() const;
149 
150  //- Write local wall function variables
151  void writeLocalEntries(Ostream&) const;
152 
153 
154 public:
155 
156  //- Runtime type information
157  TypeName("atmNutkWallFunction");
158 
159 
160  // Constructors
161 
162  //- Construct from patch and internal field
164  (
165  const fvPatch&,
167  );
168 
169  //- Construct from patch, internal field and dictionary
171  (
172  const fvPatch&,
174  const dictionary&
175  );
176 
177  //- Construct by mapping given
178  //- atmNutkWallFunctionFvPatchScalarField
179  //- onto a new patch
181  (
183  const fvPatch&,
185  const fvPatchFieldMapper&
186  );
187 
188  //- Construct as copy
190  (
192  );
193 
194  //- Construct and return a clone
195  virtual tmp<fvPatchScalarField> clone() const
196  {
198  (
200  );
201  }
202 
203  //- Construct as copy setting internal field reference
205  (
208  );
209 
210  //- Construct and return a clone setting internal field reference
212  (
214  ) const
215  {
217  (
219  );
220  }
221 
222 
223  // Member Functions
224 
225  // Mapping
226 
227  //- Map (and resize as needed) from self given a mapping object
228  virtual void autoMap(const fvPatchFieldMapper&);
229 
230  //- Reverse map the given fvPatchField onto this fvPatchField
231  virtual void rmap
232  (
233  const fvPatchScalarField&,
234  const labelList&
235  );
236 
237 
238  // I-O
239 
240  //- Write
241  virtual void write(Ostream&) const;
242 };
243 
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 } // End namespace Foam
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 #endif
252 
253 // ************************************************************************* //
This boundary condition provides a wall constraint on the turbulent viscosity (i.e. nut) based on the turbulent kinetic energy (i.e. k) for atmospheric boundary layer modelling. It is designed to be used in conjunction with the atmBoundaryLayerInletVelocity boundary condition.
virtual tmp< scalarField > calcNut() const
Calculate the turbulent viscosity.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
TypeName("atmNutkWallFunction")
Runtime type information.
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
fvPatchField< scalar > fvPatchScalarField
A FieldMapper for finite-volume patch fields.
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
void writeLocalEntries(Ostream &) const
Write local wall function variables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
List< label > labelList
A List of labels.
Definition: List.H:62
A class for managing temporary objects.
Definition: HashPtrTable.H:50
atmNutkWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Namespace for OpenFOAM.