1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace compressible
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
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),
76 dimensioned<scalar>::lookupOrAddToDict
85 dimensioned<scalar>::lookupOrAddToDict
94 dimensioned<scalar>::lookupOrAddToDict
103 dimensioned<scalar>::lookupOrAddToDict
112 dimensioned<scalar>::lookupOrAddToDict
121 dimensioned<scalar>::lookupOrAddToDict
130 dimensioned<scalar>::lookupOrAddToDict
148 autoCreateK("k", mesh_)
161 autoCreateEpsilon("epsilon", mesh_)
174 autoCreateMut("mut", mesh_)
187 autoCreateAlphat("alphat", mesh_)
190 mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
191 mut_.correctBoundaryConditions();
194 alphat_.correctBoundaryConditions();
200 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
202 tmp<volSymmTensorField> LaunderSharmaKE::R() const
204 return tmp<volSymmTensorField>
206 new volSymmTensorField
216 ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
217 k_.boundaryField().types()
223 tmp<volSymmTensorField> LaunderSharmaKE::devRhoReff() const
225 return tmp<volSymmTensorField>
227 new volSymmTensorField
237 -muEff()*dev(twoSymm(fvc::grad(U_)))
243 tmp<fvVectorMatrix> LaunderSharmaKE::divDevRhoReff(volVectorField& U) const
247 - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
252 bool LaunderSharmaKE::read()
254 if (RASModel::read())
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());
273 void LaunderSharmaKE::correct()
277 // Re-calculate viscosity
278 mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
279 mut_.correctBoundaryConditions();
281 // Re-calculate thermal diffusivity
283 alphat_.correctBoundaryConditions();
290 // Calculate parameters and coefficients for Launder-Sharma low-Reynolds
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_));
300 divU += fvc::div(mesh_.phi());
303 tmp<volTensorField> tgradU = fvc::grad(U_);
304 volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
307 // Update espsilon and G at the wall
308 epsilon_.boundaryField().updateCoeffs();
310 // Dissipation equation
312 tmp<fvScalarMatrix> epsEqn
314 fvm::ddt(rho_, epsilon_)
315 + fvm::div(phi_, epsilon_)
316 - fvm::laplacian(DepsilonEff(), epsilon_)
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_
326 epsEqn().boundaryManipulate(epsilon_.boundaryField());
329 bound(epsilon_, epsilon0_);
332 // Turbulent kinetic energy equation
334 tmp<fvScalarMatrix> kEqn
338 - fvm::laplacian(DkEff(), k_)
340 G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
341 - fvm::Sp(rho_*(epsilon_ + D)/k_, k_)
350 // Re-calculate viscosity
351 mut_ = Cmu_*fMu()*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
352 mut_.correctBoundaryConditions();
354 // Re-calculate thermal diffusivity
356 alphat_.correctBoundaryConditions();
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 } // End namespace RASModels
363 } // End namespace compressible
364 } // End namespace Foam
366 // ************************************************************************* //