initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / turbulenceModels / compressible / RAS / derivedFvPatchFields / wallFunctions / mutWallFunctions / mutSpalartAllmarasStandardWallFunction / mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
blobc2a49ac7510ef48bd1b38b8e95a693328abc1ba0
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 "mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H"
28 #include "RASModel.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
37 namespace compressible
39 namespace RASModels
42 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
44 tmp<scalarField>
45 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
47     const scalarField& magUp
48 ) const
50     const label patchI = patch().index();
52     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
53     const scalarField& y = rasModel.y()[patchI];
54     const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI];
55     const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
57     tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
58     scalarField& yPlus = tyPlus();
60     forAll(yPlus, faceI)
61     {
62         scalar kappaRe = kappa_*magUp[faceI]*y[faceI]/(muw[faceI]/rhow[faceI]);
64         scalar yp = yPlusLam_;
65         scalar ryPlusLam = 1.0/yp;
67         int iter = 0;
68         scalar yPlusLast = 0.0;
70         do
71         {
72             yPlusLast = yp;
73             yp = (kappaRe + yp)/(1.0 + log(E_*yp));
75         } while (mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10);
77         yPlus[faceI] = max(0.0, yp);
78     }
80     return tyPlus;
84 tmp<scalarField>
85 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const
87     const label patchI = patch().index();
89     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
90     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
91     const scalarField magUp = mag(Uw.patchInternalField() - Uw);
92     const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
94     tmp<scalarField> tyPlus = calcYPlus(magUp);
95     scalarField& yPlus = tyPlus();
97     tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
98     scalarField& mutw = tmutw();
100     forAll(yPlus, faceI)
101     {
102         if (yPlus[faceI] > yPlusLam_)
103         {
104             mutw[faceI] =
105                 muw[faceI]*(yPlus[faceI]*kappa_/log(E_*yPlus[faceI]) - 1.0);
106         }
107     }
109     return tmutw;
113 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
115 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
116 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
118     const fvPatch& p,
119     const DimensionedField<scalar, volMesh>& iF
122     mutWallFunctionFvPatchScalarField(p, iF)
126 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
127 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
129     const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf,
130     const fvPatch& p,
131     const DimensionedField<scalar, volMesh>& iF,
132     const fvPatchFieldMapper& mapper
135     mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
139 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
140 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
142     const fvPatch& p,
143     const DimensionedField<scalar, volMesh>& iF,
144     const dictionary& dict
147     mutWallFunctionFvPatchScalarField(p, iF, dict)
151 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
152 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
154     const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf
157     mutWallFunctionFvPatchScalarField(sawfpsf)
161 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
162 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
164     const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf,
165     const DimensionedField<scalar, volMesh>& iF
168     mutWallFunctionFvPatchScalarField(sawfpsf, iF)
172 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
174 tmp<scalarField>
175 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const
177     const label patchI = patch().index();
178     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
179     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
180     const scalarField magUp = mag(Uw.patchInternalField() - Uw);
182     return calcYPlus(magUp);
186 void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write
188     Ostream& os
189 ) const
191     fvPatchField<scalar>::write(os);
192     writeLocalEntries(os);
193     writeEntry("value", os);
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 makePatchTypeField
201     fvPatchScalarField,
202     mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 } // End namespace RASModels
208 } // End namespace compressible
209 } // End namespace Foam
211 // ************************************************************************* //