Added the field name to the creation of "mut".
[OpenFOAM-1.6.x.git] / src / turbulenceModels / compressible / RAS / LaunderSharmaKE / LaunderSharmaKE.C
blob18f8d49995241dda50bf28a0bde304a2335b2e9f
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::MUST_READ,
146             IOobject::AUTO_WRITE
147         ),
148         mesh_
149     ),
151     epsilon_
152     (
153         IOobject
154         (
155             "epsilon",
156             runTime_.timeName(),
157             mesh_,
158             IOobject::MUST_READ,
159             IOobject::AUTO_WRITE
160         ),
161         mesh_
162     ),
164     mut_
165     (
166         IOobject
167         (
168             "mut",
169             runTime_.timeName(),
170             mesh_,
171             IOobject::MUST_READ,
172             IOobject::AUTO_WRITE
173         ),
174         rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_)
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     alphat_ = mut_/Prt_;
191     alphat_.correctBoundaryConditions();
193     printCoeffs();
197 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
199 tmp<volSymmTensorField> LaunderSharmaKE::R() const
201     return tmp<volSymmTensorField>
202     (
203         new volSymmTensorField
204         (
205             IOobject
206             (
207                 "R",
208                 runTime_.timeName(),
209                 mesh_,
210                 IOobject::NO_READ,
211                 IOobject::NO_WRITE
212             ),
213             ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
214             k_.boundaryField().types()
215         )
216     );
220 tmp<volSymmTensorField> LaunderSharmaKE::devRhoReff() const
222     return tmp<volSymmTensorField>
223     (
224         new volSymmTensorField
225         (
226             IOobject
227             (
228                 "devRhoReff",
229                 runTime_.timeName(),
230                 mesh_,
231                 IOobject::NO_READ,
232                 IOobject::NO_WRITE
233             ),
234            -muEff()*dev(twoSymm(fvc::grad(U_)))
235         )
236     );
240 tmp<fvVectorMatrix> LaunderSharmaKE::divDevRhoReff(volVectorField& U) const
242     return
243     (
244       - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
245     );
249 bool LaunderSharmaKE::read()
251     if (RASModel::read())
252     {
253         Cmu_.readIfPresent(coeffDict());
254         C1_.readIfPresent(coeffDict());
255         C2_.readIfPresent(coeffDict());
256         C3_.readIfPresent(coeffDict());
257         sigmak_.readIfPresent(coeffDict());
258         sigmaEps_.readIfPresent(coeffDict());
259         Prt_.readIfPresent(coeffDict());
261         return true;
262     }
263     else
264     {
265         return false;
266     }
270 void LaunderSharmaKE::correct()
272     if (!turbulence_)
273     {
274         // Re-calculate viscosity
275         mut_ == rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
277         // Re-calculate thermal diffusivity
278         alphat_ = mut_/Prt_;
279         alphat_.correctBoundaryConditions();
281         return;
282     }
284     RASModel::correct();
286     // Calculate parameters and coefficients for Launder-Sharma low-Reynolds
287     // number model
289     volScalarField E = 2.0*mu()*mut_*fvc::magSqrGradGrad(U_)/rho_;
290     volScalarField D = 2.0*mu()*magSqr(fvc::grad(sqrt(k_)))/rho_;
292     volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
294     if (mesh_.moving())
295     {
296         divU += fvc::div(mesh_.phi());
297     }
299     tmp<volTensorField> tgradU = fvc::grad(U_);
300     volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
301     tgradU.clear();
304     // Dissipation equation
306     tmp<fvScalarMatrix> epsEqn
307     (
308         fvm::ddt(rho_, epsilon_)
309       + fvm::div(phi_, epsilon_)
310       - fvm::laplacian(DepsilonEff(), epsilon_)
311      ==
312         C1_*G*epsilon_/k_ + fvm::SuSp((C3_ - 2.0/3.0*C1_)*rho_*divU, epsilon_)
313       - fvm::Sp(C2_*f2()*rho_*epsilon_/k_, epsilon_)
314     //+ 0.75*1.5*flameKproduction*epsilon_/k_
315       + E
316     );
318     epsEqn().relax();
319     solve(epsEqn);
320     bound(epsilon_, epsilon0_);
323     // Turbulent kinetic energy equation
325     tmp<fvScalarMatrix> kEqn
326     (
327         fvm::ddt(rho_, k_)
328       + fvm::div(phi_, k_)
329       - fvm::laplacian(DkEff(), k_)
330      ==
331         G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
332       - fvm::Sp(rho_*(epsilon_ + D)/k_, k_)
333     //+ flameKproduction
334     );
336     kEqn().relax();
337     solve(kEqn);
338     bound(k_, k0_);
341     // Re-calculate viscosity
342     mut_ == Cmu_*fMu()*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
345     // Re-calculate thermal diffusivity
346     alphat_ = mut_/Prt_;
347     alphat_.correctBoundaryConditions();
351 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353 } // End namespace RASModels
354 } // End namespace compressible
355 } // End namespace Foam
357 // ************************************************************************* //