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 as copy setting internal field reference
175  (
178  );
179 
180  //- Return a clone
181  virtual tmp<fvPatchField<scalar>> clone() const
182  {
183  return fvPatchField<scalar>::Clone(*this);
184  }
185 
186  //- Clone with an internal field reference
188  (
190  ) const
191  {
192  return fvPatchField<scalar>::Clone(*this, iF);
193  }
194 
195 
196  // Member Functions
197 
198  // Mapping
199 
200  //- Map (and resize as needed) from self given a mapping object
201  virtual void autoMap(const fvPatchFieldMapper&);
202 
203  //- Reverse map the given fvPatchField onto this fvPatchField
204  virtual void rmap
205  (
206  const fvPatchScalarField&,
207  const labelList&
208  );
209 
210 
211  // I-O
212 
213  //- Write
214  virtual void write(Ostream&) const;
215 };
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace Foam
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
virtual tmp< scalarField > calcNut() const
Calculate the turbulent viscosity.
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
virtual tmp< fvPatchField< scalar > > clone() const
Return a clone.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
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...
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.