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 "mutSpalartAllmarasWallFunctionFvPatchScalarField.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace compressible
42 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
44 tmp<scalarField> mutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
46 const scalarField& magGradU
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();
69 scalar magUpara = magUp[faceI];
72 sqrt((mutw[faceI] + muw[faceI])*magGradU[faceI]/rhow[faceI]);
81 scalar kUu = min(kappa_*magUpara/ut, 50);
82 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
85 - ut*y[faceI]/(muw[faceI]/rhow[faceI])
87 + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
90 y[faceI]/(muw[faceI]/rhow[faceI])
94 scalar uTauNew = ut + f/df;
95 err = mag((ut - uTauNew)/ut);
98 } while (ut > VSMALL && err > 0.01 && ++iter < 10);
100 uTau[faceI] = max(0.0, ut);
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];
122 rhow*sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - muw
127 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
129 mutSpalartAllmarasWallFunctionFvPatchScalarField::
130 mutSpalartAllmarasWallFunctionFvPatchScalarField
133 const DimensionedField<scalar, volMesh>& iF
136 mutWallFunctionFvPatchScalarField(p, iF)
140 mutSpalartAllmarasWallFunctionFvPatchScalarField::
141 mutSpalartAllmarasWallFunctionFvPatchScalarField
143 const mutSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
145 const DimensionedField<scalar, volMesh>& iF,
146 const fvPatchFieldMapper& mapper
149 mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
153 mutSpalartAllmarasWallFunctionFvPatchScalarField::
154 mutSpalartAllmarasWallFunctionFvPatchScalarField
157 const DimensionedField<scalar, volMesh>& iF,
158 const dictionary& dict
161 mutWallFunctionFvPatchScalarField(p, iF, dict)
165 mutSpalartAllmarasWallFunctionFvPatchScalarField::
166 mutSpalartAllmarasWallFunctionFvPatchScalarField
168 const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf
171 mutWallFunctionFvPatchScalarField(wfpsf)
175 mutSpalartAllmarasWallFunctionFvPatchScalarField::
176 mutSpalartAllmarasWallFunctionFvPatchScalarField
178 const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf,
179 const DimensionedField<scalar, volMesh>& iF
182 mutWallFunctionFvPatchScalarField(wfpsf, iF)
186 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
189 mutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
191 const label patchI = patch().index();
193 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
194 const scalarField& y = rasModel.y()[patchI];
195 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
196 const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
197 const scalarField& muw = rasModel.mu().boundaryField()[patchI];
199 return y*calcUTau(mag(Uw.snGrad()))/(muw/rhow);
203 void mutSpalartAllmarasWallFunctionFvPatchScalarField::write
208 fvPatchField<scalar>::write(os);
209 writeLocalEntries(os);
210 writeEntry("value", os);
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 makePatchTypeField(fvPatchScalarField, mutSpalartAllmarasWallFunctionFvPatchScalarField);
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 } // End namespace RASModels
221 } // End namespace compressible
222 } // End namespace Foam
224 // ************************************************************************* //