FreeFOAM The Cross-Platform CFD Toolkit
nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
29 #include <finiteVolume/volFields.H>
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace incompressible
37 {
38 namespace RASModels
39 {
40 
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42 
43 tmp<scalarField>
45 {
46  const label patchI = patch().index();
47 
48  const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
49  const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
50  const scalarField magUp = mag(Uw.patchInternalField() - Uw);
51  const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
52 
53  tmp<scalarField> tyPlus = calcYPlus(magUp);
54  scalarField& yPlus = tyPlus();
55 
56  tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
57  scalarField& nutw = tnutw();
58 
59  forAll(yPlus, facei)
60  {
61  if (yPlus[facei] > yPlusLam_)
62  {
63  nutw[facei] =
64  nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0);
65  }
66  }
67 
68  return tnutw;
69 }
70 
71 
74 (
75  const scalarField& magUp
76 ) const
77 {
78  const label patchI = patch().index();
79 
80  const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
81  const scalarField& y = rasModel.y()[patchI];
82  const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
83 
84  tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
85  scalarField& yPlus = tyPlus();
86 
87  forAll(yPlus, facei)
88  {
89  scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei];
90 
91  scalar yp = yPlusLam_;
92  scalar ryPlusLam = 1.0/yp;
93 
94  int iter = 0;
95  scalar yPlusLast = 0.0;
96 
97  do
98  {
99  yPlusLast = yp;
100  yp = (kappaRe + yp)/(1.0 + log(E_*yp));
101 
102  } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 );
103 
104  yPlus[facei] = max(0.0, yp);
105  }
106 
107  return tyPlus;
108 }
109 
110 
111 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
112 
115 (
116  const fvPatch& p,
118 )
119 :
121 {}
122 
123 
126 (
128  const fvPatch& p,
130  const fvPatchFieldMapper& mapper
131 )
132 :
133  nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
134 {}
135 
136 
139 (
140  const fvPatch& p,
142  const dictionary& dict
143 )
144 :
146 {}
147 
148 
151 (
153 )
154 :
156 {}
157 
158 
161 (
164 )
165 :
167 {}
168 
169 
170 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
171 
174 {
175  const label patchI = patch().index();
176  const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
177  const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
178  const scalarField magUp = mag(Uw.patchInternalField() - Uw);
179 
180  return calcYPlus(magUp);
181 }
182 
183 
185 (
186  Ostream& os
187 ) const
188 {
190  writeLocalEntries(os);
191  writeEntry("value", os);
192 }
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
198 (
201 );
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace RASModels
206 } // End namespace incompressible
207 } // End namespace Foam
208 
209 // ************************ vim: set sw=4 sts=4 et: ************************ //