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 #include "wallDistReflection.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace compressible
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
44 defineTypeNameAndDebug(LaunderGibsonRSTM, 0);
45 addToRunTimeSelectionTable(RASModel, LaunderGibsonRSTM, dictionary);
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 LaunderGibsonRSTM::LaunderGibsonRSTM
52 const volScalarField& rho,
53 const volVectorField& U,
54 const surfaceScalarField& phi,
55 basicThermo& thermophysicalModel
58 RASModel(typeName, rho, U, phi, thermophysicalModel),
62 dimensioned<scalar>::lookupOrAddToDict
71 dimensioned<scalar>::lookupOrAddToDict
80 dimensioned<scalar>::lookupOrAddToDict
89 dimensioned<scalar>::lookupOrAddToDict
98 dimensioned<scalar>::lookupOrAddToDict
107 dimensioned<scalar>::lookupOrAddToDict
116 dimensioned<scalar>::lookupOrAddToDict
125 dimensioned<scalar>::lookupOrAddToDict
134 dimensioned<scalar>::lookupOrAddToDict
143 dimensioned<scalar>::lookupOrAddToDict
152 dimensioned<scalar>::lookupOrAddToDict
161 dimensioned<scalar>::lookupOrAddToDict
170 dimensioned<scalar>::lookupOrAddToDict
229 Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_)
232 # include "wallViscosityI.H"
234 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
238 "LaunderGibsonRSTM::LaunderGibsonRSTM"
239 "(const volScalarField&, const volVectorField&"
240 ", const surfaceScalarField&, basicThermo&)"
241 ) << "couplingFactor = " << couplingFactor_
242 << " is not in range 0 - 1" << nl
250 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
252 tmp<volSymmTensorField> LaunderGibsonRSTM::devRhoReff() const
254 return tmp<volSymmTensorField>
256 new volSymmTensorField
266 rho_*R_ - mu()*dev(twoSymm(fvc::grad(U_)))
272 tmp<fvVectorMatrix> LaunderGibsonRSTM::divDevRhoReff(volVectorField& U) const
274 if (couplingFactor_.value() > 0.0)
278 fvc::div(rho_*R_ + couplingFactor_*mut_*fvc::grad(U))
279 + fvc::laplacian((1.0 - couplingFactor_)*mut_, U)
280 - fvm::laplacian(muEff(), U)
281 - fvc::div(mu()*dev2(fvc::grad(U)().T()))
289 + fvc::laplacian(mut_, U)
290 - fvm::laplacian(muEff(), U)
291 - fvc::div(mu()*dev2(fvc::grad(U)().T()))
297 bool LaunderGibsonRSTM::read()
299 if (RASModel::read())
301 Cmu_.readIfPresent(coeffDict_);
302 Clg1_.readIfPresent(coeffDict_);
303 Clg2_.readIfPresent(coeffDict_);
304 C1_.readIfPresent(coeffDict_);
305 C2_.readIfPresent(coeffDict_);
306 Cs_.readIfPresent(coeffDict_);
307 Ceps_.readIfPresent(coeffDict_);
308 C1Ref_.readIfPresent(coeffDict_);
309 C2Ref_.readIfPresent(coeffDict_);
310 alphaR_.readIfPresent(coeffDict_);
311 alphaEps_.readIfPresent(coeffDict_);
312 alphah_.readIfPresent(coeffDict_);
314 couplingFactor_.readIfPresent(coeffDict_);
316 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
318 FatalErrorIn("LaunderGibsonRSTM::read()")
319 << "couplingFactor = " << couplingFactor_
320 << " is not in range 0 - 1" << nl
333 void LaunderGibsonRSTM::correct()
337 // Re-calculate viscosity
338 mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
344 if (mesh_.changing())
349 volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
350 volScalarField G = 0.5*mag(tr(P));
352 # include "wallFunctionsI.H"
354 // Dissipation equation
355 tmp<fvScalarMatrix> epsEqn
357 fvm::ddt(rho_, epsilon_)
358 + fvm::div(phi_, epsilon_)
359 //- fvm::laplacian(Ceps*rho_*(k_/epsilon_)*R_, epsilon_)
360 - fvm::laplacian(DepsilonEff(), epsilon_)
362 C1_*rho_*G*epsilon_/k_
363 - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_)
368 # include "wallDissipationI.H"
371 bound(epsilon_, epsilon0_);
374 // Reynolds stress equation
376 const fvPatchList& patches = mesh_.boundary();
378 forAll(patches, patchi)
380 const fvPatch& curPatch = patches[patchi];
382 if (typeid(curPatch) == typeid(wallFvPatch))
384 forAll(curPatch, facei)
386 label faceCelli = curPatch.faceCells()[facei];
388 min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 100.0);
393 volSymmTensorField reflect = C1Ref_*epsilon_/k_*R_ - C2Ref_*Clg2_*dev(P);
395 tmp<fvSymmTensorMatrix> REqn
399 //- fvm::laplacian(Cs*rho_*(k_/epsilon_)*R_, R_)
400 - fvm::laplacian(DREff(), R_)
401 + fvm::Sp(Clg1_*rho_*epsilon_/k_, R_)
404 + (2.0/3.0*(Clg1_ - 1)*I)*rho_*epsilon_
407 // wall reflection terms
410 I*((y_.n() & reflect) & y_.n())
411 - 1.5*(y_.n()*(reflect & y_.n())
412 + (y_.n() & reflect)*y_.n())
413 )*pow(Cmu_, 0.75)*rho_*pow(k_, 1.5)/(kappa_*y_*epsilon_)
421 dimensionedSymmTensor
427 k0_.value(), -GREAT, -GREAT,
438 // Re-calculate turbulent viscosity
439 mut_ = Cmu_*rho_*sqr(k_)/epsilon_;
442 # include "wallViscosityI.H"
445 // Correct wall shear stresses
447 forAll(patches, patchi)
449 const fvPatch& curPatch = patches[patchi];
451 if (typeid(curPatch) == typeid(wallFvPatch))
453 symmTensorField& Rw = R_.boundaryField()[patchi];
455 const scalarField& mutw = mut_.boundaryField()[patchi];
456 const scalarField& rhow = rho_.boundaryField()[patchi];
458 vectorField snGradU = U_.boundaryField()[patchi].snGrad();
460 const vectorField& faceAreas
461 = mesh_.Sf().boundaryField()[patchi];
463 const scalarField& magFaceAreas
464 = mesh_.magSf().boundaryField()[patchi];
466 forAll(curPatch, facei)
468 // Calculate near-wall velocity gradient
470 = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
472 // Calculate near-wall shear-stress tensor
473 tensor tauw = -(mutw[facei]/rhow[facei])*2*dev(symm(gradUw));
475 // Reset the shear components of the stress tensor
476 Rw[facei].xy() = tauw.xy();
477 Rw[facei].xz() = tauw.xz();
478 Rw[facei].yz() = tauw.yz();
485 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
487 } // End namespace RASModels
488 } // End namespace compressible
489 } // End namespace Foam
491 // ************************************************************************* //