atmosphericBoundaryLayer.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2014-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::atmosphericBoundaryLayer
26 
27 Description
28  This class provides functions to evaluate the velocity and turbulence
29  distributions appropriate for atmospheric boundary layers (ABL).
30 
31  The profile is derived from the friction velocity, flow direction and
32  "vertical" direction:
33 
34  \f[
35  U = \frac{U^*}{\kappa} ln\left(\frac{z - z_g + z_0}{z_0}\right)
36  \f]
37 
38  \f[
39  k = \frac{(U^*)^2}{\sqrt{C_mu}}
40  \f]
41 
42  \f[
43  \epsilon = \frac{(U^*)^3}{\kappa(z - z_g + z_0)}
44  \f]
45 
46  where
47  \vartable
48  U^* | Friction velocity
49  \kappa | von Karman's constant
50  C_mu | Turbulence viscosity coefficient
51  z | Vertical coordinate
52  z_0 | Surface roughness height [m]
53  z_g | Minimum z-coordinate [m]
54  \endvartable
55  and
56  \f[
57  U^* = \kappa\frac{U_{ref}}{ln\left(\frac{Z_{ref} + z_0}{z_0}\right)}
58  \f]
59  where
60  \vartable
61  U_{ref} | Reference velocity at \f$Z_{ref}\f$ [m/s]
62  Z_{ref} | Reference height [m]
63  \endvartable
64 
65  The specification of the atmospheric boundary layer is centralised in the
66  constant/atmosphericBoundaryLayerProperties dictionary which is read once on
67  construction of the atmosphericBoundaryLayer class using the
68  atmosphericBoundaryLayer::New factory method and cached automatically for
69  subsequent lookup so a single instance is used by all atmospheric boundary
70  conditions and internal field initialisation.
71 
72  Used in the
73  Foam::atmosphericBoundaryLayerVelocity,
74  Foam::atmosphericBoundaryLayerTurbulentKineticEnergy,
75  Foam::atmosphericBoundaryLayerTurbulentEpsilon and
76  Foam::atmosphericBoundaryLayerNutWallFunction boundary conditions.
77 
78  Reference:
79  D.M. Hargreaves and N.G. Wright, "On the use of the k-epsilon model
80  in commercial CFD software to model the neutral atmospheric boundary
81  layer", Journal of Wind Engineering and Industrial Aerodynamics
82  95(2007), pp 355-369.
83 
84 Usage
85  \table
86  Property | Description | Required | Default
87  flowDir | Flow direction | yes |
88  zDir | Vertical direction | yes |
89  kappa | von Karman's constant | no | 0.41
90  Cmu | Turbulence viscosity coefficient | no | 0.09
91  Uref | Reference velocity [m/s] | yes |
92  Zref | Reference height [m] | yes |
93  z0 | Surface roughness height [m] | yes |
94  zGround | Minimum z-coordinate [m] | yes |
95  Ulower | Velocity below the BL | no |
96  kLower | Turbulence k below the BL | no |
97  epsilonLower | Turbulence epsilon below the BL | no |
98  \endtable
99 
100  Example of the atmosphericBoundaryLayerProperties specification:
101  \verbatim
102  flowDir (1 0 0);
103  zDir (0 0 1);
104  Uref 10.0;
105  Zref 20.0;
106  z0 uniform 0.1;
107  zGround uniform 0.0;
108  \endverbatim
109 
110  Note:
111  D.M. Hargreaves and N.G. Wright recommend Gamma epsilon in the
112  k-epsilon model should be changed from 1.3 to 1.11 for consistency.
113  The roughness height (Er) is given by Er = 20 z0 following the same
114  reference.
115 
116 SourceFiles
117  atmosphericBoundaryLayer.C
118 
119 \*---------------------------------------------------------------------------*/
120 
121 #ifndef atmosphericBoundaryLayer_H
122 #define atmosphericBoundaryLayer_H
123 
124 #include "IOdictionary.H"
125 #include "primitiveFields.H"
126 #include "Function2.H"
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 namespace Foam
131 {
132 
133 /*---------------------------------------------------------------------------*\
134  Class atmosphericBoundaryLayer Declaration
135 \*---------------------------------------------------------------------------*/
136 
137 class atmosphericBoundaryLayer
138 :
139  public IOdictionary
140 {
141  // Private static data
142 
143  //- Default value of the Von Karman constant
144  static const scalar kappaDefault_;
145 
146  //- Default value of the turbulent viscosity coefficient
147  static const scalar CmuDefault_;
148 
149 
150  // Private Data
151 
152  //- Flow direction (x-coordinate)
153  vector flowDir_;
154 
155  //- Direction of the z-coordinate
156  vector zDir_;
157 
158  //- Direction of the y-coordinate
159  vector yDir_;
160 
161  //- Von Karman constant
162  const scalar kappa_;
163 
164  //- Turbulent viscosity coefficient
165  const scalar Cmu_;
166 
167  //- Reference velocity
168  const scalar Uref_;
169 
170  //- Reference height
171  const scalar Zref_;
172 
173  //- Surface roughness height
174  autoPtr<Function2<scalar>> z0_;
175 
176  //- Minimum coordinate value in z direction
177  autoPtr<Function2<scalar>> zGround_;
178 
179  //- True if the boundary layer is offset within the domain
180  bool offset_;
181 
182  //- Velocity of the flow below the boundary layer
183  const scalar Ulower_;
184 
185  //- Turbulence kinetic energy of the flow below the boundary layer
186  const scalar kLower_;
187 
188  //- Turbulence kinetic energy dissipation rate of the flow below the
189  // boundary layer
190  const scalar epsilonLower_;
191 
192 
193 public:
194 
195  //- Runtime type information
196  TypeName("atmosphericBoundaryLayer");
197 
198 
199  // Static Data
200 
201  //- The name of the dictionary
202  static const word dictName;
203 
204 
205  // Constructors
206 
207  //- Read construct from objectRegistry
208  explicit atmosphericBoundaryLayer(const objectRegistry& obr);
209 
210 
211  // Selectors
212 
213  //- Return a reference to the atmosphericBoundaryLayer
214  // from the database, constructing and storing if it doesn't exist
215  static const atmosphericBoundaryLayer& New(const objectRegistry& db);
216 
217 
218  // Member Functions
219 
220  // Access
221 
222  //- Von Karman constant
223  scalar kappa() const
224  {
225  return kappa_;
226  }
227 
228  //- Turbulent viscosity coefficient
229  scalar Cmu() const
230  {
231  return Cmu_;
232  }
233 
234  //- Return flow direction
235  const vector& flowDir() const
236  {
237  return flowDir_;
238  }
239 
240  //- Return z-direction
241  const vector& zDir() const
242  {
243  return zDir_;
244  }
245 
246  //- Return surface roughness height
247  tmp<scalarField> z0(const vectorField& C) const;
248 
249  //- Return friction velocity
250  tmp<scalarField> Ustar(const scalarField& z0) const;
251 
252 
253  // Evaluate functions
254 
255  //- Return the velocity field
256  tmp<vectorField> U(const vectorField& p) const;
257 
258  //- Return the turbulent kinetic energy field
259  tmp<scalarField> k(const vectorField& p) const;
260 
261  //- Return the turbulent dissipation rate field
262  tmp<scalarField> epsilon(const vectorField& p) const;
263 
264 
265  //- Inherit write from regIOobject
266  using regIOobject::write;
267 
268  //- Write
269  void write(Ostream&) const;
270 };
271 
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 } // End namespace Foam
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #endif
280 
281 // ************************************************************************* //
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:309
TypeName("atmosphericBoundaryLayer")
Runtime type information.
tmp< scalarField > z0(const vectorField &C) const
Return surface roughness height.
scalar kappa() const
Von Karman constant.
atmosphericBoundaryLayer(const objectRegistry &obr)
Read construct from objectRegistry.
static const atmosphericBoundaryLayer & New(const objectRegistry &db)
Return a reference to the atmosphericBoundaryLayer.
const vector & flowDir() const
Return flow direction.
static const word dictName
The name of the dictionary.
const vector & zDir() const
Return z-direction.
tmp< scalarField > Ustar(const scalarField &z0) const
Return friction velocity.
tmp< vectorField > U(const vectorField &p) const
Return the velocity field.
virtual bool write(const bool write=true) const
Inherit write from regIOobject.
scalar Cmu() const
Turbulent viscosity coefficient.
tmp< scalarField > k(const vectorField &p) const
Return the turbulent kinetic energy field.
tmp< scalarField > epsilon(const vectorField &p) const
Return the turbulent dissipation rate field.
virtual bool write(const bool write=true) const
Write using setting from DB.
static const coefficient C("C", dimTemperature, 234.5)
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Field< vector > vectorField
Specialisation of Field<T> for vector.
Specialisations of Field<T> for scalar, vector and tensor.
volScalarField & p