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 incompressible
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 volVectorField& U,
92 const surfaceScalarField& phi,
93 transportModel& lamTransportModel
96 RASModel(typeName, U, phi, lamTransportModel),
100 dimensioned<scalar>::lookupOrAddToDict
109 dimensioned<scalar>::lookupOrAddToDict
118 dimensioned<scalar>::lookupOrAddToDict
127 dimensioned<scalar>::lookupOrAddToDict
136 dimensioned<scalar>::lookupOrAddToDict
154 autoCreateK("k", mesh_)
166 autoCreateEpsilon("epsilon", mesh_)
178 autoCreateNut("nut", mesh_)
182 bound(epsilon_, epsilon0_);
184 nut_ = rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_);
185 nut_.correctBoundaryConditions();
191 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
193 tmp<volSymmTensorField> realizableKE::R() const
195 return tmp<volSymmTensorField>
197 new volSymmTensorField
207 ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
208 k_.boundaryField().types()
214 tmp<volSymmTensorField> realizableKE::devReff() const
216 return tmp<volSymmTensorField>
218 new volSymmTensorField
228 -nuEff()*dev(twoSymm(fvc::grad(U_)))
234 tmp<fvVectorMatrix> realizableKE::divDevReff(volVectorField& U) const
238 - fvm::laplacian(nuEff(), U)
239 - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
244 bool realizableKE::read()
246 if (RASModel::read())
248 Cmu_.readIfPresent(coeffDict());
249 A0_.readIfPresent(coeffDict());
250 C2_.readIfPresent(coeffDict());
251 sigmak_.readIfPresent(coeffDict());
252 sigmaEps_.readIfPresent(coeffDict());
263 void realizableKE::correct()
272 volTensorField gradU = fvc::grad(U_);
273 volScalarField S2 = 2*magSqr(dev(symm(gradU)));
274 volScalarField magS = sqrt(S2);
276 volScalarField eta = magS*k_/epsilon_;
277 volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43));
279 volScalarField G("RASModel::G", nut_*S2);
281 // Update espsilon and G at the wall
282 epsilon_.boundaryField().updateCoeffs();
285 // Dissipation equation
286 tmp<fvScalarMatrix> epsEqn
289 + fvm::div(phi_, epsilon_)
290 - fvm::Sp(fvc::div(phi_), epsilon_)
291 - fvm::laplacian(DepsilonEff(), epsilon_)
296 C2_*epsilon_/(k_ + sqrt(nu()*epsilon_)),
303 epsEqn().boundaryManipulate(epsilon_.boundaryField());
306 bound(epsilon_, epsilon0_);
309 // Turbulent kinetic energy equation
310 tmp<fvScalarMatrix> kEqn
314 - fvm::Sp(fvc::div(phi_), k_)
315 - fvm::laplacian(DkEff(), k_)
317 G - fvm::Sp(epsilon_/k_, k_)
325 // Re-calculate viscosity
326 nut_ = rCmu(gradU, S2, magS)*sqr(k_)/epsilon_;
327 nut_.correctBoundaryConditions();
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
333 } // End namespace RASModels
334 } // End namespace incompressible
335 } // End namespace Foam
337 // ************************************************************************* //