BUG: Corrected reference to tmp in incompressible RAS models (mantis #360)
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / RAS / derivedFvPatchFields / wallFunctions / nutWallFunctions / nutUTabulatedWallFunction / nutUTabulatedWallFunctionFvPatchScalarField.C
blob4bb2c1ea1958e993326b18f837709332b99682e1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
27 #include "RASModel.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
36 namespace incompressible
38 namespace RASModels
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];
56     return
57         max
58         (
59             scalar(0),
60             sqr(magUp/(calcUPlus(magUp*y/nuw) + ROOTVSMALL))
61            /(magGradU + ROOTVSMALL)
62           - nuw
63         );
67 tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::calcUPlus
69     const scalarField& Rey
70 ) const
72     tmp<scalarField> tuPlus(new scalarField(patch().size(), 0.0));
73     scalarField& uPlus = tuPlus();
75     forAll(uPlus, faceI)
76     {
77         uPlus[faceI] = uPlusTable_.interpolateLog10(Rey[faceI]);
78     }
80     return tuPlus;
84 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
86 nutUTabulatedWallFunctionFvPatchScalarField::
87 nutUTabulatedWallFunctionFvPatchScalarField
89     const fvPatch& p,
90     const DimensionedField<scalar, volMesh>& iF
93     nutkWallFunctionFvPatchScalarField(p, iF),
94     uPlusTableName_("undefined-uPlusTableName"),
95     uPlusTable_
96     (
97         IOobject
98         (
99             uPlusTableName_,
100             patch().boundaryMesh().mesh().time().constant(),
101             patch().boundaryMesh().mesh(),
102             IOobject::NO_READ,
103             IOobject::NO_WRITE,
104             false
105         ),
106         false
107     )
111 nutUTabulatedWallFunctionFvPatchScalarField::
112 nutUTabulatedWallFunctionFvPatchScalarField
114     const nutUTabulatedWallFunctionFvPatchScalarField& ptf,
115     const fvPatch& p,
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
129     const fvPatch& p,
130     const DimensionedField<scalar, volMesh>& iF,
131     const dictionary& dict
134     nutkWallFunctionFvPatchScalarField(p, iF, dict),
135     uPlusTableName_(dict.lookup("uPlusTable")),
136     uPlusTable_
137     (
138         IOobject
139         (
140             uPlusTableName_,
141             patch().boundaryMesh().mesh().time().constant(),
142             patch().boundaryMesh().mesh(),
143             IOobject::MUST_READ_IF_MODIFIED,
144             IOobject::NO_WRITE,
145             false
146         ),
147         true
148     )
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 makePatchTypeField
209     fvPatchScalarField,
210     nutUTabulatedWallFunctionFvPatchScalarField
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 } // End namespace RASModels
216 } // End namespace incompressible
217 } // End namespace Foam
219 // ************************************************************************* //