1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "nutUWallFunctionFvPatchScalarField.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace incompressible
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43 tmp<scalarField> nutUWallFunctionFvPatchScalarField::calcNut() const
45 const label patchI = patch().index();
47 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
48 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
49 const scalarField magUp(mag(Uw.patchInternalField() - Uw));
50 const scalarField& nuw = rasModel.nu()().boundaryField()[patchI];
52 tmp<scalarField> tyPlus = calcYPlus(magUp);
53 scalarField& yPlus = tyPlus();
55 tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
56 scalarField& nutw = tnutw();
60 if (yPlus[facei] > yPlusLam_)
63 nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0);
71 tmp<scalarField> nutUWallFunctionFvPatchScalarField::calcYPlus
73 const scalarField& magUp
76 const label patchI = patch().index();
78 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
79 const scalarField& y = rasModel.y()[patchI];
80 const scalarField& nuw = rasModel.nu()().boundaryField()[patchI];
82 tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
83 scalarField& yPlus = tyPlus();
87 scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei];
89 scalar yp = yPlusLam_;
90 scalar ryPlusLam = 1.0/yp;
93 scalar yPlusLast = 0.0;
98 yp = (kappaRe + yp)/(1.0 + log(E_*yp));
100 } while (mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 );
102 yPlus[facei] = max(0.0, yp);
109 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
111 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
114 const DimensionedField<scalar, volMesh>& iF
117 nutkWallFunctionFvPatchScalarField(p, iF)
121 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
123 const nutUWallFunctionFvPatchScalarField& ptf,
125 const DimensionedField<scalar, volMesh>& iF,
126 const fvPatchFieldMapper& mapper
129 nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
133 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
136 const DimensionedField<scalar, volMesh>& iF,
137 const dictionary& dict
140 nutkWallFunctionFvPatchScalarField(p, iF, dict)
144 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
146 const nutUWallFunctionFvPatchScalarField& sawfpsf
149 nutkWallFunctionFvPatchScalarField(sawfpsf)
153 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
155 const nutUWallFunctionFvPatchScalarField& sawfpsf,
156 const DimensionedField<scalar, volMesh>& iF
159 nutkWallFunctionFvPatchScalarField(sawfpsf, iF)
163 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
165 tmp<scalarField> nutUWallFunctionFvPatchScalarField::yPlus() const
167 const label patchI = patch().index();
168 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
169 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
170 const scalarField magUp(mag(Uw.patchInternalField() - Uw));
172 return calcYPlus(magUp);
176 void nutUWallFunctionFvPatchScalarField::write(Ostream& os) const
178 fvPatchField<scalar>::write(os);
179 writeLocalEntries(os);
180 writeEntry("value", os);
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 nutUWallFunctionFvPatchScalarField
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 } // End namespace RASModels
195 } // End namespace incompressible
196 } // End namespace Foam
198 // ************************************************************************* //