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 "nutSpalartAllmarasWallFunctionFvPatchScalarField.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace incompressible
42 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
45 nutSpalartAllmarasWallFunctionFvPatchScalarField::calcNut() const
47 const label patchI = patch().index();
49 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
50 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
51 const scalarField magGradU = mag(Uw.snGrad());
52 const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
57 sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - nuw
62 tmp<scalarField> nutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
64 const scalarField& magGradU
67 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
68 const scalarField& y = rasModel.y()[patch().index()];
70 const fvPatchVectorField& Uw =
71 rasModel.U().boundaryField()[patch().index()];
72 const scalarField magUp = mag(Uw.patchInternalField() - Uw);
74 const scalarField& nuw = rasModel.nu().boundaryField()[patch().index()];
75 const scalarField& nutw = *this;
77 tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
78 scalarField& uTau = tuTau();
82 scalar magUpara = magUp[facei];
84 scalar ut = sqrt((nutw[facei] + nuw[facei])*magGradU[facei]);
93 scalar kUu = min(kappa_*magUpara/ut, 50);
94 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
97 - ut*y[facei]/nuw[facei]
99 + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
106 scalar uTauNew = ut + f/df;
107 err = mag((ut - uTauNew)/ut);
110 } while (ut > VSMALL && err > 0.01 && ++iter < 10);
111 uTau[facei] = max(0.0, ut);
119 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
121 nutSpalartAllmarasWallFunctionFvPatchScalarField::
122 nutSpalartAllmarasWallFunctionFvPatchScalarField
125 const DimensionedField<scalar, volMesh>& iF
128 nutWallFunctionFvPatchScalarField(p, iF)
132 nutSpalartAllmarasWallFunctionFvPatchScalarField::
133 nutSpalartAllmarasWallFunctionFvPatchScalarField
135 const nutSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
137 const DimensionedField<scalar, volMesh>& iF,
138 const fvPatchFieldMapper& mapper
141 nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
145 nutSpalartAllmarasWallFunctionFvPatchScalarField::
146 nutSpalartAllmarasWallFunctionFvPatchScalarField
149 const DimensionedField<scalar, volMesh>& iF,
150 const dictionary& dict
153 nutWallFunctionFvPatchScalarField(p, iF, dict)
157 nutSpalartAllmarasWallFunctionFvPatchScalarField::
158 nutSpalartAllmarasWallFunctionFvPatchScalarField
160 const nutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf
163 nutWallFunctionFvPatchScalarField(wfpsf)
167 nutSpalartAllmarasWallFunctionFvPatchScalarField::
168 nutSpalartAllmarasWallFunctionFvPatchScalarField
170 const nutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf,
171 const DimensionedField<scalar, volMesh>& iF
174 nutWallFunctionFvPatchScalarField(wfpsf, iF)
178 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
181 nutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
183 const label patchI = patch().index();
185 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
186 const scalarField& y = rasModel.y()[patchI];
187 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
188 const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
190 return y*calcUTau(mag(Uw.snGrad()))/nuw;
194 void nutSpalartAllmarasWallFunctionFvPatchScalarField::write
199 fvPatchField<scalar>::write(os);
200 writeLocalEntries(os);
201 writeEntry("value", os);
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 nutSpalartAllmarasWallFunctionFvPatchScalarField
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 } // End namespace RASModels
216 } // End namespace incompressible
217 } // End namespace Foam
219 // ************************************************************************* //