atmBoundaryLayer.C
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-2016 OpenFOAM Foundation
9  Copyright (C) 2018 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 \*---------------------------------------------------------------------------*/
28 
29 #include "atmBoundaryLayer.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 :
40  time_(time),
41  patch_(pp),
42  flowDir_(time, "flowDir"),
43  zDir_(time, "zDir"),
44  kappa_(0.41),
45  Cmu_(0.09),
46  Uref_(time, "Uref"),
47  Zref_(time, "Zref"),
48  z0_(),
49  zGround_()
50 {}
51 
52 
54 (
55  const Time& time,
56  const polyPatch& pp,
57  const dictionary& dict
58 )
59 :
60  time_(time),
61  patch_(pp),
62  flowDir_(TimeFunction1<vector>(time, "flowDir", dict)),
63  zDir_(TimeFunction1<vector>(time, "zDir", dict)),
64  kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
65  Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
66  Uref_(TimeFunction1<scalar>(time, "Uref", dict)),
67  Zref_(TimeFunction1<scalar>(time, "Zref", dict)),
68  z0_(PatchFunction1<scalar>::New(pp, "z0", dict)),
69  zGround_(PatchFunction1<scalar>::New(pp, "zGround", dict))
70 {}
71 
72 
74 (
75  const atmBoundaryLayer& abl,
76  const fvPatch& patch,
77  const fvPatchFieldMapper& mapper
78 )
79 :
80  time_(abl.time_),
81  patch_(patch.patch()),
82  flowDir_(abl.flowDir_),
83  zDir_(abl.zDir_),
84  kappa_(abl.kappa_),
85  Cmu_(abl.Cmu_),
86  Uref_(abl.Uref_),
87  Zref_(abl.Zref_),
88  z0_(abl.z0_.clone(patch_)),
89  zGround_(abl.zGround_.clone(patch_))
90 {}
91 
92 
94 :
95  time_(abl.time_),
96  patch_(abl.patch_),
97  flowDir_(abl.flowDir_),
98  zDir_(abl.zDir_),
99  kappa_(abl.kappa_),
100  Cmu_(abl.Cmu_),
101  Uref_(abl.Uref_),
102  Zref_(abl.Zref_),
103  z0_(abl.z0_.clone(patch_)),
104  zGround_(abl.zGround_.clone(patch_))
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 {
112  const scalar t = time_.timeOutputValue();
113  vector dir(flowDir_.value(t));
114  const scalar magDir = mag(dir);
115 
116  if (magDir < SMALL)
117  {
119  << "magnitude of " << flowDir_.name()
120  << " vector must be greater than zero"
121  << abort(FatalError);
122  }
123 
124  return dir/magDir;
125 }
126 
127 
129 {
130  const scalar t = time_.timeOutputValue();
131  vector dir(zDir_.value(t));
132  const scalar magDir = mag(dir);
133 
134  if (magDir < SMALL)
135  {
137  << "magnitude of " << zDir_.name()
138  << " vector must be greater than zero"
139  << abort(FatalError);
140  }
141 
142  return dir/magDir;
143 }
144 
145 
147 {
148  const scalar t = time_.timeOutputValue();
149  const scalar Uref = Uref_.value(t);
150  const scalar Zref = Zref_.value(t);
151 
152  return kappa_*Uref/(log((Zref + z0)/z0));
153 }
154 
155 
157 {
158  z0_->autoMap(mapper);
159  zGround_->autoMap(mapper);
160 }
161 
162 
164 (
165  const atmBoundaryLayer& abl,
166  const labelList& addr
167 )
168 {
169  z0_->rmap(abl.z0_(), addr);
170  zGround_->rmap(abl.zGround_(), addr);
171 }
172 
173 
175 {
176  const scalar t = time_.timeOutputValue();
177  const scalarField zGround(zGround_->value(t));
178  const scalarField z0(max(z0_->value(t), ROOTVSMALL));
179 
180  scalarField Un((Ustar(z0)/kappa_)*log(((zDir() & p) - zGround + z0)/z0));
181 
182  return flowDir()*Un;
183 }
184 
185 
187 {
188  const scalar t = time_.timeOutputValue();
189  const scalarField z0(max(z0_->value(t), ROOTVSMALL));
190 
191  return sqr(Ustar(z0))/sqrt(Cmu_);
192 }
193 
194 
196 {
197  const scalar t = time_.timeOutputValue();
198  const scalarField zGround(zGround_->value(t));
199  const scalarField z0(max(z0_->value(t), ROOTVSMALL));
200 
201  return pow3(Ustar(z0))/(kappa_*((zDir() & p) - zGround + z0));
202 }
203 
204 
206 {
207  z0_->writeData(os) ;
208  flowDir_.writeData(os);
209  zDir_.writeData(os);
210  os.writeEntry("kappa", kappa_);
211  os.writeEntry("Cmu", Cmu_);
212  Uref_.writeData(os);
213  Zref_.writeData(os);
214  zGround_->writeData(os);
215 }
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace Foam
221 
222 // ************************************************************************* //
Foam::TimeState::timeOutputValue
scalar timeOutputValue() const
Return current time value.
Definition: TimeStateI.H:30
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
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::dictionary::lookupOrDefault
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.H:1241
Foam::TimeFunction1::value
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: TimeFunction1.C:107
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::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:89
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
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:262
Foam::PatchFunction1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: PatchFunction1.H:63
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::atmBoundaryLayer::atmBoundaryLayer
atmBoundaryLayer(const Time &time, const polyPatch &pp)
Construct null from time.
Definition: atmBoundaryLayer.C:38
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
atmBoundaryLayer.H
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
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::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::atmBoundaryLayer::epsilon
tmp< scalarField > epsilon(const vectorField &p) const
Return the turbulent dissipation rate distribution for the ATM.
Definition: atmBoundaryLayer.C:195
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
Foam::TimeFunction1::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: TimeFunction1.C:138
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