initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / turbulenceModels / compressible / RAS / LaunderSharmaKE / LaunderSharmaKE.C
blob20221e63cd825bee6012bcd346070a9d3352eb5d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "LaunderSharmaKE.H"
28 #include "addToRunTimeSelectionTable.H"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
36 namespace compressible
38 namespace RASModels
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(LaunderSharmaKE, 0);
44 addToRunTimeSelectionTable(RASModel, LaunderSharmaKE, dictionary);
46 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
48 tmp<volScalarField> LaunderSharmaKE::fMu() const
50     return exp(-3.4/sqr(scalar(1) + rho_*sqr(k_)/(mu()*epsilon_)/50.0));
54 tmp<volScalarField> LaunderSharmaKE::f2() const
56     return
57         scalar(1)
58       - 0.3*exp(-min(sqr(rho_*sqr(k_)/(mu()*epsilon_)), scalar(50.0)));
62 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
64 LaunderSharmaKE::LaunderSharmaKE
66     const volScalarField& rho,
67     const volVectorField& U,
68     const surfaceScalarField& phi,
69     const basicThermo& thermophysicalModel
72     RASModel(typeName, rho, U, phi, thermophysicalModel),
74     Cmu_
75     (
76         dimensioned<scalar>::lookupOrAddToDict
77         (
78             "Cmu",
79             coeffDict_,
80             0.09
81         )
82     ),
83     C1_
84     (
85         dimensioned<scalar>::lookupOrAddToDict
86         (
87             "C1",
88             coeffDict_,
89             1.44
90         )
91     ),
92     C2_
93     (
94         dimensioned<scalar>::lookupOrAddToDict
95         (
96             "C2",
97             coeffDict_,
98             1.92
99         )
100     ),
101     C3_
102     (
103         dimensioned<scalar>::lookupOrAddToDict
104         (
105             "C3",
106             coeffDict_,
107             -0.33
108         )
109     ),
110     sigmak_
111     (
112         dimensioned<scalar>::lookupOrAddToDict
113         (
114             "sigmak",
115             coeffDict_,
116             1.0
117         )
118     ),
119     sigmaEps_
120     (
121         dimensioned<scalar>::lookupOrAddToDict
122         (
123             "sigmaEps",
124             coeffDict_,
125             1.3
126         )
127     ),
128     Prt_
129     (
130         dimensioned<scalar>::lookupOrAddToDict
131         (
132             "Prt",
133             coeffDict_,
134             1.0
135         )
136     ),
138     k_
139     (
140         IOobject
141         (
142             "k",
143             runTime_.timeName(),
144             mesh_,
145             IOobject::NO_READ,
146             IOobject::AUTO_WRITE
147         ),
148         autoCreateK("k", mesh_)
149     ),
151     epsilon_
152     (
153         IOobject
154         (
155             "epsilon",
156             runTime_.timeName(),
157             mesh_,
158             IOobject::NO_READ,
159             IOobject::AUTO_WRITE
160         ),
161         autoCreateEpsilon("epsilon", mesh_)
162     ),
164     mut_
165     (
166         IOobject
167         (
168             "mut",
169             runTime_.timeName(),
170             mesh_,
171             IOobject::NO_READ,
172             IOobject::NO_WRITE
173         ),
174         autoCreateMut("mut", mesh_)
175     ),
177     alphat_
178     (
179         IOobject
180         (
181             "alphat",
182             runTime_.timeName(),
183             mesh_,
184             IOobject::NO_READ,
185             IOobject::AUTO_WRITE
186         ),
187         autoCreateAlphat("alphat", mesh_)
188     )
190     mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
191     mut_.correctBoundaryConditions();
193     alphat_ = mut_/Prt_;
194     alphat_.correctBoundaryConditions();
196     printCoeffs();
200 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
202 tmp<volSymmTensorField> LaunderSharmaKE::R() const
204     return tmp<volSymmTensorField>
205     (
206         new volSymmTensorField
207         (
208             IOobject
209             (
210                 "R",
211                 runTime_.timeName(),
212                 mesh_,
213                 IOobject::NO_READ,
214                 IOobject::NO_WRITE
215             ),
216             ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
217             k_.boundaryField().types()
218         )
219     );
223 tmp<volSymmTensorField> LaunderSharmaKE::devRhoReff() const
225     return tmp<volSymmTensorField>
226     (
227         new volSymmTensorField
228         (
229             IOobject
230             (
231                 "devRhoReff",
232                 runTime_.timeName(),
233                 mesh_,
234                 IOobject::NO_READ,
235                 IOobject::NO_WRITE
236             ),
237            -muEff()*dev(twoSymm(fvc::grad(U_)))
238         )
239     );
243 tmp<fvVectorMatrix> LaunderSharmaKE::divDevRhoReff(volVectorField& U) const
245     return
246     (
247       - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
248     );
252 bool LaunderSharmaKE::read()
254     if (RASModel::read())
255     {
256         Cmu_.readIfPresent(coeffDict());
257         C1_.readIfPresent(coeffDict());
258         C2_.readIfPresent(coeffDict());
259         C3_.readIfPresent(coeffDict());
260         sigmak_.readIfPresent(coeffDict());
261         sigmaEps_.readIfPresent(coeffDict());
262         Prt_.readIfPresent(coeffDict());
264         return true;
265     }
266     else
267     {
268         return false;
269     }
273 void LaunderSharmaKE::correct()
275     if (!turbulence_)
276     {
277         // Re-calculate viscosity
278         mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
279         mut_.correctBoundaryConditions();
281         // Re-calculate thermal diffusivity
282         alphat_ = mut_/Prt_;
283         alphat_.correctBoundaryConditions();
285         return;
286     }
288     RASModel::correct();
290     // Calculate parameters and coefficients for Launder-Sharma low-Reynolds
291     // number model
293     volScalarField E = 2.0*mu()*mut_*fvc::magSqrGradGrad(U_)/rho_;
294     volScalarField D = 2.0*mu()*magSqr(fvc::grad(sqrt(k_)))/rho_;
296     volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
298     if (mesh_.moving())
299     {
300         divU += fvc::div(mesh_.phi());
301     }
303     tmp<volTensorField> tgradU = fvc::grad(U_);
304     volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
305     tgradU.clear();
307     // Update espsilon and G at the wall
308     epsilon_.boundaryField().updateCoeffs();
310     // Dissipation equation
312     tmp<fvScalarMatrix> epsEqn
313     (
314         fvm::ddt(rho_, epsilon_)
315       + fvm::div(phi_, epsilon_)
316       - fvm::laplacian(DepsilonEff(), epsilon_)
317      ==
318         C1_*G*epsilon_/k_ + fvm::SuSp((C3_ - 2.0/3.0*C1_)*rho_*divU, epsilon_)
319       - fvm::Sp(C2_*f2()*rho_*epsilon_/k_, epsilon_)
320     //+ 0.75*1.5*flameKproduction*epsilon_/k_
321       + E
322     );
324     epsEqn().relax();
326     epsEqn().boundaryManipulate(epsilon_.boundaryField());
328     solve(epsEqn);
329     bound(epsilon_, epsilon0_);
332     // Turbulent kinetic energy equation
334     tmp<fvScalarMatrix> kEqn
335     (
336         fvm::ddt(rho_, k_)
337       + fvm::div(phi_, k_)
338       - fvm::laplacian(DkEff(), k_)
339      ==
340         G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
341       - fvm::Sp(rho_*(epsilon_ + D)/k_, k_)
342     //+ flameKproduction
343     );
345     kEqn().relax();
346     solve(kEqn);
347     bound(k_, k0_);
350     // Re-calculate viscosity
351     mut_ = Cmu_*fMu()*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
352     mut_.correctBoundaryConditions();
354     // Re-calculate thermal diffusivity
355     alphat_ = mut_/Prt_;
356     alphat_.correctBoundaryConditions();
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 } // End namespace RASModels
363 } // End namespace compressible
364 } // End namespace Foam
366 // ************************************************************************* //