FreeFOAM The Cross-Platform CFD Toolkit
mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.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 compressible
37 {
38 namespace RASModels
39 {
40 
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42 
43 tmp<scalarField>
44 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
45 (
46  const scalarField& magUp
47 ) const
48 {
49  const label patchI = patch().index();
50 
51  const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
52  const scalarField& y = rasModel.y()[patchI];
53  const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI];
54  const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
55 
56  tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
57  scalarField& yPlus = tyPlus();
58 
59  forAll(yPlus, faceI)
60  {
61  scalar kappaRe = kappa_*magUp[faceI]*y[faceI]/(muw[faceI]/rhow[faceI]);
62 
63  scalar yp = yPlusLam_;
64  scalar ryPlusLam = 1.0/yp;
65 
66  int iter = 0;
67  scalar yPlusLast = 0.0;
68 
69  do
70  {
71  yPlusLast = yp;
72  yp = (kappaRe + yp)/(1.0 + log(E_*yp));
73 
74  } while (mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10);
75 
76  yPlus[faceI] = max(0.0, yp);
77  }
78 
79  return tyPlus;
80 }
81 
82 
84 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const
85 {
86  const label patchI = patch().index();
87 
88  const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
89  const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
90  const scalarField magUp = mag(Uw.patchInternalField() - Uw);
91  const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
92 
93  tmp<scalarField> tyPlus = calcYPlus(magUp);
94  scalarField& yPlus = tyPlus();
95 
96  tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
97  scalarField& mutw = tmutw();
98 
99  forAll(yPlus, faceI)
100  {
101  if (yPlus[faceI] > yPlusLam_)
102  {
103  mutw[faceI] =
104  muw[faceI]*(yPlus[faceI]*kappa_/log(E_*yPlus[faceI]) - 1.0);
105  }
106  }
107 
108  return tmutw;
109 }
110 
111 
112 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
113 
114 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
115 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
116 (
117  const fvPatch& p,
119 )
120 :
122 {}
123 
124 
125 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
126 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
127 (
129  const fvPatch& p,
131  const fvPatchFieldMapper& mapper
132 )
133 :
134  mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
135 {}
136 
137 
138 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
139 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
140 (
141  const fvPatch& p,
143  const dictionary& dict
144 )
145 :
147 {}
148 
149 
150 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
151 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
152 (
154 )
155 :
157 {}
158 
159 
160 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
161 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
162 (
165 )
166 :
168 {}
169 
170 
171 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
172 
174 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const
175 {
176  const label patchI = patch().index();
177  const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
178  const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
179  const scalarField magUp = mag(Uw.patchInternalField() - Uw);
180 
181  return calcYPlus(magUp);
182 }
183 
184 
185 void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write
186 (
187  Ostream& os
188 ) const
189 {
191  writeLocalEntries(os);
192  writeEntry("value", os);
193 }
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
199 (
202 );
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace RASModels
207 } // End namespace compressible
208 } // End namespace Foam
209 
210 // ************************ vim: set sw=4 sts=4 et: ************************ //