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 "LaunderGibsonRSTM.H"
27 #include "addToRunTimeSelectionTable.H"
29 #include "backwardsCompatibilityWallFunctions.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace incompressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(LaunderGibsonRSTM, 0);
43 addToRunTimeSelectionTable(RASModel, LaunderGibsonRSTM, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 LaunderGibsonRSTM::LaunderGibsonRSTM
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
121 dimensionedScalar::lookupOrAddToDict
130 dimensionedScalar::lookupOrAddToDict
139 dimensionedScalar::lookupOrAddToDict
148 dimensionedScalar::lookupOrAddToDict
157 dimensionedScalar::lookupOrAddToDict
166 dimensionedScalar::lookupOrAddToDict
186 autoCreateR("R", mesh_)
198 autoCreateK("k", mesh_)
210 autoCreateEpsilon("epsilon", mesh_)
222 autoCreateNut("nut", mesh_)
225 nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
226 nut_ = min(nut_, nuRatio()*nu());
227 nut_.correctBoundaryConditions();
229 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
233 "LaunderGibsonRSTM::LaunderGibsonRSTM"
234 "(const volVectorField& U, const surfaceScalarField& phi,"
235 "transportModel& lamTransportModel)"
236 ) << "couplingFactor = " << couplingFactor_
237 << " is not in range 0 - 1" << nl
245 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
247 tmp<volSymmTensorField> LaunderGibsonRSTM::devReff() const
249 return tmp<volSymmTensorField>
251 new volSymmTensorField
261 R_ - nu()*dev(twoSymm(fvc::grad(U_)))
267 tmp<fvVectorMatrix> LaunderGibsonRSTM::divDevReff(volVectorField& U) const
269 if (couplingFactor_.value() > 0.0)
273 fvc::div(R_ + couplingFactor_*nut_*fvc::grad(U), "div(R)")
274 + fvc::laplacian((1.0-couplingFactor_)*nut_, U, "laplacian(nuEff,U)")
275 - fvm::laplacian(nuEff(), U)
283 + fvc::laplacian(nut_, U, "laplacian(nuEff,U)")
284 - fvm::laplacian(nuEff(), U)
290 bool LaunderGibsonRSTM::read()
292 if (RASModel::read())
294 Cmu_.readIfPresent(coeffDict());
295 Clg1_.readIfPresent(coeffDict());
296 Clg2_.readIfPresent(coeffDict());
297 C1_.readIfPresent(coeffDict());
298 C2_.readIfPresent(coeffDict());
299 Cs_.readIfPresent(coeffDict());
300 Ceps_.readIfPresent(coeffDict());
301 sigmaR_.readIfPresent(coeffDict());
302 sigmaEps_.readIfPresent(coeffDict());
303 C1Ref_.readIfPresent(coeffDict());
304 C2Ref_.readIfPresent(coeffDict());
306 couplingFactor_.readIfPresent(coeffDict());
308 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
310 FatalErrorIn("LaunderGibsonRSTM::read()")
311 << "couplingFactor = " << couplingFactor_
312 << " is not in range 0 - 1"
325 void LaunderGibsonRSTM::correct()
327 // Bound in case of topological change
329 if (mesh_.changing())
331 R_.correctBoundaryConditions();
332 bound(epsilon_, epsilon0_);
342 if (mesh_.changing())
347 volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
348 volSymmTensorField C = -fvc::div(phi_, R_);
349 volScalarField G("RASModel::G", 0.5*mag(tr(P)));
351 // Update epsilon and G at the wall
352 epsilon_.boundaryField().updateCoeffs();
354 // Dissipation equation
355 tmp<fvScalarMatrix> epsEqn
358 + fvm::div(phi_, epsilon_)
359 + fvm::SuSp(-fvc::div(phi_), epsilon_)
360 //- fvm::laplacian(Ceps*(k_/epsilon_)*R_, epsilon_)
361 - fvm::laplacian(DepsilonEff(), epsilon_)
364 - fvm::Sp(C2_*epsilon_/k_, epsilon_)
369 // No longer needed: matrix completes at the point of solution
371 // epsEqn().completeAssembly();
374 bound(epsilon_, epsilon0_);
377 // Reynolds stress equation
379 const fvPatchList& patches = mesh_.boundary();
381 forAll(patches, patchi)
383 const fvPatch& curPatch = patches[patchi];
385 if (curPatch.isWall())
387 forAll(curPatch, facei)
389 label faceCelli = curPatch.faceCells()[facei];
391 min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 1.0);
396 volSymmTensorField reflect = C1Ref_*epsilon_/k_*R_ - C2Ref_*Clg2_*dev(P);
398 tmp<fvSymmTensorMatrix> REqn
402 + fvm::SuSp(-fvc::div(phi_), R_)
403 //- fvm::laplacian(Cs*(k_/epsilon_)*R_, R_)
404 - fvm::laplacian(DREff(), R_)
405 + fvm::Sp(Clg1_*epsilon_/k_, R_)
408 + (2.0/3.0*(Clg1_ - 1)*I)*epsilon_
409 // Change for consistency with Fluent implementation.
410 // Emil Baric, NUMAP-FOAM 2011
412 - Clg2_*(dev(P) - dev(C))
414 // wall reflection terms
417 I*((yr_.n() & reflect) & yr_.n())
418 - 1.5*(yr_.n()*(reflect & yr_.n())
419 + (yr_.n() & reflect)*yr_.n())
420 )*pow(Cmu_, 0.75)*pow(k_, 1.5)/(kappa_*yr_*epsilon_)
428 dimensionedSymmTensor
434 k0_.value(), -GREAT, -GREAT,
445 // Re-calculate turbulent viscosity
446 nut_ = Cmu_*sqr(k_)/epsilon_;
447 nut_ = min(nut_, nuRatio()*nu());
448 nut_.correctBoundaryConditions();
451 // Correct wall shear stresses. Moved to wall functions with anisotropy
456 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
458 } // End namespace RASModels
459 } // End namespace incompressible
460 } // End namespace Foam
462 // ************************************************************************* //