1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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
25 \*---------------------------------------------------------------------------*/
27 #include "atmBoundaryLayerInletVelocityFvPatchVectorField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace incompressible
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 atmBoundaryLayerInletVelocityFvPatchVectorField::
43 atmBoundaryLayerInletVelocityFvPatchVectorField
46 const DimensionedField<vector, volMesh>& iF
49 fixedValueFvPatchVectorField(p, iF),
51 n_(pTraits<vector>::zero),
52 z_(pTraits<vector>::zero),
61 atmBoundaryLayerInletVelocityFvPatchVectorField::
62 atmBoundaryLayerInletVelocityFvPatchVectorField
64 const atmBoundaryLayerInletVelocityFvPatchVectorField& ptf,
66 const DimensionedField<vector, volMesh>& iF,
67 const fvPatchFieldMapper& mapper
70 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
78 zGround_(ptf.zGround_)
82 atmBoundaryLayerInletVelocityFvPatchVectorField::
83 atmBoundaryLayerInletVelocityFvPatchVectorField
86 const DimensionedField<vector, volMesh>& iF,
87 const dictionary& dict
90 fixedValueFvPatchVectorField(p, iF),
94 z0_(readScalar(dict.lookup("z0"))),
95 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
96 Uref_(readScalar(dict.lookup("Uref"))),
97 Href_(readScalar(dict.lookup("Href"))),
98 zGround_("zGround", dict, p.size())
100 if (mag(n_) < SMALL || mag(z_) < SMALL || mag(z0_) < SMALL)
104 "atmBoundaryLayerInletVelocityFvPatchVectorField"
107 "const DimensionedField<vector, volMesh>&, "
111 << "magnitude of n, z and z0 vectors must be greater than zero"
112 << abort(FatalError);
118 Ustar_ = kappa_*Uref_/(log((Href_ + z0_)/max(z0_ , 0.001)));
124 atmBoundaryLayerInletVelocityFvPatchVectorField::
125 atmBoundaryLayerInletVelocityFvPatchVectorField
127 const atmBoundaryLayerInletVelocityFvPatchVectorField& blpvf,
128 const DimensionedField<vector, volMesh>& iF
131 fixedValueFvPatchVectorField(blpvf, iF),
132 Ustar_(blpvf.Ustar_),
136 kappa_(blpvf.kappa_),
139 zGround_(blpvf.zGround_)
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs()
147 const vectorField& c = patch().Cf();
148 const scalarField coord(c & z_);
151 scalarField Un(coord.size());
155 if ((coord[i] - zGround_[i]) < Href_)
159 * log((coord[i] - zGround_[i] + z0_)/max(z0_, 0.001));
167 vectorField::operator=(n_*Un);
169 fixedValueFvPatchVectorField::updateCoeffs();
173 void atmBoundaryLayerInletVelocityFvPatchVectorField::write(Ostream& os) const
175 fvPatchVectorField::write(os);
176 os.writeKeyword("z0")
177 << z0_ << token::END_STATEMENT << nl;
179 << n_ << token::END_STATEMENT << nl;
181 << z_ << token::END_STATEMENT << nl;
182 os.writeKeyword("kappa")
183 << kappa_ << token::END_STATEMENT << nl;
184 os.writeKeyword("Uref")
185 << Uref_ << token::END_STATEMENT << nl;
186 os.writeKeyword("Href")
187 << Href_ << token::END_STATEMENT << nl;
188 zGround_.writeEntry("zGround", os) ;
189 writeEntry("value", os);
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 atmBoundaryLayerInletVelocityFvPatchVectorField
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 } // End namespace incompressible
204 } // End namespace Foam
206 // ************************************************************************* //