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 incompressible
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 volVectorField& U,
91 const surfaceScalarField& phi,
92 transportModel& lamTransportModel
95 RASModel(typeName, U, phi, lamTransportModel),
99 dimensioned<scalar>::lookupOrAddToDict
108 dimensioned<scalar>::lookupOrAddToDict
117 dimensioned<scalar>::lookupOrAddToDict
126 dimensioned<scalar>::lookupOrAddToDict
135 dimensioned<scalar>::lookupOrAddToDict
169 nut_(rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_))
172 bound(epsilon_, epsilon0_);
173 # include "wallViscosityI.H"
179 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
181 tmp<volSymmTensorField> realizableKE::R() const
183 return tmp<volSymmTensorField>
185 new volSymmTensorField
195 ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
196 k_.boundaryField().types()
202 tmp<volSymmTensorField> realizableKE::devReff() const
204 return tmp<volSymmTensorField>
206 new volSymmTensorField
216 -nuEff()*dev(twoSymm(fvc::grad(U_)))
222 tmp<fvVectorMatrix> realizableKE::divDevReff(volVectorField& U) const
226 - fvm::laplacian(nuEff(), U)
227 - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
232 bool realizableKE::read()
234 if (RASModel::read())
236 Cmu_.readIfPresent(coeffDict_);
237 A0_.readIfPresent(coeffDict_);
238 C2_.readIfPresent(coeffDict_);
239 alphak_.readIfPresent(coeffDict_);
240 alphaEps_.readIfPresent(coeffDict_);
251 void realizableKE::correct()
253 transportModel_.correct();
262 volTensorField gradU = fvc::grad(U_);
263 volScalarField S2 = 2*magSqr(dev(symm(gradU)));
264 volScalarField magS = sqrt(S2);
266 volScalarField eta = magS*k_/epsilon_;
267 volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43));
269 volScalarField G = nut_*S2;
271 # include "wallFunctionsI.H"
274 // Dissipation equation
275 tmp<fvScalarMatrix> epsEqn
278 + fvm::div(phi_, epsilon_)
279 - fvm::Sp(fvc::div(phi_), epsilon_)
280 - fvm::laplacian(DepsilonEff(), epsilon_)
285 C2_*epsilon_/(k_ + sqrt(nu()*epsilon_)),
292 # include "wallDissipationI.H"
295 bound(epsilon_, epsilon0_);
298 // Turbulent kinetic energy equation
299 tmp<fvScalarMatrix> kEqn
303 - fvm::Sp(fvc::div(phi_), k_)
304 - fvm::laplacian(DkEff(), k_)
306 G - fvm::Sp(epsilon_/k_, k_)
314 // Re-calculate viscosity
315 nut_ = rCmu(gradU, S2, magS)*sqr(k_)/epsilon_;
317 # include "wallViscosityI.H"
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
324 } // End namespace RASModels
325 } // End namespace incompressible
326 } // End namespace Foam
328 // ************************************************************************* //