1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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& lamTransportModel
54 RASModel(typeName, U, phi, lamTransportModel),
58 dimensionedScalar::lookupOrAddToDict
67 dimensionedScalar::lookupOrAddToDict
76 dimensionedScalar::lookupOrAddToDict
85 dimensionedScalar::lookupOrAddToDict
94 dimensionedScalar::lookupOrAddToDict
103 dimensionedScalar::lookupOrAddToDict
112 dimensionedScalar::lookupOrAddToDict
130 autoCreateK("k", mesh_)
142 autoCreateEpsilon("epsilon", mesh_)
154 autoCreateNut("nut", mesh_)
157 nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
158 nut_ = min(nut_, nuRatio()*nu());
159 nut_.correctBoundaryConditions();
165 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
168 tmp<volSymmTensorField> RNGkEpsilon::R() const
170 return tmp<volSymmTensorField>
172 new volSymmTensorField
182 ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
183 k_.boundaryField().types()
189 tmp<volSymmTensorField> RNGkEpsilon::devReff() const
191 return tmp<volSymmTensorField>
193 new volSymmTensorField
203 -nuEff()*dev(twoSymm(fvc::grad(U_)))
209 tmp<fvVectorMatrix> RNGkEpsilon::divDevReff(volVectorField& U) const
213 - fvm::laplacian(nuEff(), U)
214 - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
219 bool RNGkEpsilon::read()
221 if (RASModel::read())
223 Cmu_.readIfPresent(coeffDict());
224 C1_.readIfPresent(coeffDict());
225 C2_.readIfPresent(coeffDict());
226 sigmak_.readIfPresent(coeffDict());
227 sigmaEps_.readIfPresent(coeffDict());
228 eta0_.readIfPresent(coeffDict());
229 beta_.readIfPresent(coeffDict());
240 void RNGkEpsilon::correct()
242 // Bound in case of topological change
244 if (mesh_.changing())
247 bound(epsilon_, epsilon0_);
257 volScalarField S2 = 2*magSqr(symm(fvc::grad(U_)));
259 volScalarField G("RASModel::G", nut_*S2);
261 volScalarField eta = sqrt(S2)*k_/epsilon_;
263 ((eta*(scalar(1) - eta/eta0_))/(scalar(1) + beta_*eta*sqr(eta)));
265 // Update epsilon and G at the wall
266 epsilon_.boundaryField().updateCoeffs();
268 // Dissipation equation
269 tmp<fvScalarMatrix> epsEqn
272 + fvm::div(phi_, epsilon_)
273 + fvm::SuSp(-fvc::div(phi_), epsilon_)
274 - fvm::laplacian(DepsilonEff(), epsilon_)
276 (C1_ - R)*G*epsilon_/k_
277 //- fvm::SuSp(R*G/k_, epsilon_)
278 - fvm::Sp(C2_*epsilon_/k_, epsilon_)
283 // No longer needed: matrix completes at the point of solution
285 // epsEqn().completeAssembly();
288 bound(epsilon_, epsilon0_);
291 // Turbulent kinetic energy equation
293 tmp<fvScalarMatrix> kEqn
297 + fvm::SuSp(-fvc::div(phi_), k_)
298 - fvm::laplacian(DkEff(), k_)
300 G - fvm::Sp(epsilon_/k_, k_)
308 // Re-calculate viscosity
309 nut_ = Cmu_*sqr(k_)/epsilon_;
310 nut_ = min(nut_, nuRatio()*nu());
311 nut_.correctBoundaryConditions();
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 } // End namespace RASModels
318 } // End namespace incompressible
319 } // End namespace Foam
321 // ************************************************************************* //