1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace compressible
42 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
45 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
47 const scalarField& magUp
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();
62 scalar kappaRe = kappa_*magUp[faceI]*y[faceI]/(muw[faceI]/rhow[faceI]);
64 scalar yp = yPlusLam_;
65 scalar ryPlusLam = 1.0/yp;
68 scalar yPlusLast = 0.0;
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);
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();
102 if (yPlus[faceI] > yPlusLam_)
105 muw[faceI]*(yPlus[faceI]*kappa_/log(E_*yPlus[faceI]) - 1.0);
113 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
115 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
116 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
119 const DimensionedField<scalar, volMesh>& iF
122 mutWallFunctionFvPatchScalarField(p, iF)
126 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
127 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
129 const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf,
131 const DimensionedField<scalar, volMesh>& iF,
132 const fvPatchFieldMapper& mapper
135 mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
139 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
140 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
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 * * * * * * * * * * * * * //
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
191 fvPatchField<scalar>::write(os);
192 writeLocalEntries(os);
193 writeEntry("value", os);
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 } // End namespace RASModels
208 } // End namespace compressible
209 } // End namespace Foam
211 // ************************************************************************* //