1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "realizableKE.H"
27 #include "addToRunTimeSelectionTable.H"
29 #include "backwardsCompatibilityWallFunctions.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();
59 (2*sqrt(2.0))*((S&S)&&S)
62 + dimensionedScalar("small", dimensionSet(0, 0, -3, 0, 0), SMALL)
70 (1.0/3.0)*acos(min(max(sqrt(6.0)*W, -scalar(1)), scalar(1)))
72 volScalarField As(sqrt(6.0)*cos(phis));
73 volScalarField Us(sqrt(S2/2.0 + magSqr(skew(gradU))));
75 return 1.0/(A0_ + As*Us*k_/epsilon_);
79 tmp<volScalarField> realizableKE::rCmu
81 const volTensorField& gradU
84 volScalarField S2(2*magSqr(dev(symm(gradU))));
85 volScalarField magS(sqrt(S2));
86 return rCmu(gradU, S2, magS);
90 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
92 realizableKE::realizableKE
94 const volScalarField& rho,
95 const volVectorField& U,
96 const surfaceScalarField& phi,
97 const basicThermo& thermophysicalModel,
98 const word& turbulenceModelName,
102 RASModel(modelName, rho, U, phi, thermophysicalModel, turbulenceModelName),
106 dimensioned<scalar>::lookupOrAddToDict
115 dimensioned<scalar>::lookupOrAddToDict
124 dimensioned<scalar>::lookupOrAddToDict
133 dimensioned<scalar>::lookupOrAddToDict
142 dimensioned<scalar>::lookupOrAddToDict
151 dimensioned<scalar>::lookupOrAddToDict
169 autoCreateK("k", mesh_)
181 autoCreateEpsilon("epsilon", mesh_)
193 autoCreateMut("mut", mesh_)
205 autoCreateAlphat("alphat", mesh_)
209 bound(epsilon_, epsilonMin_);
211 mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_;
212 mut_.correctBoundaryConditions();
215 alphat_.correctBoundaryConditions();
221 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
223 tmp<volSymmTensorField> realizableKE::R() const
225 return tmp<volSymmTensorField>
227 new volSymmTensorField
237 ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
238 k_.boundaryField().types()
244 tmp<volSymmTensorField> realizableKE::devRhoReff() const
246 return tmp<volSymmTensorField>
248 new volSymmTensorField
258 -muEff()*dev(twoSymm(fvc::grad(U_)))
264 tmp<fvVectorMatrix> realizableKE::divDevRhoReff(volVectorField& U) const
268 - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(T(fvc::grad(U))))
273 bool realizableKE::read()
275 if (RASModel::read())
277 Cmu_.readIfPresent(coeffDict());
278 A0_.readIfPresent(coeffDict());
279 C2_.readIfPresent(coeffDict());
280 sigmak_.readIfPresent(coeffDict());
281 sigmaEps_.readIfPresent(coeffDict());
282 Prt_.readIfPresent(coeffDict());
293 void realizableKE::correct()
297 // Re-calculate viscosity
298 mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_;
299 mut_.correctBoundaryConditions();
301 // Re-calculate thermal diffusivity
303 alphat_.correctBoundaryConditions();
310 volScalarField divU(fvc::div(phi_/fvc::interpolate(rho_)));
314 divU += fvc::div(mesh_.phi());
317 volTensorField gradU(fvc::grad(U_));
318 volScalarField S2(2*magSqr(dev(symm(gradU))));
319 volScalarField magS(sqrt(S2));
321 volScalarField eta(magS*k_/epsilon_);
322 volScalarField C1(max(eta/(scalar(5) + eta), scalar(0.43)));
324 volScalarField G("RASModel::G", mut_*(gradU && dev(twoSymm(gradU))));
326 // Update epsilon and G at the wall
327 epsilon_.boundaryField().updateCoeffs();
329 // Dissipation equation
330 tmp<fvScalarMatrix> epsEqn
332 fvm::ddt(rho_, epsilon_)
333 + fvm::div(phi_, epsilon_)
334 - fvm::laplacian(DepsilonEff(), epsilon_)
336 C1*rho_*magS*epsilon_
339 C2_*rho_*epsilon_/(k_ + sqrt((mu()/rho_)*epsilon_)),
346 epsEqn().boundaryManipulate(epsilon_.boundaryField());
349 bound(epsilon_, epsilonMin_);
352 // Turbulent kinetic energy equation
354 tmp<fvScalarMatrix> kEqn
358 - fvm::laplacian(DkEff(), k_)
360 G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
361 - fvm::Sp(rho_*epsilon_/k_, k_)
368 // Re-calculate viscosity
369 mut_ = rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_;
370 mut_.correctBoundaryConditions();
372 // Re-calculate thermal diffusivity
374 alphat_.correctBoundaryConditions();
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380 } // End namespace RASModels
381 } // End namespace compressible
382 } // End namespace Foam
384 // ************************************************************************* //