1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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"
29 #include "wallFvPatch.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace compressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(realizableKE, 0);
43 addToRunTimeSelectionTable(RASModel, realizableKE, dictionary);
45 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
47 tmp<volScalarField> realizableKE::rCmu
49 const volTensorField& gradU,
50 const volScalarField& S2,
51 const volScalarField& magS
54 tmp<volSymmTensorField> tS = dev(symm(gradU));
55 const volSymmTensorField& S = tS();
58 (2*sqrt(2.0))*((S&S)&&S)
61 + dimensionedScalar("small", dimensionSet(0, 0, -3, 0, 0), SMALL)
67 (1.0/3.0)*acos(min(max(sqrt(6.0)*W, -scalar(1)), scalar(1)));
68 volScalarField As = sqrt(6.0)*cos(phis);
69 volScalarField Us = sqrt(S2/2.0 + magSqr(skew(gradU)));
71 return 1.0/(A0_ + As*Us*k_/(epsilon_ + epsilonSmall_));
75 tmp<volScalarField> realizableKE::rCmu
77 const volTensorField& gradU
80 volScalarField S2 = 2*magSqr(dev(symm(gradU)));
81 volScalarField magS = sqrt(S2);
82 return rCmu(gradU, S2, magS);
86 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
88 realizableKE::realizableKE
90 const volScalarField& rho,
91 const volVectorField& U,
92 const surfaceScalarField& phi,
93 basicThermo& thermophysicalModel
96 RASModel(typeName, rho, U, phi, thermophysicalModel),
100 dimensioned<scalar>::lookupOrAddToDict
109 dimensioned<scalar>::lookupOrAddToDict
118 dimensioned<scalar>::lookupOrAddToDict
127 dimensioned<scalar>::lookupOrAddToDict
136 dimensioned<scalar>::lookupOrAddToDict
145 dimensioned<scalar>::lookupOrAddToDict
189 rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_)
193 bound(epsilon_, epsilon0_);
194 # include "wallViscosityI.H"
200 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
202 tmp<volSymmTensorField> realizableKE::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> realizableKE::devRhoReff() const
225 return tmp<volSymmTensorField>
227 new volSymmTensorField
237 -muEff()*dev(twoSymm(fvc::grad(U_)))
243 tmp<fvVectorMatrix> realizableKE::divDevRhoReff(volVectorField& U) const
247 - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
252 bool realizableKE::read()
254 if (RASModel::read())
256 Cmu_.readIfPresent(coeffDict_);
257 A0_.readIfPresent(coeffDict_);
258 C2_.readIfPresent(coeffDict_);
259 alphak_.readIfPresent(coeffDict_);
260 alphaEps_.readIfPresent(coeffDict_);
261 alphah_.readIfPresent(coeffDict_);
272 void realizableKE::correct()
276 // Re-calculate viscosity
277 mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_;
283 volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
287 divU += fvc::div(mesh_.phi());
290 volTensorField gradU = fvc::grad(U_);
291 volScalarField S2 = 2*magSqr(dev(symm(gradU)));
292 volScalarField magS = sqrt(S2);
294 volScalarField eta = magS*k_/epsilon_;
295 volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43));
297 volScalarField G = mut_*(gradU && dev(twoSymm(gradU)));
299 # include "wallFunctionsI.H"
301 // Dissipation equation
302 tmp<fvScalarMatrix> epsEqn
304 fvm::ddt(rho_, epsilon_)
305 + fvm::div(phi_, epsilon_)
306 - fvm::laplacian(DepsilonEff(), epsilon_)
308 C1*rho_*magS*epsilon_
311 C2_*rho_*epsilon_/(k_ + sqrt((mu()/rho_)*epsilon_)),
318 # include "wallDissipationI.H"
321 bound(epsilon_, epsilon0_);
324 // Turbulent kinetic energy equation
326 tmp<fvScalarMatrix> kEqn
330 - fvm::laplacian(DkEff(), k_)
332 G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
333 - fvm::Sp(rho_*(epsilon_)/k_, k_)
340 // Re-calculate viscosity
341 mut_ = rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_;
343 # include "wallViscosityI.H"
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350 } // End namespace RASModels
351 } // End namespace compressible
352 } // End namespace Foam
354 // ************************************************************************* //