initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / turbulenceModels / incompressible / RAS / derivedFvPatchFields / wallFunctions / nutWallFunctions / nutSpalartAllmarasStandardWallFunction / nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
blobe3c3e556711e8c174e2694f4b81f5ae38cee8d31
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 2 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 "nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H"
28 #include "RASModel.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
37 namespace incompressible
39 namespace RASModels
42 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
44 tmp<scalarField>
45 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcNut() const
47     const label patchI = patch().index();
49     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
50     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
51     const scalarField magUp = mag(Uw.patchInternalField() - Uw);
52     const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
54     tmp<scalarField> tyPlus = calcYPlus(magUp);
55     scalarField& yPlus = tyPlus();
57     tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
58     scalarField& nutw = tnutw();
60     forAll(yPlus, facei)
61     {
62         if (yPlus[facei] > yPlusLam_)
63         {
64             nutw[facei] =
65                 nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0);
66         }
67     }
69     return tnutw;
73 tmp<scalarField>
74 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
76     const scalarField& magUp
77 ) const
79     const label patchI = patch().index();
81     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
82     const scalarField& y = rasModel.y()[patchI];
83     const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
85     tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
86     scalarField& yPlus = tyPlus();
88     forAll(yPlus, facei)
89     {
90         scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei];
92         scalar yp = yPlusLam_;
93         scalar ryPlusLam = 1.0/yp;
95         int iter = 0;
96         scalar yPlusLast = 0.0;
98         do
99         {
100             yPlusLast = yp;
101             yp = (kappaRe + yp)/(1.0 + log(E_*yp));
103         } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 );
105         yPlus[facei] = max(0.0, yp);
106     }
108     return tyPlus;
112 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
114 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
115 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
117     const fvPatch& p,
118     const DimensionedField<scalar, volMesh>& iF
121     nutWallFunctionFvPatchScalarField(p, iF)
125 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
126 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
128     const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf,
129     const fvPatch& p,
130     const DimensionedField<scalar, volMesh>& iF,
131     const fvPatchFieldMapper& mapper
134     nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
138 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
139 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
141     const fvPatch& p,
142     const DimensionedField<scalar, volMesh>& iF,
143     const dictionary& dict
146     nutWallFunctionFvPatchScalarField(p, iF, dict)
150 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
151 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
153     const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf
156     nutWallFunctionFvPatchScalarField(sawfpsf)
160 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
161 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
163     const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf,
164     const DimensionedField<scalar, volMesh>& iF
167     nutWallFunctionFvPatchScalarField(sawfpsf, iF)
171 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
173 tmp<scalarField>
174 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const
176     const label patchI = patch().index();
177     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
178     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
179     const scalarField magUp = mag(Uw.patchInternalField() - Uw);
181     return calcYPlus(magUp);
185 void nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write
187     Ostream& os
188 ) const
190     fvPatchField<scalar>::write(os);
191     writeLocalEntries(os);
192     writeEntry("value", os);
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 makePatchTypeField
200     fvPatchScalarField,
201     nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 } // End namespace RASModels
207 } // End namespace incompressible
208 } // End namespace Foam
210 // ************************************************************************* //