atmNutUWallFunctionFvPatchScalarField.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) 2020 ENERCON GmbH
9  Copyright (C) 2020-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::atmNutUWallFunctionFvPatchScalarField
29 
30 Group
31  grpAtmWallFunctions
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) for atmospheric
36  boundary layer modelling. It is designed to be used in conjunction
37  with the \c atmBoundaryLayerInletVelocity boundary condition.
38 
39  The governing equation of the boundary condition:
40 
41  \f[
42  u = \frac{u^*}{\kappa} ln \left(\frac{z + z_0}{z_0}\right)
43  \f]
44 
45  where
46  \vartable
47  u^* | Friction velocity
48  \kappa | von Kármán constant
49  z_0 | Surface roughness length [m]
50  z | Ground-normal coordinate
51  \endvartable
52 
53  Required fields:
54  \verbatim
55  nut | Turbulent viscosity [m2/s]
56  U | Velocity [m/s]
57  \endverbatim
58 
59 Usage
60  Example of the boundary condition specification:
61  \verbatim
62  <patchName>
63  {
64  // Mandatory entries
65  type atmNutUWallFunction;
66  z0 <PatchFunction1<scalar>>;
67 
68  // Optional entries
69  boundNut true;
70 
71  // Inherited entries
72  ...
73  }
74  \endverbatim
75 
76  where the entries mean:
77  \table
78  Property | Description | Type | Reqd | Deflt
79  type | Type name: atmNutUWallFunction | word | yes | -
80  z0 | Surface roughness length [m] | PatchFunction1<scalar> | yes | -
81  boundNut | Flag: zero-bound nut near wall | bool | no | true
82  \endtable
83 
84  The inherited entries are elaborated in:
85  - \link nutUWallFunctionFvPatchScalarField.H \endlink
86  - \link PatchFunction1.H \endlink
87 
88 SourceFiles
89  atmNutUWallFunctionFvPatchScalarField.C
90 
91 \*---------------------------------------------------------------------------*/
92 
93 #ifndef atmNutUWallFunctionFvPatchScalarField_H
94 #define atmNutUWallFunctionFvPatchScalarField_H
95 
97 #include "PatchFunction1.H"
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 namespace Foam
102 {
103 
104 /*---------------------------------------------------------------------------*\
105  Class atmNutUWallFunctionFvPatchScalarField Declaration
106 \*---------------------------------------------------------------------------*/
107 
108 class atmNutUWallFunctionFvPatchScalarField
109 :
110  public nutUWallFunctionFvPatchScalarField
111 {
112  // Private Data
113 
114  //- Flag to zero-bound nut to prevent negative nut
115  //- at the wall arising from negative heat fluxes
116  const bool boundNut_;
117 
118  //- Surface roughness length field [m]
119  autoPtr<PatchFunction1<scalar>> z0_;
120 
121 
122 protected:
123 
124  // Protected Member Functions
125 
126  //- Calculate the turbulent viscosity
127  virtual tmp<scalarField> calcNut() const;
128 
129  //- Write local wall function variables
130  void writeLocalEntries(Ostream&) const;
131 
132 
133 public:
134 
135  //- Runtime type information
136  TypeName("atmNutUWallFunction");
137 
138 
139  // Constructors
140 
141  //- Construct from patch and internal field
143  (
144  const fvPatch&,
146  );
147 
148  //- Construct from patch, internal field and dictionary
150  (
151  const fvPatch&,
153  const dictionary&
154  );
155 
156  //- Construct by mapping given
157  //- atmNutUWallFunctionFvPatchScalarField
158  //- onto a new patch
160  (
162  const fvPatch&,
164  const fvPatchFieldMapper&
165  );
166 
167  //- Construct as copy
169  (
171  );
172 
173  //- Construct and return a clone
174  virtual tmp<fvPatchScalarField> clone() const
175  {
177  (
179  );
180  }
181 
182  //- Construct as copy setting internal field reference
184  (
187  );
188 
189  //- Construct and return a clone setting internal field reference
191  (
193  ) const
194  {
196  (
198  );
199  }
200 
201 
202  // Member Functions
203 
204  // Mapping
205 
206  //- Map (and resize as needed) from self given a mapping object
207  virtual void autoMap(const fvPatchFieldMapper&);
208 
209  //- Reverse map the given fvPatchField onto this fvPatchField
210  virtual void rmap
211  (
212  const fvPatchScalarField&,
213  const labelList&
214  );
215 
216 
217  // I-O
218 
219  //- Write
220  virtual void write(Ostream&) const;
221 };
222 
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 } // End namespace Foam
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 #endif
231 
232 // ************************************************************************* //
virtual tmp< scalarField > calcNut() const
Calculate the turbulent viscosity.
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
atmNutUWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
fvPatchField< scalar > fvPatchScalarField
A FieldMapper for finite-volume patch fields.
void writeLocalEntries(Ostream &) const
Write local wall function variables.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
TypeName("atmNutUWallFunction")
Runtime type information.
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
This boundary condition provides a wall constraint on the turbulent viscosity (i.e. nut) based on velocity (i.e. U) for atmospheric boundary layer modelling. It is designed to be used in conjunction with the atmBoundaryLayerInletVelocity boundary condition.
Namespace for OpenFOAM.