FreeFOAM The Cross-Platform CFD Toolkit
omegaWallFunctionFvPatchScalarField.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) 2008-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>
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace incompressible
38 {
39 namespace RASModels
40 {
41 
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 
44 void omegaWallFunctionFvPatchScalarField::checkType()
45 {
46  if (!isA<wallFvPatch>(patch()))
47  {
48  FatalErrorIn("omegaWallFunctionFvPatchScalarField::checkType()")
49  << "Invalid wall function specification" << nl
50  << " Patch type for patch " << patch().name()
51  << " must be wall" << nl
52  << " Current patch type is " << patch().type() << nl << endl
53  << abort(FatalError);
54  }
55 }
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
61 (
62  const fvPatch& p,
64 )
65 :
67  UName_("U"),
68  kName_("k"),
69  GName_("RASModel::G"),
70  nuName_("nu"),
71  nutName_("nut"),
72  Cmu_(0.09),
73  kappa_(0.41),
74  E_(9.8),
75  beta1_(0.075)
76 {
77  checkType();
78 }
79 
80 
82 (
84  const fvPatch& p,
86  const fvPatchFieldMapper& mapper
87 )
88 :
89  fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
90  UName_(ptf.UName_),
91  kName_(ptf.kName_),
92  GName_(ptf.GName_),
93  nuName_(ptf.nuName_),
94  nutName_(ptf.nutName_),
95  Cmu_(ptf.Cmu_),
96  kappa_(ptf.kappa_),
97  E_(ptf.E_),
98  beta1_(ptf.beta1_)
99 {
100  checkType();
101 }
102 
103 
105 (
106  const fvPatch& p,
108  const dictionary& dict
109 )
110 :
112  UName_(dict.lookupOrDefault<word>("U", "U")),
113  kName_(dict.lookupOrDefault<word>("k", "k")),
114  GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
115  nuName_(dict.lookupOrDefault<word>("nu", "nu")),
116  nutName_(dict.lookupOrDefault<word>("nut", "nut")),
117  Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
118  kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
119  E_(dict.lookupOrDefault<scalar>("E", 9.8)),
120  beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
121 {
122  checkType();
123 }
124 
125 
127 (
129 )
130 :
132  UName_(owfpsf.UName_),
133  kName_(owfpsf.kName_),
134  GName_(owfpsf.GName_),
135  nuName_(owfpsf.nuName_),
136  nutName_(owfpsf.nutName_),
137  Cmu_(owfpsf.Cmu_),
138  kappa_(owfpsf.kappa_),
139  E_(owfpsf.E_),
140  beta1_(owfpsf.beta1_)
141 {
142  checkType();
143 }
144 
145 
147 (
150 )
151 :
153  UName_(owfpsf.UName_),
154  kName_(owfpsf.kName_),
155  GName_(owfpsf.GName_),
156  nuName_(owfpsf.nuName_),
157  nutName_(owfpsf.nutName_),
158  Cmu_(owfpsf.Cmu_),
159  kappa_(owfpsf.kappa_),
160  E_(owfpsf.E_),
161  beta1_(owfpsf.beta1_)
162 {
163  checkType();
164 }
165 
166 
167 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
168 
170 {
171  if (updated())
172  {
173  return;
174  }
175 
176  const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
177  const scalarField& y = rasModel.y()[patch().index()];
178 
179  const scalar Cmu25 = pow(Cmu_, 0.25);
180 
181  volScalarField& G = const_cast<volScalarField&>
182  (db().lookupObject<volScalarField>(GName_));
183 
184  volScalarField& omega = const_cast<volScalarField&>
186 
187  const scalarField& k = db().lookupObject<volScalarField>(kName_);
188 
189  const scalarField& nuw =
190  patch().lookupPatchField<volScalarField, scalar>(nuName_);
191 
192  const scalarField& nutw =
193  patch().lookupPatchField<volScalarField, scalar>(nutName_);
194 
195  const fvPatchVectorField& Uw =
197 
198  vectorField n = patch().nf();
199 
200  const scalarField magGradUw = mag(Uw.snGrad());
201 
202  // Set omega and G
203  forAll(nutw, faceI)
204  {
205  label faceCellI = patch().faceCells()[faceI];
206 
207  scalar omegaVis = 6.0*nuw[faceI]/(beta1_*sqr(y[faceI]));
208  scalar omegaLog = sqrt(k[faceCellI])/(Cmu25*kappa_*y[faceI]);
209  omega[faceCellI] = sqrt(sqr(omegaVis) + sqr(omegaLog));
210 
211  G[faceCellI] =
212  (nutw[faceI] + nuw[faceI])
213  *magGradUw[faceI]
214  *Cmu25*sqrt(k[faceCellI])
215  /(kappa_*y[faceI]);
216  }
217 
218  // TODO: perform averaging for cells sharing more than one boundary face
219 
221 }
222 
223 
225 {
227  writeEntryIfDifferent<word>(os, "U", "U", UName_);
228  writeEntryIfDifferent<word>(os, "k", "k", kName_);
229  writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
230  writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
231  writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
232  os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
233  os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
234  os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
235  os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
236  writeEntry("value", os);
237 }
238 
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
243 (
246 );
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 } // End namespace RASModels
251 } // End namespace incompressible
252 } // End namespace Foam
253 
254 // ************************ vim: set sw=4 sts=4 et: ************************ //