1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "LaunderGibsonRSTM.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "wallFvPatch.H"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace compressible
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(LaunderGibsonRSTM, 0);
44 addToRunTimeSelectionTable(RASModel, LaunderGibsonRSTM, dictionary);
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 LaunderGibsonRSTM::LaunderGibsonRSTM
50 const volScalarField& rho,
51 const volVectorField& U,
52 const surfaceScalarField& phi,
53 const basicThermo& thermophysicalModel
56 RASModel(typeName, rho, U, phi, thermophysicalModel),
60 dimensioned<scalar>::lookupOrAddToDict
69 dimensioned<scalar>::lookupOrAddToDict
78 dimensioned<scalar>::lookupOrAddToDict
87 dimensioned<scalar>::lookupOrAddToDict
96 dimensioned<scalar>::lookupOrAddToDict
105 dimensioned<scalar>::lookupOrAddToDict
114 dimensioned<scalar>::lookupOrAddToDict
123 dimensioned<scalar>::lookupOrAddToDict
132 dimensioned<scalar>::lookupOrAddToDict
141 dimensioned<scalar>::lookupOrAddToDict
150 dimensioned<scalar>::lookupOrAddToDict
159 dimensioned<scalar>::lookupOrAddToDict
168 dimensioned<scalar>::lookupOrAddToDict
177 dimensioned<scalar>::lookupOrAddToDict
197 autoCreateR("R", mesh_)
209 autoCreateK("k", mesh_)
221 autoCreateEpsilon("epsilon", mesh_)
233 autoCreateMut("mut", mesh_)
245 autoCreateAlphat("alphat", mesh_)
248 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
252 "LaunderGibsonRSTM::LaunderGibsonRSTM"
253 "(const volScalarField&, const volVectorField&"
254 ", const surfaceScalarField&, basicThermo&)"
255 ) << "couplingFactor = " << couplingFactor_
256 << " is not in range 0 - 1" << nl
260 mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
261 mut_.correctBoundaryConditions();
264 alphat_.correctBoundaryConditions();
270 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
272 tmp<volSymmTensorField> LaunderGibsonRSTM::devRhoReff() const
274 return tmp<volSymmTensorField>
276 new volSymmTensorField
286 rho_*R_ - mu()*dev(twoSymm(fvc::grad(U_)))
292 tmp<fvVectorMatrix> LaunderGibsonRSTM::divDevRhoReff(volVectorField& U) const
294 if (couplingFactor_.value() > 0.0)
298 fvc::div(rho_*R_ + couplingFactor_*mut_*fvc::grad(U))
299 + fvc::laplacian((1.0 - couplingFactor_)*mut_, U)
300 - fvm::laplacian(muEff(), U)
301 - fvc::div(mu()*dev2(fvc::grad(U)().T()))
309 + fvc::laplacian(mut_, U)
310 - fvm::laplacian(muEff(), U)
311 - fvc::div(mu()*dev2(fvc::grad(U)().T()))
317 bool LaunderGibsonRSTM::read()
319 if (RASModel::read())
321 Cmu_.readIfPresent(coeffDict());
322 kappa_.readIfPresent(coeffDict());
323 Clg1_.readIfPresent(coeffDict());
324 Clg2_.readIfPresent(coeffDict());
325 C1_.readIfPresent(coeffDict());
326 C2_.readIfPresent(coeffDict());
327 Cs_.readIfPresent(coeffDict());
328 Ceps_.readIfPresent(coeffDict());
329 C1Ref_.readIfPresent(coeffDict());
330 C2Ref_.readIfPresent(coeffDict());
331 sigmaR_.readIfPresent(coeffDict());
332 sigmaEps_.readIfPresent(coeffDict());
333 Prt_.readIfPresent(coeffDict());
335 couplingFactor_.readIfPresent(coeffDict());
337 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
339 FatalErrorIn("LaunderGibsonRSTM::read()")
340 << "couplingFactor = " << couplingFactor_
341 << " is not in range 0 - 1" << nl
354 void LaunderGibsonRSTM::correct()
358 // Re-calculate viscosity
359 mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
360 mut_.correctBoundaryConditions();
362 // Re-calculate thermal diffusivity
364 alphat_.correctBoundaryConditions();
371 if (mesh_.changing())
376 volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
377 volScalarField G("RASModel::G", 0.5*mag(tr(P)));
379 // Update espsilon and G at the wall
380 epsilon_.boundaryField().updateCoeffs();
382 // Dissipation equation
383 tmp<fvScalarMatrix> epsEqn
385 fvm::ddt(rho_, epsilon_)
386 + fvm::div(phi_, epsilon_)
387 //- fvm::laplacian(Ceps*rho_*(k_/epsilon_)*R_, epsilon_)
388 - fvm::laplacian(DepsilonEff(), epsilon_)
390 C1_*rho_*G*epsilon_/k_
391 - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_)
396 epsEqn().boundaryManipulate(epsilon_.boundaryField());
399 bound(epsilon_, epsilon0_);
402 // Reynolds stress equation
404 const fvPatchList& patches = mesh_.boundary();
406 forAll(patches, patchi)
408 const fvPatch& curPatch = patches[patchi];
410 if (isA<wallFvPatch>(curPatch))
412 forAll(curPatch, facei)
414 label faceCelli = curPatch.faceCells()[facei];
416 min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 100.0);
421 volSymmTensorField reflect = C1Ref_*epsilon_/k_*R_ - C2Ref_*Clg2_*dev(P);
423 tmp<fvSymmTensorMatrix> REqn
427 //- fvm::laplacian(Cs*rho_*(k_/epsilon_)*R_, R_)
428 - fvm::laplacian(DREff(), R_)
429 + fvm::Sp(Clg1_*rho_*epsilon_/k_, R_)
432 + (2.0/3.0*(Clg1_ - 1)*I)*rho_*epsilon_
435 // wall reflection terms
438 I*((y_.n() & reflect) & y_.n())
439 - 1.5*(y_.n()*(reflect & y_.n())
440 + (y_.n() & reflect)*y_.n())
441 )*pow(Cmu_, 0.75)*rho_*pow(k_, 1.5)/(kappa_*y_*epsilon_)
449 dimensionedSymmTensor
455 k0_.value(), -GREAT, -GREAT,
466 // Re-calculate turbulent viscosity
467 mut_ = Cmu_*rho_*sqr(k_)/epsilon_;
468 mut_.correctBoundaryConditions();
470 // Re-calculate thermal diffusivity
472 alphat_.correctBoundaryConditions();
474 // Correct wall shear stresses
476 forAll(patches, patchi)
478 const fvPatch& curPatch = patches[patchi];
480 if (isA<wallFvPatch>(curPatch))
482 symmTensorField& Rw = R_.boundaryField()[patchi];
484 const scalarField& mutw = mut_.boundaryField()[patchi];
485 const scalarField& rhow = rho_.boundaryField()[patchi];
487 vectorField snGradU = U_.boundaryField()[patchi].snGrad();
489 const vectorField& faceAreas
490 = mesh_.Sf().boundaryField()[patchi];
492 const scalarField& magFaceAreas
493 = mesh_.magSf().boundaryField()[patchi];
495 forAll(curPatch, facei)
497 // Calculate near-wall velocity gradient
499 = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
501 // Calculate near-wall shear-stress tensor
502 tensor tauw = -(mutw[facei]/rhow[facei])*2*dev(symm(gradUw));
504 // Reset the shear components of the stress tensor
505 Rw[facei].xy() = tauw.xy();
506 Rw[facei].xz() = tauw.xz();
507 Rw[facei].yz() = tauw.yz();
514 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
516 } // End namespace RASModels
517 } // End namespace compressible
518 } // End namespace Foam
520 // ************************************************************************* //