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 "realizableKE.H"
28 #include "addToRunTimeSelectionTable.H"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace compressible
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(realizableKE, 0);
44 addToRunTimeSelectionTable(RASModel, realizableKE, dictionary);
46 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
48 tmp<volScalarField> realizableKE::rCmu
50 const volTensorField& gradU,
51 const volScalarField& S2,
52 const volScalarField& magS
55 tmp<volSymmTensorField> tS = dev(symm(gradU));
56 const volSymmTensorField& S = tS();
59 (2*sqrt(2.0))*((S&S)&&S)
62 + dimensionedScalar("small", dimensionSet(0, 0, -3, 0, 0), SMALL)
68 (1.0/3.0)*acos(min(max(sqrt(6.0)*W, -scalar(1)), scalar(1)));
69 volScalarField As = sqrt(6.0)*cos(phis);
70 volScalarField Us = sqrt(S2/2.0 + magSqr(skew(gradU)));
72 return 1.0/(A0_ + As*Us*k_/(epsilon_ + epsilonSmall_));
76 tmp<volScalarField> realizableKE::rCmu
78 const volTensorField& gradU
81 volScalarField S2 = 2*magSqr(dev(symm(gradU)));
82 volScalarField magS = sqrt(S2);
83 return rCmu(gradU, S2, magS);
87 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
89 realizableKE::realizableKE
91 const volScalarField& rho,
92 const volVectorField& U,
93 const surfaceScalarField& phi,
94 const basicThermo& thermophysicalModel
97 RASModel(typeName, rho, U, phi, thermophysicalModel),
101 dimensioned<scalar>::lookupOrAddToDict
110 dimensioned<scalar>::lookupOrAddToDict
119 dimensioned<scalar>::lookupOrAddToDict
128 dimensioned<scalar>::lookupOrAddToDict
137 dimensioned<scalar>::lookupOrAddToDict
146 dimensioned<scalar>::lookupOrAddToDict
164 autoCreateK("k", mesh_)
176 autoCreateEpsilon("epsilon", mesh_)
188 autoCreateMut("mut", mesh_)
200 autoCreateAlphat("alphat", mesh_)
204 bound(epsilon_, epsilon0_);
206 mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
207 mut_.correctBoundaryConditions();
210 alphat_.correctBoundaryConditions();
216 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
218 tmp<volSymmTensorField> realizableKE::R() const
220 return tmp<volSymmTensorField>
222 new volSymmTensorField
232 ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
233 k_.boundaryField().types()
239 tmp<volSymmTensorField> realizableKE::devRhoReff() const
241 return tmp<volSymmTensorField>
243 new volSymmTensorField
253 -muEff()*dev(twoSymm(fvc::grad(U_)))
259 tmp<fvVectorMatrix> realizableKE::divDevRhoReff(volVectorField& U) const
263 - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
268 bool realizableKE::read()
270 if (RASModel::read())
272 Cmu_.readIfPresent(coeffDict());
273 A0_.readIfPresent(coeffDict());
274 C2_.readIfPresent(coeffDict());
275 sigmak_.readIfPresent(coeffDict());
276 sigmaEps_.readIfPresent(coeffDict());
277 Prt_.readIfPresent(coeffDict());
288 void realizableKE::correct()
292 // Re-calculate viscosity
293 mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_;
294 mut_.correctBoundaryConditions();
296 // Re-calculate thermal diffusivity
298 alphat_.correctBoundaryConditions();
305 volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
309 divU += fvc::div(mesh_.phi());
312 volTensorField gradU = fvc::grad(U_);
313 volScalarField S2 = 2*magSqr(dev(symm(gradU)));
314 volScalarField magS = sqrt(S2);
316 volScalarField eta = magS*k_/epsilon_;
317 volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43));
319 volScalarField G("RASModel::G", mut_*(gradU && dev(twoSymm(gradU))));
321 // Update espsilon and G at the wall
322 epsilon_.boundaryField().updateCoeffs();
324 // Dissipation equation
325 tmp<fvScalarMatrix> epsEqn
327 fvm::ddt(rho_, epsilon_)
328 + fvm::div(phi_, epsilon_)
329 - fvm::laplacian(DepsilonEff(), epsilon_)
331 C1*rho_*magS*epsilon_
334 C2_*rho_*epsilon_/(k_ + sqrt((mu()/rho_)*epsilon_)),
341 epsEqn().boundaryManipulate(epsilon_.boundaryField());
344 bound(epsilon_, epsilon0_);
347 // Turbulent kinetic energy equation
349 tmp<fvScalarMatrix> kEqn
353 - fvm::laplacian(DkEff(), k_)
355 G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
356 - fvm::Sp(rho_*(epsilon_)/k_, k_)
363 // Re-calculate viscosity
364 mut_ = rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_;
365 mut_.correctBoundaryConditions();
367 // Re-calculate thermal diffusivity
369 alphat_.correctBoundaryConditions();
373 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375 } // End namespace RASModels
376 } // End namespace compressible
377 } // End namespace Foam
379 // ************************************************************************* //