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 \*---------------------------------------------------------------------------*/
27 #include "addToRunTimeSelectionTable.H"
29 #include "backwardsCompatibilityWallFunctions.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace compressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(kEpsilon, 0);
43 addToRunTimeSelectionTable(RASModel, kEpsilon, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 const volScalarField& rho,
50 const volVectorField& U,
51 const surfaceScalarField& phi,
52 const basicThermo& thermophysicalModel,
53 const word& turbulenceModelName,
57 RASModel(modelName, rho, U, phi, thermophysicalModel, turbulenceModelName),
61 dimensioned<scalar>::lookupOrAddToDict
70 dimensioned<scalar>::lookupOrAddToDict
79 dimensioned<scalar>::lookupOrAddToDict
88 dimensioned<scalar>::lookupOrAddToDict
97 dimensioned<scalar>::lookupOrAddToDict
106 dimensioned<scalar>::lookupOrAddToDict
115 dimensioned<scalar>::lookupOrAddToDict
133 autoCreateK("k", mesh_)
145 autoCreateEpsilon("epsilon", mesh_)
157 autoCreateMut("mut", mesh_)
169 autoCreateAlphat("alphat", mesh_)
173 bound(epsilon_, epsilonMin_);
175 mut_ = Cmu_*rho_*sqr(k_)/epsilon_;
176 mut_.correctBoundaryConditions();
179 alphat_.correctBoundaryConditions();
185 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
187 tmp<volSymmTensorField> kEpsilon::R() const
189 return tmp<volSymmTensorField>
191 new volSymmTensorField
201 ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
202 k_.boundaryField().types()
208 tmp<volSymmTensorField> kEpsilon::devRhoReff() const
210 return tmp<volSymmTensorField>
212 new volSymmTensorField
222 -muEff()*dev(twoSymm(fvc::grad(U_)))
228 tmp<fvVectorMatrix> kEpsilon::divDevRhoReff(volVectorField& U) const
232 - fvm::laplacian(muEff(), U)
233 - fvc::div(muEff()*dev2(T(fvc::grad(U))))
238 bool kEpsilon::read()
240 if (RASModel::read())
242 Cmu_.readIfPresent(coeffDict());
243 C1_.readIfPresent(coeffDict());
244 C2_.readIfPresent(coeffDict());
245 C3_.readIfPresent(coeffDict());
246 sigmak_.readIfPresent(coeffDict());
247 sigmaEps_.readIfPresent(coeffDict());
248 Prt_.readIfPresent(coeffDict());
259 void kEpsilon::correct()
263 // Re-calculate viscosity
264 mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
265 mut_.correctBoundaryConditions();
267 // Re-calculate thermal diffusivity
269 alphat_.correctBoundaryConditions();
276 volScalarField divU(fvc::div(phi_/fvc::interpolate(rho_)));
280 divU += fvc::div(mesh_.phi());
283 tmp<volTensorField> tgradU = fvc::grad(U_);
284 volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
287 // Update epsilon and G at the wall
288 epsilon_.boundaryField().updateCoeffs();
290 // Dissipation equation
291 tmp<fvScalarMatrix> epsEqn
293 fvm::ddt(rho_, epsilon_)
294 + fvm::div(phi_, epsilon_)
295 - fvm::laplacian(DepsilonEff(), epsilon_)
298 - fvm::SuSp(((2.0/3.0)*C1_ + C3_)*rho_*divU, epsilon_)
299 - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_)
304 epsEqn().boundaryManipulate(epsilon_.boundaryField());
307 bound(epsilon_, epsilonMin_);
310 // Turbulent kinetic energy equation
312 tmp<fvScalarMatrix> kEqn
316 - fvm::laplacian(DkEff(), k_)
319 - fvm::SuSp((2.0/3.0)*rho_*divU, k_)
320 - fvm::Sp(rho_*epsilon_/k_, k_)
328 // Re-calculate viscosity
329 mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
330 mut_.correctBoundaryConditions();
332 // Re-calculate thermal diffusivity
334 alphat_.correctBoundaryConditions();
338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 } // End namespace RASModels
341 } // End namespace compressible
342 } // End namespace Foam
344 // ************************************************************************* //