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 "nutUTabulatedWallFunctionFvPatchScalarField.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace incompressible
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43 tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::calcNut() const
45 const label patchI = patch().index();
47 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
48 const scalarField& y = rasModel.y()[patchI];
49 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
50 const scalarField magUp(mag(Uw.patchInternalField() - Uw));
51 const scalarField magGradU(mag(Uw.snGrad()));
52 const tmp<volScalarField> tnu = rasModel.nu();
53 const volScalarField& nu = tnu();
54 const scalarField& nuw = nu.boundaryField()[patchI];
60 sqr(magUp/(calcUPlus(magUp*y/nuw) + ROOTVSMALL))
61 /(magGradU + ROOTVSMALL)
67 tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::calcUPlus
69 const scalarField& Rey
72 tmp<scalarField> tuPlus(new scalarField(patch().size(), 0.0));
73 scalarField& uPlus = tuPlus();
77 uPlus[faceI] = uPlusTable_.interpolateLog10(Rey[faceI]);
84 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
86 nutUTabulatedWallFunctionFvPatchScalarField::
87 nutUTabulatedWallFunctionFvPatchScalarField
90 const DimensionedField<scalar, volMesh>& iF
93 nutkWallFunctionFvPatchScalarField(p, iF),
94 uPlusTableName_("undefined-uPlusTableName"),
100 patch().boundaryMesh().mesh().time().constant(),
101 patch().boundaryMesh().mesh(),
111 nutUTabulatedWallFunctionFvPatchScalarField::
112 nutUTabulatedWallFunctionFvPatchScalarField
114 const nutUTabulatedWallFunctionFvPatchScalarField& ptf,
116 const DimensionedField<scalar, volMesh>& iF,
117 const fvPatchFieldMapper& mapper
120 nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
121 uPlusTableName_(ptf.uPlusTableName_),
122 uPlusTable_(ptf.uPlusTable_)
126 nutUTabulatedWallFunctionFvPatchScalarField::
127 nutUTabulatedWallFunctionFvPatchScalarField
130 const DimensionedField<scalar, volMesh>& iF,
131 const dictionary& dict
134 nutkWallFunctionFvPatchScalarField(p, iF, dict),
135 uPlusTableName_(dict.lookup("uPlusTable")),
141 patch().boundaryMesh().mesh().time().constant(),
142 patch().boundaryMesh().mesh(),
143 IOobject::MUST_READ_IF_MODIFIED,
152 nutUTabulatedWallFunctionFvPatchScalarField::
153 nutUTabulatedWallFunctionFvPatchScalarField
155 const nutUTabulatedWallFunctionFvPatchScalarField& wfpsf
158 nutkWallFunctionFvPatchScalarField(wfpsf),
159 uPlusTableName_(wfpsf.uPlusTableName_),
160 uPlusTable_(wfpsf.uPlusTable_)
164 nutUTabulatedWallFunctionFvPatchScalarField::
165 nutUTabulatedWallFunctionFvPatchScalarField
167 const nutUTabulatedWallFunctionFvPatchScalarField& wfpsf,
168 const DimensionedField<scalar, volMesh>& iF
171 nutkWallFunctionFvPatchScalarField(wfpsf, iF),
172 uPlusTableName_(wfpsf.uPlusTableName_),
173 uPlusTable_(wfpsf.uPlusTable_)
177 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
179 tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::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 scalarField magUp(mag(Uw.patchInternalField() - Uw));
187 const tmp<volScalarField> tnu = rasModel.nu();
188 const volScalarField& nu = tnu();
189 const scalarField& nuw = nu.boundaryField()[patchI];
190 const scalarField Rey(magUp*y/nuw);
192 return Rey/(calcUPlus(Rey) + ROOTVSMALL);
196 void nutUTabulatedWallFunctionFvPatchScalarField::write(Ostream& os) const
198 fvPatchField<scalar>::write(os);
199 os.writeKeyword("uPlusTable") << uPlusTableName_
200 << token::END_STATEMENT << nl;
201 writeEntry("value", os);
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 nutUTabulatedWallFunctionFvPatchScalarField
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 } // End namespace RASModels
216 } // End namespace incompressible
217 } // End namespace Foam
219 // ************************************************************************* //