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];
119 return max(scalar(0), rhow*sqr(calcUTau(magGradU))/magGradU - muw);
123 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
125 mutSpalartAllmarasWallFunctionFvPatchScalarField::
126 mutSpalartAllmarasWallFunctionFvPatchScalarField
129 const DimensionedField<scalar, volMesh>& iF
132 mutWallFunctionFvPatchScalarField(p, iF)
136 mutSpalartAllmarasWallFunctionFvPatchScalarField::
137 mutSpalartAllmarasWallFunctionFvPatchScalarField
139 const mutSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
141 const DimensionedField<scalar, volMesh>& iF,
142 const fvPatchFieldMapper& mapper
145 mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
149 mutSpalartAllmarasWallFunctionFvPatchScalarField::
150 mutSpalartAllmarasWallFunctionFvPatchScalarField
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 * * * * * * * * * * * * * //
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
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 // ************************************************************************* //