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 "realizableKE.H"
27 #include "addToRunTimeSelectionTable.H"
29 #include "backwardsCompatibilityWallFunctions.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace incompressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(realizableKE, 0);
43 addToRunTimeSelectionTable(RASModel, realizableKE, dictionary);
45 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
47 tmp<volScalarField> realizableKE::rCmu
49 const volTensorField& gradU,
50 const volScalarField& S2,
51 const volScalarField& magS
54 tmp<volSymmTensorField> tS = dev(symm(gradU));
55 const volSymmTensorField& S = tS();
58 (2*sqrt(2.0))*((S&S)&&S)
61 + dimensionedScalar("small", dimensionSet(0, 0, -3, 0, 0), SMALL)
67 (1.0/3.0)*acos(min(max(sqrt(6.0)*W, -scalar(1)), scalar(1)));
68 volScalarField As = sqrt(6.0)*cos(phis);
69 volScalarField Us = sqrt(S2/2.0 + magSqr(skew(gradU)));
71 return 1.0/(A0_ + As*Us*k_/(epsilon_ + epsilonSmall_));
75 tmp<volScalarField> realizableKE::rCmu
77 const volTensorField& gradU
80 volScalarField S2 = 2*magSqr(dev(symm(gradU)));
81 volScalarField magS = sqrt(S2);
82 return rCmu(gradU, S2, magS);
86 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
88 realizableKE::realizableKE
90 const volVectorField& U,
91 const surfaceScalarField& phi,
92 transportModel& lamTransportModel
95 RASModel(typeName, U, phi, lamTransportModel),
99 dimensionedScalar::lookupOrAddToDict
108 dimensionedScalar::lookupOrAddToDict
117 dimensionedScalar::lookupOrAddToDict
126 dimensionedScalar::lookupOrAddToDict
135 dimensionedScalar::lookupOrAddToDict
153 autoCreateK("k", mesh_)
165 autoCreateEpsilon("epsilon", mesh_)
177 autoCreateNut("nut", mesh_)
181 bound(epsilon_, epsilon0_);
183 nut_ = rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_);
184 nut_ = min(nut_, nuRatio()*nu());
185 nut_.correctBoundaryConditions();
191 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
193 tmp<volSymmTensorField> realizableKE::R() const
195 return tmp<volSymmTensorField>
197 new volSymmTensorField
207 ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
208 k_.boundaryField().types()
214 tmp<volSymmTensorField> realizableKE::devReff() const
216 return tmp<volSymmTensorField>
218 new volSymmTensorField
228 -nuEff()*dev(twoSymm(fvc::grad(U_)))
234 tmp<fvVectorMatrix> realizableKE::divDevReff(volVectorField& U) const
238 - fvm::laplacian(nuEff(), U)
239 - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
244 bool realizableKE::read()
246 if (RASModel::read())
248 Cmu_.readIfPresent(coeffDict());
249 A0_.readIfPresent(coeffDict());
250 C2_.readIfPresent(coeffDict());
251 sigmak_.readIfPresent(coeffDict());
252 sigmaEps_.readIfPresent(coeffDict());
263 void realizableKE::correct()
265 // Bound in case of topological change
267 if (mesh_.changing())
270 bound(epsilon_, epsilon0_);
280 volTensorField gradU = fvc::grad(U_);
281 volScalarField S2 = 2*magSqr(dev(symm(gradU)));
282 volScalarField magS = sqrt(S2);
284 volScalarField eta = magS*k_/epsilon_;
285 volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43));
287 volScalarField G("RASModel::G", nut_*S2);
289 // Update epsilon and G at the wall
290 epsilon_.boundaryField().updateCoeffs();
293 // Dissipation equation
294 tmp<fvScalarMatrix> epsEqn
297 + fvm::div(phi_, epsilon_)
298 + fvm::SuSp(-fvc::div(phi_), epsilon_)
299 - fvm::laplacian(DepsilonEff(), epsilon_)
304 C2_*epsilon_/(k_ + sqrt(nu()*epsilon_)),
311 // No longer needed: matrix completes at the point of solution
313 // epsEqn().completeAssembly();
316 bound(epsilon_, epsilon0_);
319 // Turbulent kinetic energy equation
320 tmp<fvScalarMatrix> kEqn
324 + fvm::SuSp(-fvc::div(phi_), k_)
325 - fvm::laplacian(DkEff(), k_)
327 G - fvm::Sp(epsilon_/k_, k_)
335 // Re-calculate viscosity
336 nut_ = rCmu(gradU, S2, magS)*sqr(k_)/epsilon_;
337 nut_ = min(nut_, nuRatio()*nu());
338 nut_.correctBoundaryConditions();
342 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
344 } // End namespace RASModels
345 } // End namespace incompressible
346 } // End namespace Foam
348 // ************************************************************************* //