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 \*---------------------------------------------------------------------------*/
28 #include "addToRunTimeSelectionTable.H"
29 #include "wallFvPatch.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace incompressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(LRR, 0);
43 addToRunTimeSelectionTable(RASModel, LRR, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
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
178 nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_))
180 # include "wallViscosityI.H"
182 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
187 "(const volVectorField& U, const surfaceScalarField& phi,"
188 "transportModel& lamTransportModel)"
189 ) << "couplingFactor = " << couplingFactor_
190 << " is not in range 0 - 1" << nl
198 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
200 tmp<volSymmTensorField> LRR::devReff() const
202 return tmp<volSymmTensorField>
204 new volSymmTensorField
214 R_ - nu()*dev(twoSymm(fvc::grad(U_)))
220 tmp<fvVectorMatrix> LRR::divDevReff(volVectorField& U) const
222 if (couplingFactor_.value() > 0.0)
226 fvc::div(R_ + couplingFactor_*nut_*fvc::grad(U), "div(R)")
229 (1.0 - couplingFactor_)*nut_,
233 - fvm::laplacian(nuEff(), U)
241 + fvc::laplacian(nut_, U, "laplacian(nuEff,U)")
242 - fvm::laplacian(nuEff(), U)
250 if (RASModel::read())
252 Cmu_.readIfPresent(coeffDict_);
253 Clrr1_.readIfPresent(coeffDict_);
254 Clrr2_.readIfPresent(coeffDict_);
255 C1_.readIfPresent(coeffDict_);
256 C2_.readIfPresent(coeffDict_);
257 Cs_.readIfPresent(coeffDict_);
258 Ceps_.readIfPresent(coeffDict_);
259 alphaEps_.readIfPresent(coeffDict_);
261 couplingFactor_.readIfPresent(coeffDict_);
263 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
265 FatalErrorIn("LRR::read()")
266 << "couplingFactor = " << couplingFactor_
267 << " is not in range 0 - 1"
282 transportModel_.correct();
291 volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
292 volScalarField G = 0.5*mag(tr(P));
294 # include "wallFunctionsI.H"
296 // Dissipation equation
297 tmp<fvScalarMatrix> epsEqn
300 + fvm::div(phi_, epsilon_)
301 - fvm::Sp(fvc::div(phi_), epsilon_)
302 //- fvm::laplacian(Ceps*(K/epsilon_)*R, epsilon_)
303 - fvm::laplacian(DepsilonEff(), epsilon_)
306 - fvm::Sp(C2_*epsilon_/k_, epsilon_)
311 # include "wallDissipationI.H"
314 bound(epsilon_, epsilon0_);
317 // Reynolds stress equation
319 const fvPatchList& patches = mesh_.boundary();
321 forAll(patches, patchi)
323 const fvPatch& curPatch = patches[patchi];
325 if (typeid(curPatch) == typeid(wallFvPatch))
327 forAll(curPatch, facei)
329 label faceCelli = curPatch.faceCells()[facei];
331 *= min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 1.0);
337 tmp<fvSymmTensorMatrix> REqn
341 - fvm::Sp(fvc::div(phi_), R_)
342 //- fvm::laplacian(Cs*(k_/epsilon_)*R_, R_)
343 - fvm::laplacian(DREff(), R_)
344 + fvm::Sp(Clrr1_*epsilon_/k_, R_)
347 - (2.0/3.0*(1 - Clrr1_)*I)*epsilon_
356 dimensionedSymmTensor
362 k0_.value(), -GREAT, -GREAT,
373 // Re-calculate viscosity
374 nut_ = Cmu_*sqr(k_)/epsilon_;
376 # include "wallViscosityI.H"
379 // Correct wall shear stresses
381 forAll(patches, patchi)
383 const fvPatch& curPatch = patches[patchi];
385 if (typeid(curPatch) == typeid(wallFvPatch))
387 symmTensorField& Rw = R_.boundaryField()[patchi];
389 const scalarField& nutw = nut_.boundaryField()[patchi];
391 vectorField snGradU = U_.boundaryField()[patchi].snGrad();
393 const vectorField& faceAreas
394 = mesh_.Sf().boundaryField()[patchi];
396 const scalarField& magFaceAreas
397 = mesh_.magSf().boundaryField()[patchi];
399 forAll(curPatch, facei)
401 // Calculate near-wall velocity gradient
403 = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
405 // Calculate near-wall shear-stress tensor
406 tensor tauw = -nutw[facei]*2*symm(gradUw);
408 // Reset the shear components of the stress tensor
409 Rw[facei].xy() = tauw.xy();
410 Rw[facei].xz() = tauw.xz();
411 Rw[facei].yz() = tauw.yz();
418 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
420 } // End namespace RASModels
421 } // End namespace incompressible
422 } // End namespace Foam
424 // ************************************************************************* //