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 "nutUSpaldingWallFunctionFvPatchScalarField.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace incompressible
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43 tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::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 magGradU(mag(Uw.snGrad()));
50 const tmp<volScalarField> tnu = rasModel.nu();
51 const volScalarField& nu = tnu();
52 const scalarField& nuw = nu.boundaryField()[patchI];
57 sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - nuw
62 tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::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 ut = sqrt((nutw[facei] + nuw[facei])*magGradU[facei]);
91 scalar kUu = min(kappa_*magUp[facei]/ut, 50);
92 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
95 - ut*y[facei]/nuw[facei]
97 + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
101 + magUp[facei]/sqr(ut)
104 scalar uTauNew = ut + f/df;
105 err = mag((ut - uTauNew)/ut);
108 } while (ut > ROOTVSMALL && err > 0.01 && ++iter < 10);
110 uTau[facei] = max(0.0, ut);
118 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
120 nutUSpaldingWallFunctionFvPatchScalarField::
121 nutUSpaldingWallFunctionFvPatchScalarField
124 const DimensionedField<scalar, volMesh>& iF
127 nutkWallFunctionFvPatchScalarField(p, iF)
131 nutUSpaldingWallFunctionFvPatchScalarField::
132 nutUSpaldingWallFunctionFvPatchScalarField
134 const nutUSpaldingWallFunctionFvPatchScalarField& ptf,
136 const DimensionedField<scalar, volMesh>& iF,
137 const fvPatchFieldMapper& mapper
140 nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
144 nutUSpaldingWallFunctionFvPatchScalarField::
145 nutUSpaldingWallFunctionFvPatchScalarField
148 const DimensionedField<scalar, volMesh>& iF,
149 const dictionary& dict
152 nutkWallFunctionFvPatchScalarField(p, iF, dict)
156 nutUSpaldingWallFunctionFvPatchScalarField::
157 nutUSpaldingWallFunctionFvPatchScalarField
159 const nutUSpaldingWallFunctionFvPatchScalarField& wfpsf
162 nutkWallFunctionFvPatchScalarField(wfpsf)
166 nutUSpaldingWallFunctionFvPatchScalarField::
167 nutUSpaldingWallFunctionFvPatchScalarField
169 const nutUSpaldingWallFunctionFvPatchScalarField& wfpsf,
170 const DimensionedField<scalar, volMesh>& iF
173 nutkWallFunctionFvPatchScalarField(wfpsf, iF)
177 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
179 tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::yPlus() const
181 const label patchI = patch().index();
183 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
184 const scalarField& y = rasModel.y()[patchI];
185 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
186 const tmp<volScalarField> tnu = rasModel.nu();
187 const volScalarField& nu = tnu();
188 const scalarField& nuw = nu.boundaryField()[patchI];
190 return y*calcUTau(mag(Uw.snGrad()))/nuw;
194 void nutUSpaldingWallFunctionFvPatchScalarField::write(Ostream& os) const
196 fvPatchField<scalar>::write(os);
197 writeLocalEntries(os);
198 writeEntry("value", os);
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 nutUSpaldingWallFunctionFvPatchScalarField
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 } // End namespace RASModels
213 } // End namespace incompressible
214 } // End namespace Foam
216 // ************************************************************************* //