bugfix: corrected NO_READ->MUST_READ for k and epsilon fields
[OpenFOAM-1.6.x.git] / src / turbulenceModels / compressible / RAS / LaunderSharmaKE / LaunderSharmaKE.C
blob10160bbed4f7887c06925dedff753af37b745569
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_(rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_)),
166     alphat_
167     (
168         IOobject
169         (
170             "alphat",
171             runTime_.timeName(),
172             mesh_,
173             IOobject::NO_READ,
174             IOobject::AUTO_WRITE
175         ),
176         autoCreateAlphat("alphat", mesh_)
177     )
179     alphat_ = mut_/Prt_;
180     alphat_.correctBoundaryConditions();
182     printCoeffs();
186 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
188 tmp<volSymmTensorField> LaunderSharmaKE::R() const
190     return tmp<volSymmTensorField>
191     (
192         new volSymmTensorField
193         (
194             IOobject
195             (
196                 "R",
197                 runTime_.timeName(),
198                 mesh_,
199                 IOobject::NO_READ,
200                 IOobject::NO_WRITE
201             ),
202             ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
203             k_.boundaryField().types()
204         )
205     );
209 tmp<volSymmTensorField> LaunderSharmaKE::devRhoReff() const
211     return tmp<volSymmTensorField>
212     (
213         new volSymmTensorField
214         (
215             IOobject
216             (
217                 "devRhoReff",
218                 runTime_.timeName(),
219                 mesh_,
220                 IOobject::NO_READ,
221                 IOobject::NO_WRITE
222             ),
223            -muEff()*dev(twoSymm(fvc::grad(U_)))
224         )
225     );
229 tmp<fvVectorMatrix> LaunderSharmaKE::divDevRhoReff(volVectorField& U) const
231     return
232     (
233       - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
234     );
238 bool LaunderSharmaKE::read()
240     if (RASModel::read())
241     {
242         Cmu_.readIfPresent(coeffDict());
243         C1_.readIfPresent(coeffDict());
244         C2_.readIfPresent(coeffDict());
245         C3_.readIfPresent(coeffDict());
246         sigmak_.readIfPresent(coeffDict());
247         sigmaEps_.readIfPresent(coeffDict());
248         Prt_.readIfPresent(coeffDict());
250         return true;
251     }
252     else
253     {
254         return false;
255     }
259 void LaunderSharmaKE::correct()
261     if (!turbulence_)
262     {
263         // Re-calculate viscosity
264         mut_ == rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
266         // Re-calculate thermal diffusivity
267         alphat_ = mut_/Prt_;
268         alphat_.correctBoundaryConditions();
270         return;
271     }
273     RASModel::correct();
275     // Calculate parameters and coefficients for Launder-Sharma low-Reynolds
276     // number model
278     volScalarField E = 2.0*mu()*mut_*fvc::magSqrGradGrad(U_)/rho_;
279     volScalarField D = 2.0*mu()*magSqr(fvc::grad(sqrt(k_)))/rho_;
281     volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
283     if (mesh_.moving())
284     {
285         divU += fvc::div(mesh_.phi());
286     }
288     tmp<volTensorField> tgradU = fvc::grad(U_);
289     volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
290     tgradU.clear();
293     // Dissipation equation
295     tmp<fvScalarMatrix> epsEqn
296     (
297         fvm::ddt(rho_, epsilon_)
298       + fvm::div(phi_, epsilon_)
299       - fvm::laplacian(DepsilonEff(), epsilon_)
300      ==
301         C1_*G*epsilon_/k_ + fvm::SuSp((C3_ - 2.0/3.0*C1_)*rho_*divU, epsilon_)
302       - fvm::Sp(C2_*f2()*rho_*epsilon_/k_, epsilon_)
303     //+ 0.75*1.5*flameKproduction*epsilon_/k_
304       + E
305     );
307     epsEqn().relax();
308     solve(epsEqn);
309     bound(epsilon_, epsilon0_);
312     // Turbulent kinetic energy equation
314     tmp<fvScalarMatrix> kEqn
315     (
316         fvm::ddt(rho_, k_)
317       + fvm::div(phi_, k_)
318       - fvm::laplacian(DkEff(), k_)
319      ==
320         G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
321       - fvm::Sp(rho_*(epsilon_ + D)/k_, k_)
322     //+ flameKproduction
323     );
325     kEqn().relax();
326     solve(kEqn);
327     bound(k_, k0_);
330     // Re-calculate viscosity
331     mut_ == Cmu_*fMu()*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
334     // Re-calculate thermal diffusivity
335     alphat_ = mut_/Prt_;
336     alphat_.correctBoundaryConditions();
340 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
342 } // End namespace RASModels
343 } // End namespace compressible
344 } // End namespace Foam
346 // ************************************************************************* //