FreeFOAM The Cross-Platform CFD Toolkit
nutSpalartAllmarasWallFunctionFvPatchScalarField.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 magGradU = mag(Uw.snGrad());
51  const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
52 
53  return max
54  (
55  scalar(0),
56  sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - nuw
57  );
58 }
59 
60 
62 (
63  const scalarField& magGradU
64 ) const
65 {
66  const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
67  const scalarField& y = rasModel.y()[patch().index()];
68 
69  const fvPatchVectorField& Uw =
70  rasModel.U().boundaryField()[patch().index()];
71  const scalarField magUp = mag(Uw.patchInternalField() - Uw);
72 
73  const scalarField& nuw = rasModel.nu().boundaryField()[patch().index()];
74  const scalarField& nutw = *this;
75 
76  tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
77  scalarField& uTau = tuTau();
78 
79  forAll(uTau, facei)
80  {
81  scalar magUpara = magUp[facei];
82 
83  scalar ut = sqrt((nutw[facei] + nuw[facei])*magGradU[facei]);
84 
85  if (ut > VSMALL)
86  {
87  int iter = 0;
88  scalar err = GREAT;
89 
90  do
91  {
92  scalar kUu = min(kappa_*magUpara/ut, 50);
93  scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
94 
95  scalar f =
96  - ut*y[facei]/nuw[facei]
97  + magUpara/ut
98  + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
99 
100  scalar df =
101  y[facei]/nuw[facei]
102  + magUpara/sqr(ut)
103  + 1/E_*kUu*fkUu/ut;
104 
105  scalar uTauNew = ut + f/df;
106  err = mag((ut - uTauNew)/ut);
107  ut = uTauNew;
108 
109  } while (ut > VSMALL && err > 0.01 && ++iter < 10);
110  uTau[facei] = max(0.0, ut);
111  }
112  }
113 
114  return tuTau;
115 }
116 
117 
118 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
119 
122 (
123  const fvPatch& p,
125 )
126 :
128 {}
129 
130 
133 (
135  const fvPatch& p,
137  const fvPatchFieldMapper& mapper
138 )
139 :
140  nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
141 {}
142 
143 
146 (
147  const fvPatch& p,
149  const dictionary& dict
150 )
151 :
153 {}
154 
155 
158 (
160 )
161 :
163 {}
164 
165 
168 (
171 )
172 :
174 {}
175 
176 
177 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
178 
181 {
182  const label patchI = patch().index();
183 
184  const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
185  const scalarField& y = rasModel.y()[patchI];
186  const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
187  const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
188 
189  return y*calcUTau(mag(Uw.snGrad()))/nuw;
190 }
191 
192 
194 (
195  Ostream& os
196 ) const
197 {
199  writeLocalEntries(os);
200  writeEntry("value", os);
201 }
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
207 (
210 );
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace RASModels
215 } // End namespace incompressible
216 } // End namespace Foam
217 
218 // ************************ vim: set sw=4 sts=4 et: ************************ //