initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / turbulenceModels / compressible / RAS / derivedFvPatchFields / wallFunctions / mutWallFunctions / mutSpalartAllmarasWallFunction / mutSpalartAllmarasWallFunctionFvPatchScalarField.C
blobdfe1e88cab4121b3296df3b8311e397c2136aef4
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 "mutSpalartAllmarasWallFunctionFvPatchScalarField.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "RASModel.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
37 namespace compressible
39 namespace RASModels
42 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
44 tmp<scalarField> mutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
46     const scalarField& magGradU
47 ) const
49     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
50     const scalarField& y = rasModel.y()[patch().index()];
52     const fvPatchVectorField& Uw =
53         rasModel.U().boundaryField()[patch().index()];
55     scalarField magUp = mag(Uw.patchInternalField() - Uw);
57     const fvPatchScalarField& rhow =
58         rasModel.rho().boundaryField()[patch().index()];
60     const fvPatchScalarField& muw =
61         rasModel.mu().boundaryField()[patch().index()];
62     const scalarField& mutw = *this;
64     tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
65     scalarField& uTau = tuTau();
67     forAll(mutw, faceI)
68     {
69         scalar magUpara = magUp[faceI];
71         scalar ut =
72             sqrt((mutw[faceI] + muw[faceI])*magGradU[faceI]/rhow[faceI]);
74         if (ut > VSMALL)
75         {
76             int iter = 0;
77             scalar err = GREAT;
79             do
80             {
81                 scalar kUu = min(kappa_*magUpara/ut, 50);
82                 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
84                 scalar f =
85                     - ut*y[faceI]/(muw[faceI]/rhow[faceI])
86                     + magUpara/ut
87                     + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
89                 scalar df =
90                     y[faceI]/(muw[faceI]/rhow[faceI])
91                   + magUpara/sqr(ut)
92                   + 1/E_*kUu*fkUu/ut;
94                 scalar uTauNew = ut + f/df;
95                 err = mag((ut - uTauNew)/ut);
96                 ut = uTauNew;
98             } while (ut > VSMALL && err > 0.01 && ++iter < 10);
100             uTau[faceI] = max(0.0, ut);
101         }
102     }
104     return tuTau;
108 tmp<scalarField>
109 mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const
111     const label patchI = patch().index();
113     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
114     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
115     const scalarField magGradU = mag(Uw.snGrad());
116     const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
117     const scalarField& muw = rasModel.mu().boundaryField()[patchI];
119     return max(scalar(0), rhow*sqr(calcUTau(magGradU))/magGradU - muw);
123 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
125 mutSpalartAllmarasWallFunctionFvPatchScalarField::
126 mutSpalartAllmarasWallFunctionFvPatchScalarField
128     const fvPatch& p,
129     const DimensionedField<scalar, volMesh>& iF
132     mutWallFunctionFvPatchScalarField(p, iF)
136 mutSpalartAllmarasWallFunctionFvPatchScalarField::
137 mutSpalartAllmarasWallFunctionFvPatchScalarField
139     const mutSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
140     const fvPatch& p,
141     const DimensionedField<scalar, volMesh>& iF,
142     const fvPatchFieldMapper& mapper
145     mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
149 mutSpalartAllmarasWallFunctionFvPatchScalarField::
150 mutSpalartAllmarasWallFunctionFvPatchScalarField
152     const fvPatch& p,
153     const DimensionedField<scalar, volMesh>& iF,
154     const dictionary& dict
157     mutWallFunctionFvPatchScalarField(p, iF, dict)
161 mutSpalartAllmarasWallFunctionFvPatchScalarField::
162 mutSpalartAllmarasWallFunctionFvPatchScalarField
164     const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf
167     mutWallFunctionFvPatchScalarField(wfpsf)
171 mutSpalartAllmarasWallFunctionFvPatchScalarField::
172 mutSpalartAllmarasWallFunctionFvPatchScalarField
174     const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf,
175     const DimensionedField<scalar, volMesh>& iF
178     mutWallFunctionFvPatchScalarField(wfpsf, iF)
182 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
184 tmp<scalarField>
185 mutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
187     const label patchI = patch().index();
189     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
190     const scalarField& y = rasModel.y()[patchI];
191     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
192     const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
193     const scalarField& muw = rasModel.mu().boundaryField()[patchI];
195     return y*calcUTau(mag(Uw.snGrad()))/(muw/rhow);
199 void mutSpalartAllmarasWallFunctionFvPatchScalarField::write
201     Ostream& os
202 ) const
204     fvPatchField<scalar>::write(os);
205     writeLocalEntries(os);
206     writeEntry("value", os);
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 makePatchTypeField(fvPatchScalarField, mutSpalartAllmarasWallFunctionFvPatchScalarField);
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 } // End namespace RASModels
217 } // End namespace compressible
218 } // End namespace Foam
220 // ************************************************************************* //