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 "RNGkEpsilon.H"
27 #include "addToRunTimeSelectionTable.H"
29 #include "backwardsCompatibilityWallFunctions.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace incompressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(RNGkEpsilon, 0);
43 addToRunTimeSelectionTable(RASModel, RNGkEpsilon, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 RNGkEpsilon::RNGkEpsilon
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
96 dimensioned<scalar>::lookupOrAddToDict
105 dimensioned<scalar>::lookupOrAddToDict
114 dimensioned<scalar>::lookupOrAddToDict
132 autoCreateK("k", mesh_)
144 autoCreateEpsilon("epsilon", mesh_)
156 autoCreateNut("nut", mesh_)
160 bound(epsilon_, epsilonMin_);
162 nut_ = Cmu_*sqr(k_)/epsilon_;
163 nut_.correctBoundaryConditions();
169 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
172 tmp<volSymmTensorField> RNGkEpsilon::R() const
174 return tmp<volSymmTensorField>
176 new volSymmTensorField
186 ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
187 k_.boundaryField().types()
193 tmp<volSymmTensorField> RNGkEpsilon::devReff() const
195 return tmp<volSymmTensorField>
197 new volSymmTensorField
207 -nuEff()*dev(twoSymm(fvc::grad(U_)))
213 tmp<fvVectorMatrix> RNGkEpsilon::divDevReff(volVectorField& U) const
217 - fvm::laplacian(nuEff(), U)
218 - fvc::div(nuEff()*dev(T(fvc::grad(U))))
223 bool RNGkEpsilon::read()
225 if (RASModel::read())
227 Cmu_.readIfPresent(coeffDict());
228 C1_.readIfPresent(coeffDict());
229 C2_.readIfPresent(coeffDict());
230 sigmak_.readIfPresent(coeffDict());
231 sigmaEps_.readIfPresent(coeffDict());
232 eta0_.readIfPresent(coeffDict());
233 beta_.readIfPresent(coeffDict());
244 void RNGkEpsilon::correct()
253 const volScalarField S2(2*magSqr(symm(fvc::grad(U_))));
254 volScalarField G("RASModel::G", nut_*S2);
256 const volScalarField eta(sqrt(S2)*k_/epsilon_);
259 ((eta*(scalar(1) - eta/eta0_))/(scalar(1) + beta_*eta*sqr(eta)))
262 // Update epsilon and G at the wall
263 epsilon_.boundaryField().updateCoeffs();
265 // Dissipation equation
266 tmp<fvScalarMatrix> epsEqn
269 + fvm::div(phi_, epsilon_)
270 - fvm::laplacian(DepsilonEff(), epsilon_)
272 (C1_ - R)*G*epsilon_/k_
273 //- fvm::SuSp(R*G/k_, epsilon_)
274 - fvm::Sp(C2_*epsilon_/k_, epsilon_)
279 epsEqn().boundaryManipulate(epsilon_.boundaryField());
282 bound(epsilon_, epsilonMin_);
285 // Turbulent kinetic energy equation
287 tmp<fvScalarMatrix> kEqn
291 - fvm::laplacian(DkEff(), k_)
293 G - fvm::Sp(epsilon_/k_, k_)
301 // Re-calculate viscosity
302 nut_ = Cmu_*sqr(k_)/epsilon_;
303 nut_.correctBoundaryConditions();
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 } // End namespace RASModels
310 } // End namespace incompressible
311 } // End namespace Foam
313 // ************************************************************************* //