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 \*---------------------------------------------------------------------------*/
28 #include "addToRunTimeSelectionTable.H"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace compressible
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(kEpsilon, 0);
44 addToRunTimeSelectionTable(RASModel, kEpsilon, dictionary);
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 const volScalarField& rho,
51 const volVectorField& U,
52 const surfaceScalarField& phi,
53 const basicThermo& thermophysicalModel
56 RASModel(typeName, rho, U, phi, thermophysicalModel),
60 dimensioned<scalar>::lookupOrAddToDict
69 dimensioned<scalar>::lookupOrAddToDict
78 dimensioned<scalar>::lookupOrAddToDict
87 dimensioned<scalar>::lookupOrAddToDict
96 dimensioned<scalar>::lookupOrAddToDict
105 dimensioned<scalar>::lookupOrAddToDict
114 dimensioned<scalar>::lookupOrAddToDict
132 autoCreateK("k", mesh_)
144 autoCreateEpsilon("epsilon", mesh_)
156 autoCreateMut("mut", mesh_)
168 autoCreateAlphat("alphat", mesh_)
171 mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
172 mut_.correctBoundaryConditions();
175 alphat_.correctBoundaryConditions();
181 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
183 tmp<volSymmTensorField> kEpsilon::R() const
185 return tmp<volSymmTensorField>
187 new volSymmTensorField
197 ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
198 k_.boundaryField().types()
204 tmp<volSymmTensorField> kEpsilon::devRhoReff() const
206 return tmp<volSymmTensorField>
208 new volSymmTensorField
218 -muEff()*dev(twoSymm(fvc::grad(U_)))
224 tmp<fvVectorMatrix> kEpsilon::divDevRhoReff(volVectorField& U) const
228 - fvm::laplacian(muEff(), U)
229 - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
234 bool kEpsilon::read()
236 if (RASModel::read())
238 Cmu_.readIfPresent(coeffDict());
239 C1_.readIfPresent(coeffDict());
240 C2_.readIfPresent(coeffDict());
241 C3_.readIfPresent(coeffDict());
242 sigmak_.readIfPresent(coeffDict());
243 sigmaEps_.readIfPresent(coeffDict());
244 Prt_.readIfPresent(coeffDict());
255 void kEpsilon::correct()
259 // Re-calculate viscosity
260 mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
261 mut_.correctBoundaryConditions();
263 // Re-calculate thermal diffusivity
265 alphat_.correctBoundaryConditions();
272 volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
276 divU += fvc::div(mesh_.phi());
279 tmp<volTensorField> tgradU = fvc::grad(U_);
280 volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
283 // Update espsilon and G at the wall
284 epsilon_.boundaryField().updateCoeffs();
286 // Dissipation equation
287 tmp<fvScalarMatrix> epsEqn
289 fvm::ddt(rho_, epsilon_)
290 + fvm::div(phi_, epsilon_)
291 - fvm::laplacian(DepsilonEff(), epsilon_)
294 - fvm::SuSp(((2.0/3.0)*C1_ + C3_)*rho_*divU, epsilon_)
295 - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_)
300 epsEqn().boundaryManipulate(epsilon_.boundaryField());
303 bound(epsilon_, epsilon0_);
306 // Turbulent kinetic energy equation
308 tmp<fvScalarMatrix> kEqn
312 - fvm::laplacian(DkEff(), k_)
315 - fvm::SuSp((2.0/3.0)*rho_*divU, k_)
316 - fvm::Sp(rho_*epsilon_/k_, k_)
324 // Re-calculate viscosity
325 mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
326 mut_.correctBoundaryConditions();
328 // Re-calculate thermal diffusivity
330 alphat_.correctBoundaryConditions();
334 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 } // End namespace RASModels
337 } // End namespace compressible
338 } // End namespace Foam
340 // ************************************************************************* //