Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / RAS / derivedFvPatchFields / atmBoundaryLayerInletEpsilon / atmBoundaryLayerInletEpsilonFvPatchScalarField.C
blobda7e69950e98007fac0ad6d305e056f003970798
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.
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"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
37 namespace incompressible
40 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
42 atmBoundaryLayerInletEpsilonFvPatchScalarField::
43 atmBoundaryLayerInletEpsilonFvPatchScalarField
45     const fvPatch& p,
46     const DimensionedField<scalar, volMesh>& iF
49     fixedValueFvPatchScalarField(p, iF),
50     Ustar_(0),
51     z_(pTraits<vector>::zero),
52     z0_(0),
53     kappa_(0.41),
54     zGround_(0)
58 atmBoundaryLayerInletEpsilonFvPatchScalarField::
59 atmBoundaryLayerInletEpsilonFvPatchScalarField
61     const atmBoundaryLayerInletEpsilonFvPatchScalarField& ptf,
62     const fvPatch& p,
63     const DimensionedField<scalar, volMesh>& iF,
64     const fvPatchFieldMapper& mapper
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_)
76 atmBoundaryLayerInletEpsilonFvPatchScalarField::
77 atmBoundaryLayerInletEpsilonFvPatchScalarField
79     const fvPatch& p,
80     const DimensionedField<scalar, volMesh>& iF,
81     const dictionary& dict
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")))
91     if (mag(z_) < SMALL)
92     {
93         FatalErrorIn
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     }
106     z_ /= mag(z_);
108     evaluate();
112 atmBoundaryLayerInletEpsilonFvPatchScalarField::
113 atmBoundaryLayerInletEpsilonFvPatchScalarField
115     const atmBoundaryLayerInletEpsilonFvPatchScalarField& blpsf,
116     const DimensionedField<scalar, volMesh>& iF
119     fixedValueFvPatchScalarField(blpsf, iF),
120     Ustar_(blpsf.Ustar_),
121     z_(blpsf.z_),
122     z0_(blpsf.z0_),
123     kappa_(blpsf.kappa_),
124     zGround_(blpsf.zGround_)
128 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
130 void atmBoundaryLayerInletEpsilonFvPatchScalarField::updateCoeffs()
132     const vectorField& c = patch().Cf();
133     tmp<scalarField> coord = (c & z_);
134     scalarField::operator=(pow3(Ustar_)/(kappa_*(coord - zGround_ + z0_)));
138 void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const
140     fvPatchScalarField::write(os);
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);
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 makePatchTypeField
159     fvPatchScalarField,
160     atmBoundaryLayerInletEpsilonFvPatchScalarField
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 } // End namespace incompressible
166 } // End namespace Foam
168 // ************************************************************************* //