FreeFOAM The Cross-Platform CFD Toolkit
atmBoundaryLayerInletEpsilonFvPatchScalarField.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) 2010-2010 OpenCFD Ltd.
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 the
13  Free Software Foundation; either version 3 of the License, or (at your
14  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, write to the Free Software Foundation,
23  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 \*---------------------------------------------------------------------------*/
26 
30 #include <finiteVolume/volFields.H>
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace incompressible
38 {
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
42 atmBoundaryLayerInletEpsilonFvPatchScalarField::
43 atmBoundaryLayerInletEpsilonFvPatchScalarField
44 (
45  const fvPatch& p,
47 )
48 :
49  fixedValueFvPatchScalarField(p, iF),
50  Ustar_(0),
52  z0_(0),
53  kappa_(0.41),
54  zGround_(0)
55 {}
56 
57 
58 atmBoundaryLayerInletEpsilonFvPatchScalarField::
59 atmBoundaryLayerInletEpsilonFvPatchScalarField
60 (
62  const fvPatch& p,
64  const fvPatchFieldMapper& mapper
65 )
66 :
67  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
68  Ustar_(ptf.Ustar_),
69  z_(ptf.z_),
70  z0_(ptf.z0_),
71  kappa_(ptf.kappa_),
72  zGround_(ptf.zGround_)
73 {}
74 
75 
76 atmBoundaryLayerInletEpsilonFvPatchScalarField::
77 atmBoundaryLayerInletEpsilonFvPatchScalarField
78 (
79  const fvPatch& p,
81  const dictionary& dict
82 )
83 :
84  fixedValueFvPatchScalarField(p, iF),
85  Ustar_(readScalar(dict.lookup("Ustar"))),
86  z_(dict.lookup("z")),
87  z0_(readScalar(dict.lookup("z0"))),
88  kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
89  zGround_(readScalar(dict.lookup("zGround")))
90 {
91  if (mag(z_) < SMALL)
92  {
94  (
95  "atmBoundaryLayerInletEpsilonFvPatchScalarField"
96  "("
97  "const fvPatch&, "
98  "const DimensionedField<scalar, volMesh>&, "
99  "const dictionary&"
100  ")"
101  )
102  << "magnitude of z vector must be greater than zero"
103  << abort(FatalError);
104  }
105 
106  z_ /= mag(z_);
107 
108  evaluate();
109 }
110 
111 
112 atmBoundaryLayerInletEpsilonFvPatchScalarField::
113 atmBoundaryLayerInletEpsilonFvPatchScalarField
114 (
117 )
118 :
119  fixedValueFvPatchScalarField(blpsf, iF),
120  Ustar_(blpsf.Ustar_),
121  z_(blpsf.z_),
122  z0_(blpsf.z0_),
123  kappa_(blpsf.kappa_),
124  zGround_(blpsf.zGround_)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
130 void atmBoundaryLayerInletEpsilonFvPatchScalarField::updateCoeffs()
131 {
132  const vectorField& c = patch().Cf();
133  scalarField coord = (c & z_);
134  scalarField::operator=(pow3(Ustar_)/(kappa_*(coord - zGround_ + z0_)));
135 }
136 
137 
138 void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const
139 {
141  os.writeKeyword("Ustar")
142  << Ustar_ << token::END_STATEMENT << nl;
143  os.writeKeyword("z")
144  << z_ << token::END_STATEMENT << nl;
145  os.writeKeyword("z0")
146  << z0_ << token::END_STATEMENT << nl;
147  os.writeKeyword("kappa")
148  << kappa_ << token::END_STATEMENT << nl;
149  os.writeKeyword("zGround")
150  << zGround_ << token::END_STATEMENT << nl;
151  writeEntry("value", os);
152 }
153 
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
158 (
161 );
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace incompressible
166 } // End namespace Foam
167 
168 // ************************************************************************* //