1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-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 \*---------------------------------------------------------------------------*/
27 #include "addToRunTimeSelectionTable.H"
28 #include "wallFvPatch.H"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace compressible
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(LRR, 0);
44 addToRunTimeSelectionTable(RASModel, LRR, dictionary);
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 const volScalarField& rho,
51 const volVectorField& U,
52 const surfaceScalarField& phi,
53 const basicThermo& thermophysicalModel,
54 const word& turbulenceModelName,
58 RASModel(modelName, rho, U, phi, thermophysicalModel, turbulenceModelName),
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
170 autoCreateR("R", mesh_)
182 autoCreateK("k", mesh_)
194 autoCreateEpsilon("epsilon", mesh_)
206 autoCreateMut("mut", mesh_)
218 autoCreateAlphat("alphat", mesh_)
221 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
226 "( const volScalarField&, const volVectorField&"
227 ", const surfaceScalarField&, incompressibleTransportModel&)"
228 ) << "couplingFactor = " << couplingFactor_
229 << " is not in range 0 - 1" << nl
234 bound(epsilon_, epsilonMin_);
236 mut_ = Cmu_*rho_*sqr(k_)/epsilon_;
237 mut_.correctBoundaryConditions();
240 alphat_.correctBoundaryConditions();
246 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
248 tmp<volSymmTensorField> LRR::devRhoReff() const
250 return tmp<volSymmTensorField>
252 new volSymmTensorField
262 rho_*R_ - mu()*dev(twoSymm(fvc::grad(U_)))
268 tmp<fvVectorMatrix> LRR::divDevRhoReff(volVectorField& U) const
270 if (couplingFactor_.value() > 0.0)
274 fvc::div(rho_*R_ + couplingFactor_*mut_*fvc::grad(U))
275 + fvc::laplacian((1.0 - couplingFactor_)*mut_, U)
276 - fvm::laplacian(muEff(), U)
277 - fvc::div(mu()*dev2(T(fvc::grad(U))))
285 + fvc::laplacian(mut_, U)
286 - fvm::laplacian(muEff(), U)
287 - fvc::div(mu()*dev2(T(fvc::grad(U))))
295 if (RASModel::read())
297 Cmu_.readIfPresent(coeffDict());
298 Clrr1_.readIfPresent(coeffDict());
299 Clrr2_.readIfPresent(coeffDict());
300 C1_.readIfPresent(coeffDict());
301 C2_.readIfPresent(coeffDict());
302 Cs_.readIfPresent(coeffDict());
303 Ceps_.readIfPresent(coeffDict());
304 sigmaR_.readIfPresent(coeffDict());
305 sigmaEps_.readIfPresent(coeffDict());
306 Prt_.readIfPresent(coeffDict());
307 couplingFactor_.readIfPresent(coeffDict());
309 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
311 FatalErrorIn("LRR::read()")
312 << "couplingFactor = " << couplingFactor_
313 << " is not in range 0 - 1" << nl
330 // Re-calculate viscosity
331 mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
332 mut_.correctBoundaryConditions();
334 // Re-calculate thermal diffusivity
336 alphat_.correctBoundaryConditions();
343 volSymmTensorField P(-twoSymm(R_ & fvc::grad(U_)));
344 volScalarField G("RASModel::G", 0.5*mag(tr(P)));
346 // Update epsilon and G at the wall
347 epsilon_.boundaryField().updateCoeffs();
349 // Dissipation equation
350 tmp<fvScalarMatrix> epsEqn
352 fvm::ddt(rho_, epsilon_)
353 + fvm::div(phi_, epsilon_)
354 //- fvm::laplacian(Ceps*rho_*(k_/epsilon_)*R_, epsilon_)
355 - fvm::laplacian(DepsilonEff(), epsilon_)
357 C1_*rho_*G*epsilon_/k_
358 - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_)
363 epsEqn().boundaryManipulate(epsilon_.boundaryField());
366 bound(epsilon_, epsilonMin_);
369 // Reynolds stress equation
371 const fvPatchList& patches = mesh_.boundary();
373 forAll(patches, patchi)
375 const fvPatch& curPatch = patches[patchi];
377 if (isA<wallFvPatch>(curPatch))
379 forAll(curPatch, facei)
381 label faceCelli = curPatch.faceCells()[facei];
384 G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL),
392 tmp<fvSymmTensorMatrix> REqn
396 //- fvm::laplacian(Cs*rho_*(k_/epsilon_)*R_, R_)
397 - fvm::laplacian(DREff(), R_)
398 + fvm::Sp(Clrr1_*rho_*epsilon_/k_, R_)
401 - (2.0/3.0*(1 - Clrr1_)*I)*rho_*epsilon_
410 dimensionedSymmTensor
416 kMin_.value(), -GREAT, -GREAT,
417 kMin_.value(), -GREAT,
427 // Re-calculate viscosity
428 mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
429 mut_.correctBoundaryConditions();
431 // Re-calculate thermal diffusivity
433 alphat_.correctBoundaryConditions();
436 // Correct wall shear stresses
438 forAll(patches, patchi)
440 const fvPatch& curPatch = patches[patchi];
442 if (isA<wallFvPatch>(curPatch))
444 symmTensorField& Rw = R_.boundaryField()[patchi];
446 const scalarField& rhow = rho_.boundaryField()[patchi];
447 const scalarField& mutw = mut_.boundaryField()[patchi];
449 const vectorField snGradU(U_.boundaryField()[patchi].snGrad());
451 const vectorField& faceAreas
452 = mesh_.Sf().boundaryField()[patchi];
454 const scalarField& magFaceAreas
455 = mesh_.magSf().boundaryField()[patchi];
457 forAll(curPatch, facei)
459 // Calculate near-wall velocity gradient
461 = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
463 // Calculate near-wall shear-stress tensor
464 tensor tauw = -(mutw[facei]/rhow[facei])*2*dev(symm(gradUw));
466 // Reset the shear components of the stress tensor
467 Rw[facei].xy() = tauw.xy();
468 Rw[facei].xz() = tauw.xz();
469 Rw[facei].yz() = tauw.yz();
476 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
478 } // End namespace RASModels
479 } // End namespace compressible
480 } // End namespace Foam
482 // ************************************************************************* //