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 "nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace incompressible
42 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
45 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::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 magUp = mag(Uw.patchInternalField() - Uw);
52 const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
54 tmp<scalarField> tyPlus = calcYPlus(magUp);
55 scalarField& yPlus = tyPlus();
57 tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
58 scalarField& nutw = tnutw();
62 if (yPlus[facei] > yPlusLam_)
65 nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0);
74 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
76 const scalarField& magUp
79 const label patchI = patch().index();
81 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
82 const scalarField& y = rasModel.y()[patchI];
83 const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
85 tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
86 scalarField& yPlus = tyPlus();
90 scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei];
92 scalar yp = yPlusLam_;
93 scalar ryPlusLam = 1.0/yp;
96 scalar yPlusLast = 0.0;
101 yp = (kappaRe + yp)/(1.0 + log(E_*yp));
103 } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 );
105 yPlus[facei] = max(0.0, yp);
112 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
114 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
115 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
118 const DimensionedField<scalar, volMesh>& iF
121 nutWallFunctionFvPatchScalarField(p, iF)
125 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
126 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
128 const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf,
130 const DimensionedField<scalar, volMesh>& iF,
131 const fvPatchFieldMapper& mapper
134 nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
138 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
139 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
142 const DimensionedField<scalar, volMesh>& iF,
143 const dictionary& dict
146 nutWallFunctionFvPatchScalarField(p, iF, dict)
150 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
151 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
153 const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf
156 nutWallFunctionFvPatchScalarField(sawfpsf)
160 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
161 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
163 const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf,
164 const DimensionedField<scalar, volMesh>& iF
167 nutWallFunctionFvPatchScalarField(sawfpsf, iF)
171 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
174 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const
176 const label patchI = patch().index();
177 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
178 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
179 const scalarField magUp = mag(Uw.patchInternalField() - Uw);
181 return calcYPlus(magUp);
185 void nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write
190 fvPatchField<scalar>::write(os);
191 writeLocalEntries(os);
192 writeEntry("value", os);
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 } // End namespace RASModels
207 } // End namespace incompressible
208 } // End namespace Foam
210 // ************************************************************************* //