FreeFOAM The Cross-Platform CFD Toolkit
LaunderSharmaKE.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 
26 #include "LaunderSharmaKE.H"
28 
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace compressible
36 {
37 namespace RASModels
38 {
39 
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 
42 defineTypeNameAndDebug(LaunderSharmaKE, 0);
43 addToRunTimeSelectionTable(RASModel, LaunderSharmaKE, dictionary);
44 
45 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
46 
47 tmp<volScalarField> LaunderSharmaKE::fMu() const
48 {
49  return exp(-3.4/sqr(scalar(1) + rho_*sqr(k_)/(mu()*epsilon_)/50.0));
50 }
51 
52 
53 tmp<volScalarField> LaunderSharmaKE::f2() const
54 {
55  return
56  scalar(1)
57  - 0.3*exp(-min(sqr(rho_*sqr(k_)/(mu()*epsilon_)), scalar(50.0)));
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
62 
63 LaunderSharmaKE::LaunderSharmaKE
64 (
65  const volScalarField& rho,
66  const volVectorField& U,
67  const surfaceScalarField& phi,
68  const basicThermo& thermophysicalModel
69 )
70 :
71  RASModel(typeName, rho, U, phi, thermophysicalModel),
72 
73  Cmu_
74  (
76  (
77  "Cmu",
78  coeffDict_,
79  0.09
80  )
81  ),
82  C1_
83  (
85  (
86  "C1",
87  coeffDict_,
88  1.44
89  )
90  ),
91  C2_
92  (
94  (
95  "C2",
96  coeffDict_,
97  1.92
98  )
99  ),
100  C3_
101  (
103  (
104  "C3",
105  coeffDict_,
106  -0.33
107  )
108  ),
109  sigmak_
110  (
112  (
113  "sigmak",
114  coeffDict_,
115  1.0
116  )
117  ),
118  sigmaEps_
119  (
121  (
122  "sigmaEps",
123  coeffDict_,
124  1.3
125  )
126  ),
127  Prt_
128  (
130  (
131  "Prt",
132  coeffDict_,
133  1.0
134  )
135  ),
136 
137  k_
138  (
139  IOobject
140  (
141  "k",
142  runTime_.timeName(),
143  mesh_,
146  ),
147  mesh_
148  ),
149 
150  epsilon_
151  (
152  IOobject
153  (
154  "epsilon",
155  runTime_.timeName(),
156  mesh_,
159  ),
160  mesh_
161  ),
162 
163  mut_
164  (
165  IOobject
166  (
167  "mut",
168  runTime_.timeName(),
169  mesh_,
172  ),
173  autoCreateLowReMut("mut", mesh_)
174  ),
175 
176  alphat_
177  (
178  IOobject
179  (
180  "alphat",
181  runTime_.timeName(),
182  mesh_,
185  ),
186  autoCreateAlphat("alphat", mesh_)
187  )
188 {
189  mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
190  mut_.correctBoundaryConditions();
191 
192  alphat_ = mut_/Prt_;
193  alphat_.correctBoundaryConditions();
194 
195  printCoeffs();
196 }
197 
198 
199 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
200 
201 tmp<volSymmTensorField> LaunderSharmaKE::R() const
202 {
204  (
206  (
207  IOobject
208  (
209  "R",
210  runTime_.timeName(),
211  mesh_,
214  ),
215  ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
216  k_.boundaryField().types()
217  )
218  );
219 }
220 
221 
222 tmp<volSymmTensorField> LaunderSharmaKE::devRhoReff() const
223 {
225  (
227  (
228  IOobject
229  (
230  "devRhoReff",
231  runTime_.timeName(),
232  mesh_,
235  ),
236  -muEff()*dev(twoSymm(fvc::grad(U_)))
237  )
238  );
239 }
240 
241 
242 tmp<fvVectorMatrix> LaunderSharmaKE::divDevRhoReff(volVectorField& U) const
243 {
244  return
245  (
246  - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
247  );
248 }
249 
250 
251 bool LaunderSharmaKE::read()
252 {
253  if (RASModel::read())
254  {
255  Cmu_.readIfPresent(coeffDict());
256  C1_.readIfPresent(coeffDict());
257  C2_.readIfPresent(coeffDict());
258  C3_.readIfPresent(coeffDict());
259  sigmak_.readIfPresent(coeffDict());
260  sigmaEps_.readIfPresent(coeffDict());
261  Prt_.readIfPresent(coeffDict());
262 
263  return true;
264  }
265  else
266  {
267  return false;
268  }
269 }
270 
271 
273 {
274  if (!turbulence_)
275  {
276  // Re-calculate viscosity
277  mut_ == rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
278 
279  // Re-calculate thermal diffusivity
280  alphat_ = mut_/Prt_;
281  alphat_.correctBoundaryConditions();
282 
283  return;
284  }
285 
287 
288  // Calculate parameters and coefficients for Launder-Sharma low-Reynolds
289  // number model
290 
291  volScalarField E = 2.0*mu()*mut_*fvc::magSqrGradGrad(U_)/rho_;
292  volScalarField D = 2.0*mu()*magSqr(fvc::grad(sqrt(k_)))/rho_;
293 
294  volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
295 
296  if (mesh_.moving())
297  {
298  divU += fvc::div(mesh_.phi());
299  }
300 
301  tmp<volTensorField> tgradU = fvc::grad(U_);
302  volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
303  tgradU.clear();
304 
305 
306  // Dissipation equation
307 
308  tmp<fvScalarMatrix> epsEqn
309  (
310  fvm::ddt(rho_, epsilon_)
311  + fvm::div(phi_, epsilon_)
312  - fvm::laplacian(DepsilonEff(), epsilon_)
313  ==
314  C1_*G*epsilon_/k_ + fvm::SuSp((C3_ - 2.0/3.0*C1_)*rho_*divU, epsilon_)
315  - fvm::Sp(C2_*f2()*rho_*epsilon_/k_, epsilon_)
316  //+ 0.75*1.5*flameKproduction*epsilon_/k_
317  + E
318  );
319 
320  epsEqn().relax();
321  solve(epsEqn);
322  bound(epsilon_, epsilon0_);
323 
324 
325  // Turbulent kinetic energy equation
326 
328  (
329  fvm::ddt(rho_, k_)
330  + fvm::div(phi_, k_)
331  - fvm::laplacian(DkEff(), k_)
332  ==
333  G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
334  - fvm::Sp(rho_*(epsilon_ + D)/k_, k_)
335  //+ flameKproduction
336  );
337 
338  kEqn().relax();
339  solve(kEqn);
340  bound(k_, k0_);
341 
342 
343  // Re-calculate viscosity
344  mut_ == Cmu_*fMu()*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
345 
346 
347  // Re-calculate thermal diffusivity
348  alphat_ = mut_/Prt_;
349  alphat_.correctBoundaryConditions();
350 }
351 
352 
353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 
355 } // End namespace RASModels
356 } // End namespace compressible
357 } // End namespace Foam
358 
359 // ************************ vim: set sw=4 sts=4 et: ************************ //