atmBoundaryLayer.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) 2014-2018 OpenFOAM Foundation
9  Copyright (C) 2015 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::atmBoundaryLayer
29 
30 Group
31  grpRASBoundaryConditions grpInletBoundaryConditions
32 
33 Description
34  This class provides functions to evaluate the velocity and turbulence
35  distributions appropriate for atmospheric boundary layers (ABL).
36 
37  The profile is derived from the friction velocity, flow direction and
38  "vertical" direction:
39 
40  \f[
41  U = \frac{U^*}{\kappa} ln\left(\frac{z - z_g + z_0}{z_0}\right)
42  \f]
43 
44  \f[
45  k = \frac{(U^*)^2}{\sqrt{C_{\mu}}}
46  \f]
47 
48  \f[
49  \epsilon = \frac{(U^*)^3}{\kappa(z - z_g + z_0)}
50  \f]
51 
52  where
53  \vartable
54  U^* | Friction velocity
55  \kappa | von Karman's constant
56  C_{\mu} | Turbulence viscosity coefficient
57  z | Vertical coordinate
58  z_0 | Surface roughness height [m]
59  z_g | Minimum z-coordinate [m]
60  \endvartable
61  and
62  \f[
63  U^* = \kappa\frac{U_{ref}}{ln\left(\frac{Z_{ref} + z_0}{z_0}\right)}
64  \f]
65  where
66  \vartable
67  U_{ref} | Reference velocity at \f$Z_{ref}\f$ [m/s]
68  Z_{ref} | Reference height [m]
69  \endvartable
70 
71  Use in the atmBoundaryLayerInletVelocity, atmBoundaryLayerInletK and
72  atmBoundaryLayerInletEpsilon boundary conditions.
73 
74  Reference:
75  D.M. Hargreaves and N.G. Wright, "On the use of the k-epsilon model
76  in commercial CFD software to model the neutral atmospheric boundary
77  layer", Journal of Wind Engineering and Industrial Aerodynamics
78  95(2007), pp 355-369.
79 
80 Usage
81  \table
82  Property | Description | Required | Default
83  flowDir | Flow direction | yes |
84  zDir | Vertical direction | yes |
85  kappa | von Karman's constant | no | 0.41
86  Cmu | Turbulence viscosity coefficient | no | 0.09
87  Uref | Reference velocity [m/s] | yes |
88  Zref | Reference height [m] | yes |
89  z0 | Surface roughness height [m] | yes |
90  zGround | Minimum z-coordinate [m] | yes |
91  \endtable
92 
93  Example of the boundary condition specification:
94  \verbatim
95  ground
96  {
97  type atmBoundaryLayerInletVelocity;
98  flowDir (1 0 0);
99  zDir (0 0 1);
100  Uref 10.0;
101  Zref 20.0;
102  z0 uniform 0.1;
103  zGround uniform 0.0;
104  }
105  \endverbatim
106 
107 Note
108  D.M. Hargreaves and N.G. Wright recommend Gamma epsilon in the
109  k-epsilon model should be changed from 1.3 to 1.11 for consistency.
110  The roughness height (Er) is given by Er = 20 z0 following the same
111  reference.
112 
113 SourceFiles
114  atmBoundaryLayer.C
115 
116 \*---------------------------------------------------------------------------*/
117 
118 #ifndef atmBoundaryLayer_H
119 #define atmBoundaryLayer_H
120 
121 #include "fvPatchFields.H"
122 #include "TimeFunction1.H"
123 #include "PatchFunction1.H"
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 namespace Foam
128 {
129 
130 /*---------------------------------------------------------------------------*\
131  Class atmBoundaryLayer Declaration
132 \*---------------------------------------------------------------------------*/
133 
134 class atmBoundaryLayer
135 {
136  // Private data
137 
138  //- Reference to the time database
139  const Time& time_;
140 
141  //- Reference to the patch
142  const polyPatch& patch_;
143 
144  //- Flow direction
145  TimeFunction1<vector> flowDir_;
146 
147  //- Direction of the z-coordinate
148  TimeFunction1<vector> zDir_;
149 
150  //- Von Karman constant
151  const scalar kappa_;
152 
153  //- Turbulent viscosity coefficient
154  const scalar Cmu_;
155 
156  //- Reference velocity
157  TimeFunction1<scalar> Uref_;
158 
159  //- Reference height
160  TimeFunction1<scalar> Zref_;
161 
162  //- Surface roughness height
163  autoPtr<PatchFunction1<scalar>> z0_;
164 
165  //- Minimum coordinate value in z direction
166  autoPtr<PatchFunction1<scalar>> zGround_;
167 
168 
169 public:
170 
171  // Constructors
172 
173  //- Construct null from time
174  atmBoundaryLayer(const Time& time, const polyPatch& pp);
175 
176  //- Construct from the time database and dictionary
178  (
179  const Time& time,
180  const polyPatch& pp,
181  const dictionary& dict
182  );
183 
184  //- Construct by mapping given atmBoundaryLayer onto a new patch
186  (
187  const atmBoundaryLayer& abl,
188  const fvPatch& patch,
189  const fvPatchFieldMapper& mapper
190  );
191 
192  //- Construct as copy
194 
195 
196  // Member functions
197 
198  // Access
199 
200  //- Return flow direction
201  vector flowDir() const;
202 
203  //- Return z-direction
204  vector zDir() const;
205 
206  //- Return friction velocity
207  tmp<scalarField> Ustar(const scalarField& z0) const;
208 
209 
210  // Mapping functions
211 
212  //- Map (and resize as needed) from self given a mapping object
213  void autoMap(const fvPatchFieldMapper&);
214 
215  //- Reverse map the given fvPatchField onto this fvPatchField
216  void rmap(const atmBoundaryLayer&, const labelList&);
217 
218 
219  // Evaluate functions
220 
221  //- Return the velocity distribution for the ATM
222  tmp<vectorField> U(const vectorField& p) const;
223 
224  //- Return the turbulent kinetic energy distribution for the ATM
225  tmp<scalarField> k(const vectorField& p) const;
226 
227  //- Return the turbulent dissipation rate distribution for the ATM
228  tmp<scalarField> epsilon(const vectorField& p) const;
229 
230 
231  //- Write
232  void write(Ostream&) const;
233 };
234 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 } // End namespace Foam
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #endif
243 
244 // ************************************************************************* //
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::atmBoundaryLayer::Ustar
tmp< scalarField > Ustar(const scalarField &z0) const
Return friction velocity.
Definition: atmBoundaryLayer.C:146
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
PatchFunction1.H
Foam::atmBoundaryLayer::U
tmp< vectorField > U(const vectorField &p) const
Return the velocity distribution for the ATM.
Definition: atmBoundaryLayer.C:174
Foam::atmBoundaryLayer
This class provides functions to evaluate the velocity and turbulence distributions appropriate for a...
Definition: atmBoundaryLayer.H:210
Foam::TimeFunction1
Light wrapper around Function1 to provide a mechanism to update time-based entries.
Definition: ConeNozzleInjection.H:80
Foam::atmBoundaryLayer::flowDir
vector flowDir() const
Return flow direction.
Definition: atmBoundaryLayer.C:110
Foam::atmBoundaryLayer::k
tmp< scalarField > k(const vectorField &p) const
Return the turbulent kinetic energy distribution for the ATM.
Definition: atmBoundaryLayer.C:186
Foam::atmBoundaryLayer::write
void write(Ostream &) const
Write.
Definition: atmBoundaryLayer.C:205
Foam::Field< scalar >
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::atmBoundaryLayer::atmBoundaryLayer
atmBoundaryLayer(const Time &time, const polyPatch &pp)
Construct null from time.
Definition: atmBoundaryLayer.C:38
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
fvPatchFields.H
Foam::Vector< scalar >
Foam::atmBoundaryLayer::autoMap
void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: atmBoundaryLayer.C:156
Foam::List< label >
Foam::atmBoundaryLayer::epsilon
tmp< scalarField > epsilon(const vectorField &p) const
Return the turbulent dissipation rate distribution for the ATM.
Definition: atmBoundaryLayer.C:195
Foam::atmBoundaryLayer::zDir
vector zDir() const
Return z-direction.
Definition: atmBoundaryLayer.C:128
Foam::atmBoundaryLayer::rmap
void rmap(const atmBoundaryLayer &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: atmBoundaryLayer.C:164
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
TimeFunction1.H