1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 tmp<volScalarField> tnu = rasModel.nu();
51 const volScalarField& nu = tnu();
52 const scalarField& nuw = 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);
73 tmp<scalarField> nutUWallFunctionFvPatchScalarField::calcYPlus
75 const scalarField& magUp
78 const label patchI = patch().index();
80 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
81 const scalarField& y = rasModel.y()[patchI];
82 const tmp<volScalarField> tnu = rasModel.nu();
83 const volScalarField& nu = tnu();
84 const scalarField& nuw = nu.boundaryField()[patchI];
86 tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
87 scalarField& yPlus = tyPlus();
91 scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei];
93 scalar yp = yPlusLam_;
94 scalar ryPlusLam = 1.0/yp;
97 scalar yPlusLast = 0.0;
102 yp = (kappaRe + yp)/(1.0 + log(E_*yp));
104 } while (mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 );
106 yPlus[facei] = max(0.0, yp);
113 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
115 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
118 const DimensionedField<scalar, volMesh>& iF
121 nutkWallFunctionFvPatchScalarField(p, iF)
125 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
127 const nutUWallFunctionFvPatchScalarField& ptf,
129 const DimensionedField<scalar, volMesh>& iF,
130 const fvPatchFieldMapper& mapper
133 nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
137 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
140 const DimensionedField<scalar, volMesh>& iF,
141 const dictionary& dict
144 nutkWallFunctionFvPatchScalarField(p, iF, dict)
148 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
150 const nutUWallFunctionFvPatchScalarField& sawfpsf
153 nutkWallFunctionFvPatchScalarField(sawfpsf)
157 nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField
159 const nutUWallFunctionFvPatchScalarField& sawfpsf,
160 const DimensionedField<scalar, volMesh>& iF
163 nutkWallFunctionFvPatchScalarField(sawfpsf, iF)
167 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
169 tmp<scalarField> nutUWallFunctionFvPatchScalarField::yPlus() const
171 const label patchI = patch().index();
172 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
173 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
174 const scalarField magUp(mag(Uw.patchInternalField() - Uw));
176 return calcYPlus(magUp);
180 void nutUWallFunctionFvPatchScalarField::write(Ostream& os) const
182 fvPatchField<scalar>::write(os);
183 writeLocalEntries(os);
184 writeEntry("value", os);
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 nutUWallFunctionFvPatchScalarField
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 } // End namespace RASModels
199 } // End namespace incompressible
200 } // End namespace Foam
202 // ************************************************************************* //