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 | Copyright (C) 2014-2015 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 \*---------------------------------------------------------------------------*/
25 
26 #include "atmBoundaryLayer.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 :
37  flowDir_(pTraits<vector>::zero),
38  zDir_(pTraits<vector>::zero),
39  kappa_(0.41),
40  Cmu_(0.09),
41  Uref_(0),
42  Zref_(0),
43  z0_(0),
44  zGround_(0),
45  Ustar_(0)
46 {}
47 
48 
50 :
51  flowDir_(dict.lookup("flowDir")),
52  zDir_(dict.lookup("zDir")),
53  kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
54  Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
55  Uref_(readScalar(dict.lookup("Uref"))),
56  Zref_(readScalar(dict.lookup("Zref"))),
57  z0_("z0", dict, p.size()),
58  zGround_("zGround", dict, p.size()),
59  Ustar_(p.size())
60 {
61  if (mag(flowDir_) < SMALL || mag(zDir_) < SMALL)
62  {
64  << "magnitude of n or z must be greater than zero"
65  << abort(FatalError);
66  }
67 
68  // Ensure direction vectors are normalized
69  flowDir_ /= mag(flowDir_);
70  zDir_ /= mag(zDir_);
71 
72  Ustar_ = kappa_*Uref_/(log((Zref_ + z0_)/z0_));
73 }
74 
75 
77 (
78  const atmBoundaryLayer& ptf,
79  const fvPatchFieldMapper& mapper
80 )
81 :
82  flowDir_(ptf.flowDir_),
83  zDir_(ptf.zDir_),
84  kappa_(ptf.kappa_),
85  Cmu_(ptf.Cmu_),
86  Uref_(ptf.Uref_),
87  Zref_(ptf.Zref_),
88  z0_(ptf.z0_, mapper),
89  zGround_(ptf.zGround_, mapper),
90  Ustar_(ptf.Ustar_, mapper)
91 {}
92 
93 
95 :
96  flowDir_(blpvf.flowDir_),
97  zDir_(blpvf.zDir_),
98  kappa_(blpvf.kappa_),
99  Cmu_(blpvf.Cmu_),
100  Uref_(blpvf.Uref_),
101  Zref_(blpvf.Zref_),
102  z0_(blpvf.z0_),
103  zGround_(blpvf.zGround_),
104  Ustar_(blpvf.Ustar_)
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 {
112  z0_.autoMap(m);
113  zGround_.autoMap(m);
114  Ustar_.autoMap(m);
115 }
116 
117 
119 (
120  const atmBoundaryLayer& blptf,
121  const labelList& addr
122 )
123 {
124  z0_.rmap(blptf.z0_, addr);
125  zGround_.rmap(blptf.zGround_, addr);
126  Ustar_.rmap(blptf.Ustar_, addr);
127 }
128 
129 
131 {
132  scalarField Un
133  (
134  (Ustar_/kappa_)
135  *log(((zDir_ & p) - zGround_ + z0_)/z0_)
136  );
137 
138  return flowDir_*Un;
139 }
140 
141 
143 {
144  return sqr(Ustar_)/sqrt(Cmu_);
145 }
146 
147 
149 {
150  return pow3(Ustar_)/(kappa_*((zDir_ & p) - zGround_ + z0_));
151 }
152 
153 
155 {
156  z0_.writeEntry("z0", os) ;
157  os.writeKeyword("flowDir")
159  os.writeKeyword("zDir")
160  << zDir_ << token::END_STATEMENT << nl;
161  os.writeKeyword("kappa")
162  << kappa_ << token::END_STATEMENT << nl;
163  os.writeKeyword("Cmu")
164  << Cmu_ << token::END_STATEMENT << nl;
165  os.writeKeyword("Uref")
166  << Uref_ << token::END_STATEMENT << nl;
167  os.writeKeyword("Zref")
168  << Zref_ << token::END_STATEMENT << nl;
169  zGround_.writeEntry("zGround", os) ;
170 }
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 } // End namespace Foam
176 
177 // ************************************************************************* //
Foam::atmBoundaryLayer::kappa_
const scalar kappa_
Von Karman constant.
Definition: atmBoundaryLayer.H:217
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
p
p
Definition: pEqn.H:62
Foam::atmBoundaryLayer::zDir_
vector zDir_
Direction of the z-coordinate.
Definition: atmBoundaryLayer.H:214
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::Field::autoMap
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition: Field.C:508
Foam::atmBoundaryLayer::Uref_
const scalar Uref_
Reference velocity.
Definition: atmBoundaryLayer.H:223
Foam::atmBoundaryLayer::U
tmp< vectorField > U(const vectorField &p) const
Return the velocity distribution for the ATM.
Definition: atmBoundaryLayer.C:130
Foam::atmBoundaryLayer::Ustar_
scalarField Ustar_
Friction velocity.
Definition: atmBoundaryLayer.H:235
Foam::atmBoundaryLayer
This class provides functions to evaluate the velocity and turbulence distributions appropriate for a...
Definition: atmBoundaryLayer.H:206
Foam::atmBoundaryLayer::z0_
scalarField z0_
Surface roughness height.
Definition: atmBoundaryLayer.H:229
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::atmBoundaryLayer::flowDir_
vector flowDir_
Flow direction.
Definition: atmBoundaryLayer.H:211
Foam::atmBoundaryLayer::k
tmp< scalarField > k(const vectorField &p) const
Return the turbulent kinetic energy distribution for the ATM.
Definition: atmBoundaryLayer.C:142
Foam::atmBoundaryLayer::write
void write(Ostream &) const
Write.
Definition: atmBoundaryLayer.C:154
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::atmBoundaryLayer::zGround_
scalarField zGround_
Minimum coordinate value in z direction.
Definition: atmBoundaryLayer.H:232
Foam::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:87
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::atmBoundaryLayer::atmBoundaryLayer
atmBoundaryLayer()
Construct null.
Definition: atmBoundaryLayer.C:35
Foam::atmBoundaryLayer::Cmu_
const scalar Cmu_
Turbulent viscosity coefficient.
Definition: atmBoundaryLayer.H:220
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:253
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::Field::writeEntry
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Definition: Field.C:700
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
atmBoundaryLayer.H
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
Foam::Vector< scalar >
Foam::atmBoundaryLayer::autoMap
void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: atmBoundaryLayer.C:110
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:50
Foam::atmBoundaryLayer::epsilon
tmp< scalarField > epsilon(const vectorField &p) const
Return the turbulent dissipation rate distribution for the ATM.
Definition: atmBoundaryLayer.C:148
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::atmBoundaryLayer::rmap
void rmap(const atmBoundaryLayer &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: atmBoundaryLayer.C:119
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress
Foam::zero
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:47
Foam::atmBoundaryLayer::Zref_
const scalar Zref_
Reference height.
Definition: atmBoundaryLayer.H:226