ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / RAS / derivedFvPatchFields / atmBoundaryLayerInletEpsilon / atmBoundaryLayerInletEpsilonFvPatchScalarField.C
blob42ebfb697f085e9e6bfffbc33781f78cc2535bc8
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 "atmBoundaryLayerInletEpsilonFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
38 namespace incompressible
41 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
43 atmBoundaryLayerInletEpsilonFvPatchScalarField::
44 atmBoundaryLayerInletEpsilonFvPatchScalarField
46     const fvPatch& p,
47     const DimensionedField<scalar, volMesh>& iF
50     fixedValueFvPatchScalarField(p, iF),
51     Ustar_(0),
52     z_(pTraits<vector>::zero),
53     z0_(0),
54     kappa_(0.41),
55     zGround_(0)
59 atmBoundaryLayerInletEpsilonFvPatchScalarField::
60 atmBoundaryLayerInletEpsilonFvPatchScalarField
62     const atmBoundaryLayerInletEpsilonFvPatchScalarField& ptf,
63     const fvPatch& p,
64     const DimensionedField<scalar, volMesh>& iF,
65     const fvPatchFieldMapper& mapper
68     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
69     Ustar_(ptf.Ustar_),
70     z_(ptf.z_),
71     z0_(ptf.z0_),
72     kappa_(ptf.kappa_),
73     zGround_(ptf.zGround_)
77 atmBoundaryLayerInletEpsilonFvPatchScalarField::
78 atmBoundaryLayerInletEpsilonFvPatchScalarField
80     const fvPatch& p,
81     const DimensionedField<scalar, volMesh>& iF,
82     const dictionary& dict
85     fixedValueFvPatchScalarField(p, iF),
86     Ustar_(readScalar(dict.lookup("Ustar"))),
87     z_(dict.lookup("z")),
88     z0_(readScalar(dict.lookup("z0"))),
89     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
90     zGround_(p.size(), 0.0)
92     if (mag(z_) < SMALL)
93     {
94         FatalErrorIn
95         (
96             "atmBoundaryLayerInletEpsilonFvPatchScalarField"
97             "("
98                 "const fvPatch&, "
99                 "const DimensionedField<scalar, volMesh>&, "
100                 "const dictionary&"
101             ")"
102         )
103             << "magnitude of z vector must be greater than zero"
104             << abort(FatalError);
105     }
107     z_ /= mag(z_);
109     evaluate();
113 atmBoundaryLayerInletEpsilonFvPatchScalarField::
114 atmBoundaryLayerInletEpsilonFvPatchScalarField
116     const atmBoundaryLayerInletEpsilonFvPatchScalarField& blpsf,
117     const DimensionedField<scalar, volMesh>& iF
120     fixedValueFvPatchScalarField(blpsf, iF),
121     Ustar_(blpsf.Ustar_),
122     z_(blpsf.z_),
123     z0_(blpsf.z0_),
124     kappa_(blpsf.kappa_),
125     zGround_(blpsf.zGround_)
129 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
131 void atmBoundaryLayerInletEpsilonFvPatchScalarField::updateCoeffs()
133     const vectorField& c = patch().Cf();
134     const scalarField coord(c & z_);
136     scalarField::operator=(pow3(Ustar_)/(kappa_*(coord - zGround_ + z0_)));
140 void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const
142     fvPatchScalarField::write(os);
143     os.writeKeyword("Ustar")
144         << Ustar_ << token::END_STATEMENT << nl;
145     os.writeKeyword("z")
146         << z_ << token::END_STATEMENT << nl;
147     os.writeKeyword("z0")
148         << z0_ << token::END_STATEMENT << nl;
149     os.writeKeyword("kappa")
150         << kappa_ << token::END_STATEMENT << nl;
151     os.writeKeyword("zGround")
152         << zGround_ << token::END_STATEMENT << nl;
153     writeEntry("value", os);
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 makePatchTypeField
161     fvPatchScalarField,
162     atmBoundaryLayerInletEpsilonFvPatchScalarField
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 } // End namespace incompressible
168 } // End namespace Foam
170 // ************************************************************************* //