1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace incompressible
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(LaunderGibsonRSTM, 0);
44 addToRunTimeSelectionTable(RASModel, LaunderGibsonRSTM, dictionary);
46 // * * * * * * * * * * * * * * * * 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
167 dimensioned<scalar>::lookupOrAddToDict
187 autoCreateR("R", mesh_)
199 autoCreateK("k", mesh_)
211 autoCreateEpsilon("epsilon", mesh_)
223 autoCreateNut("nut", mesh_)
226 nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
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 volScalarField G("RASModel::G", 0.5*mag(tr(P)));
350 // Update epsilon and G at the wall
351 epsilon_.boundaryField().updateCoeffs();
353 // Dissipation equation
354 tmp<fvScalarMatrix> epsEqn
357 + fvm::div(phi_, epsilon_)
358 + fvm::SuSp(-fvc::div(phi_), epsilon_)
359 //- fvm::laplacian(Ceps*(k_/epsilon_)*R_, epsilon_)
360 - fvm::laplacian(DepsilonEff(), epsilon_)
363 - fvm::Sp(C2_*epsilon_/k_, epsilon_)
368 epsEqn().boundaryManipulate(epsilon_.boundaryField());
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 (curPatch.isWall())
384 forAll(curPatch, facei)
386 label faceCelli = curPatch.faceCells()[facei];
388 min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 1.0);
393 volSymmTensorField reflect = C1Ref_*epsilon_/k_*R_ - C2Ref_*Clg2_*dev(P);
395 tmp<fvSymmTensorMatrix> REqn
399 + fvm::SuSp(-fvc::div(phi_), R_)
400 //- fvm::laplacian(Cs*(k_/epsilon_)*R_, R_)
401 - fvm::laplacian(DREff(), R_)
402 + fvm::Sp(Clg1_*epsilon_/k_, R_)
405 + (2.0/3.0*(Clg1_ - 1)*I)*epsilon_
408 // wall reflection terms
411 I*((yr_.n() & reflect) & yr_.n())
412 - 1.5*(yr_.n()*(reflect & yr_.n())
413 + (yr_.n() & reflect)*yr_.n())
414 )*pow(Cmu_, 0.75)*pow(k_, 1.5)/(kappa_*yr_*epsilon_)
422 dimensionedSymmTensor
428 k0_.value(), -GREAT, -GREAT,
439 // Re-calculate turbulent viscosity
440 nut_ = Cmu_*sqr(k_)/epsilon_;
441 nut_.correctBoundaryConditions();
444 // Correct wall shear stresses
446 forAll(patches, patchi)
448 const fvPatch& curPatch = patches[patchi];
450 if (curPatch.isWall())
452 symmTensorField& Rw = R_.boundaryField()[patchi];
454 const scalarField& nutw = nut_.boundaryField()[patchi];
456 vectorField snGradU = U_.boundaryField()[patchi].snGrad();
458 const vectorField& faceAreas
459 = mesh_.Sf().boundaryField()[patchi];
461 const scalarField& magFaceAreas
462 = mesh_.magSf().boundaryField()[patchi];
464 forAll(curPatch, facei)
466 // Calculate near-wall velocity gradient
468 = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
470 // Calculate near-wall shear-stress tensor
471 tensor tauw = -nutw[facei]*2*symm(gradUw);
473 // Reset the shear components of the stress tensor
474 Rw[facei].xy() = tauw.xy();
475 Rw[facei].xz() = tauw.xz();
476 Rw[facei].yz() = tauw.yz();
483 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
485 } // End namespace RASModels
486 } // End namespace incompressible
487 } // End namespace Foam
489 // ************************************************************************* //