1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "LaunderGibsonRSTM.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "wallFvPatch.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace incompressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(LaunderGibsonRSTM, 0);
43 addToRunTimeSelectionTable(RASModel, LaunderGibsonRSTM, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 LaunderGibsonRSTM::LaunderGibsonRSTM
50 const volVectorField& U,
51 const surfaceScalarField& phi,
52 transportModel& lamTransportModel
55 RASModel(typeName, U, phi, lamTransportModel),
59 dimensioned<scalar>::lookupOrAddToDict
68 dimensioned<scalar>::lookupOrAddToDict
77 dimensioned<scalar>::lookupOrAddToDict
86 dimensioned<scalar>::lookupOrAddToDict
95 dimensioned<scalar>::lookupOrAddToDict
104 dimensioned<scalar>::lookupOrAddToDict
113 dimensioned<scalar>::lookupOrAddToDict
122 dimensioned<scalar>::lookupOrAddToDict
131 dimensioned<scalar>::lookupOrAddToDict
140 dimensioned<scalar>::lookupOrAddToDict
149 dimensioned<scalar>::lookupOrAddToDict
158 dimensioned<scalar>::lookupOrAddToDict
207 nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_))
209 # include "wallViscosityI.H"
211 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
215 "LaunderGibsonRSTM::LaunderGibsonRSTM"
216 "(const volVectorField& U, const surfaceScalarField& phi,"
217 "transportModel& lamTransportModel)"
218 ) << "couplingFactor = " << couplingFactor_
219 << " is not in range 0 - 1" << nl
227 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
229 tmp<volSymmTensorField> LaunderGibsonRSTM::devReff() const
231 return tmp<volSymmTensorField>
233 new volSymmTensorField
243 R_ - nu()*dev(twoSymm(fvc::grad(U_)))
249 tmp<fvVectorMatrix> LaunderGibsonRSTM::divDevReff(volVectorField& U) const
251 if (couplingFactor_.value() > 0.0)
255 fvc::div(R_ + couplingFactor_*nut_*fvc::grad(U), "div(R)")
256 + fvc::laplacian((1.0-couplingFactor_)*nut_, U, "laplacian(nuEff,U)")
257 - fvm::laplacian(nuEff(), U)
265 + fvc::laplacian(nut_, U, "laplacian(nuEff,U)")
266 - fvm::laplacian(nuEff(), U)
272 bool LaunderGibsonRSTM::read()
274 if (RASModel::read())
276 Cmu_.readIfPresent(coeffDict_);
277 Clg1_.readIfPresent(coeffDict_);
278 Clg2_.readIfPresent(coeffDict_);
279 C1_.readIfPresent(coeffDict_);
280 C2_.readIfPresent(coeffDict_);
281 Cs_.readIfPresent(coeffDict_);
282 Ceps_.readIfPresent(coeffDict_);
283 alphaR_.readIfPresent(coeffDict_);
284 alphaEps_.readIfPresent(coeffDict_);
285 C1Ref_.readIfPresent(coeffDict_);
286 C2Ref_.readIfPresent(coeffDict_);
288 couplingFactor_.readIfPresent(coeffDict_);
290 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
292 FatalErrorIn("LaunderGibsonRSTM::read()")
293 << "couplingFactor = " << couplingFactor_
294 << " is not in range 0 - 1"
307 void LaunderGibsonRSTM::correct()
309 transportModel_.correct();
318 if (mesh_.changing())
323 volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
324 volScalarField G = 0.5*tr(P);
326 # include "wallFunctionsI.H"
328 // Dissipation equation
329 tmp<fvScalarMatrix> epsEqn
332 + fvm::div(phi_, epsilon_)
333 //- fvm::laplacian(Ceps*(k_/epsilon_)*R_, epsilon_)
334 - fvm::laplacian(DepsilonEff(), epsilon_)
337 - fvm::Sp(C2_*epsilon_/k_, epsilon_)
342 # include "wallDissipationI.H"
345 bound(epsilon_, epsilon0_);
348 // Reynolds stress equation
350 const fvPatchList& patches = mesh_.boundary();
352 forAll(patches, patchi)
354 const fvPatch& curPatch = patches[patchi];
356 if (typeid(curPatch) == typeid(wallFvPatch))
358 forAll(curPatch, facei)
360 label faceCelli = curPatch.faceCells()[facei];
362 min(G[faceCelli]/(0.5*tr(P[faceCelli]) + SMALL), 1.0);
367 volSymmTensorField reflect = C1Ref_*epsilon_/k_*R_ - C2Ref_*Clg2_*dev(P);
369 tmp<fvSymmTensorMatrix> REqn
373 //- fvm::laplacian(Cs*(k_/epsilon_)*R_, R_)
374 - fvm::laplacian(DREff(), R_)
375 + fvm::Sp(Clg1_*epsilon_/k_, R_)
378 + (2.0/3.0*(Clg1_ - 1)*I)*epsilon_
381 // wall reflection terms
384 I*((yr_.n() & reflect) & yr_.n())
385 - 1.5*(yr_.n()*(reflect & yr_.n())
386 + (yr_.n() & reflect)*yr_.n())
387 )*pow(Cmu_, 0.75)*pow(k_, 1.5)/(kappa_*yr_*epsilon_)
395 dimensionedSymmTensor
401 k0_.value(), -GREAT, -GREAT,
412 // Re-calculate turbulent viscosity
413 nut_ = Cmu_*sqr(k_)/epsilon_;
416 # include "wallViscosityI.H"
419 // Correct wall shear stresses
421 forAll(patches, patchi)
423 const fvPatch& curPatch = patches[patchi];
425 if (typeid(curPatch) == typeid(wallFvPatch))
427 symmTensorField& Rw = R_.boundaryField()[patchi];
429 const scalarField& nutw = nut_.boundaryField()[patchi];
431 vectorField snGradU = U_.boundaryField()[patchi].snGrad();
433 const vectorField& faceAreas
434 = mesh_.Sf().boundaryField()[patchi];
436 const scalarField& magFaceAreas
437 = mesh_.magSf().boundaryField()[patchi];
439 forAll(curPatch, facei)
441 // Calculate near-wall velocity gradient
443 = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
445 // Calculate near-wall shear-stress tensor
446 tensor tauw = -nutw[facei]*2*symm(gradUw);
448 // Reset the shear components of the stress tensor
449 Rw[facei].xy() = tauw.xy();
450 Rw[facei].xz() = tauw.xz();
451 Rw[facei].yz() = tauw.yz();
458 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
460 } // End namespace RASModels
461 } // End namespace incompressible
462 } // End namespace Foam
464 // ************************************************************************* //