ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / RAS / derivedFvPatchFields / atmBoundaryLayerInletVelocity / atmBoundaryLayerInletVelocityFvPatchVectorField.C
blob734059135771ae240a5f43082ff96f835de9cd97
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
37 namespace incompressible
40 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
42 atmBoundaryLayerInletVelocityFvPatchVectorField::
43 atmBoundaryLayerInletVelocityFvPatchVectorField
45     const fvPatch& p,
46     const DimensionedField<vector, volMesh>& iF
49     fixedValueFvPatchVectorField(p, iF),
50     Ustar_(0),
51     n_(pTraits<vector>::zero),
52     z_(pTraits<vector>::zero),
53     z0_(0),
54     kappa_(0.41),
55     Uref_(0),
56     Href_(0),
57     zGround_(0)
61 atmBoundaryLayerInletVelocityFvPatchVectorField::
62 atmBoundaryLayerInletVelocityFvPatchVectorField
64     const atmBoundaryLayerInletVelocityFvPatchVectorField& ptf,
65     const fvPatch& p,
66     const DimensionedField<vector, volMesh>& iF,
67     const fvPatchFieldMapper& mapper
70     fixedValueFvPatchVectorField(ptf, p, iF, mapper),
71     Ustar_(ptf.Ustar_),
72     n_(ptf.n_),
73     z_(ptf.z_),
74     z0_(ptf.z0_),
75     kappa_(ptf.kappa_),
76     Uref_(ptf.Uref_),
77     Href_(ptf.Href_),
78     zGround_(ptf.zGround_)
82 atmBoundaryLayerInletVelocityFvPatchVectorField::
83 atmBoundaryLayerInletVelocityFvPatchVectorField
85     const fvPatch& p,
86     const DimensionedField<vector, volMesh>& iF,
87     const dictionary& dict
90     fixedValueFvPatchVectorField(p, iF),
91     Ustar_(0),
92     n_(dict.lookup("n")),
93     z_(dict.lookup("z")),
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)
101     {
102         FatalErrorIn
103         (
104             "atmBoundaryLayerInletVelocityFvPatchVectorField"
105             "("
106                 "const fvPatch&, "
107                 "const DimensionedField<vector, volMesh>&, "
108                 "onst dictionary&"
109             ")"
110         )
111             << "magnitude of n, z and z0 vectors must be greater than zero"
112             << abort(FatalError);
113     }
115     n_ /= mag(n_);
116     z_ /= mag(z_);
118     Ustar_ = kappa_*Uref_/(log((Href_  + z0_)/max(z0_ , 0.001)));
120     evaluate();
124 atmBoundaryLayerInletVelocityFvPatchVectorField::
125 atmBoundaryLayerInletVelocityFvPatchVectorField
127     const atmBoundaryLayerInletVelocityFvPatchVectorField& blpvf,
128     const DimensionedField<vector, volMesh>& iF
131     fixedValueFvPatchVectorField(blpvf, iF),
132     Ustar_(blpvf.Ustar_),
133     n_(blpvf.n_),
134     z_(blpvf.z_),
135     z0_(blpvf.z0_),
136     kappa_(blpvf.kappa_),
137     Uref_(blpvf.Uref_),
138     Href_(blpvf.Href_),
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());
153     forAll(coord, i)
154     {
155         if ((coord[i] - zGround_[i]) < Href_)
156         {
157             Un[i] =
158                 (Ustar_/kappa_)
159               * log((coord[i] - zGround_[i] + z0_)/max(z0_, 0.001));
160         }
161         else
162         {
163             Un[i] = (Uref_);
164         }
165     }
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;
178     os.writeKeyword("n")
179         << n_ << token::END_STATEMENT << nl;
180     os.writeKeyword("z")
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 makePatchTypeField
197     fvPatchVectorField,
198     atmBoundaryLayerInletVelocityFvPatchVectorField
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 } // End namespace incompressible
204 } // End namespace Foam
206 // ************************************************************************* //