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 incompressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(kEpsilon, 0);
43 addToRunTimeSelectionTable(RASModel, kEpsilon, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 const volVectorField& U,
50 const surfaceScalarField& phi,
51 transportModel& transport,
52 const word& turbulenceModelName,
56 RASModel(modelName, U, phi, transport, turbulenceModelName),
60 dimensioned<scalar>::lookupOrAddToDict
69 dimensioned<scalar>::lookupOrAddToDict
78 dimensioned<scalar>::lookupOrAddToDict
87 dimensioned<scalar>::lookupOrAddToDict
105 autoCreateK("k", mesh_)
117 autoCreateEpsilon("epsilon", mesh_)
129 autoCreateNut("nut", mesh_)
133 bound(epsilon_, epsilonMin_);
135 nut_ = Cmu_*sqr(k_)/epsilon_;
136 nut_.correctBoundaryConditions();
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 tmp<volSymmTensorField> kEpsilon::R() const
146 return tmp<volSymmTensorField>
148 new volSymmTensorField
158 ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
159 k_.boundaryField().types()
165 tmp<volSymmTensorField> kEpsilon::devReff() const
167 return tmp<volSymmTensorField>
169 new volSymmTensorField
179 -nuEff()*dev(twoSymm(fvc::grad(U_)))
185 tmp<fvVectorMatrix> kEpsilon::divDevReff(volVectorField& U) const
189 - fvm::laplacian(nuEff(), U)
190 - fvc::div(nuEff()*dev(T(fvc::grad(U))))
195 bool kEpsilon::read()
197 if (RASModel::read())
199 Cmu_.readIfPresent(coeffDict());
200 C1_.readIfPresent(coeffDict());
201 C2_.readIfPresent(coeffDict());
202 sigmaEps_.readIfPresent(coeffDict());
213 void kEpsilon::correct()
222 volScalarField G("RASModel::G", nut_*2*magSqr(symm(fvc::grad(U_))));
224 // Update epsilon and G at the wall
225 epsilon_.boundaryField().updateCoeffs();
227 // Dissipation equation
228 tmp<fvScalarMatrix> epsEqn
231 + fvm::div(phi_, epsilon_)
232 - fvm::Sp(fvc::div(phi_), epsilon_)
233 - fvm::laplacian(DepsilonEff(), epsilon_)
236 - fvm::Sp(C2_*epsilon_/k_, epsilon_)
241 epsEqn().boundaryManipulate(epsilon_.boundaryField());
244 bound(epsilon_, epsilonMin_);
247 // Turbulent kinetic energy equation
248 tmp<fvScalarMatrix> kEqn
252 - fvm::Sp(fvc::div(phi_), k_)
253 - fvm::laplacian(DkEff(), k_)
256 - fvm::Sp(epsilon_/k_, k_)
264 // Re-calculate viscosity
265 nut_ = Cmu_*sqr(k_)/epsilon_;
266 nut_.correctBoundaryConditions();
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 } // End namespace RASModels
273 } // End namespace incompressible
274 } // End namespace Foam
276 // ************************************************************************* //