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 \*---------------------------------------------------------------------------*/
28 #include "addToRunTimeSelectionTable.H"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace incompressible
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(LRR, 0);
44 addToRunTimeSelectionTable(RASModel, LRR, dictionary);
46 // * * * * * * * * * * * * * * * * 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
149 autoCreateR("R", mesh_)
161 autoCreateK("k", mesh_)
173 autoCreateEpsilon("epsilon", mesh_)
185 autoCreateNut("nut", mesh_)
188 nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
189 nut_.correctBoundaryConditions();
191 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
196 "(const volVectorField& U, const surfaceScalarField& phi,"
197 "transportModel& lamTransportModel)"
198 ) << "couplingFactor = " << couplingFactor_
199 << " is not in range 0 - 1" << nl
207 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
209 tmp<volSymmTensorField> LRR::devReff() const
211 return tmp<volSymmTensorField>
213 new volSymmTensorField
223 R_ - nu()*dev(twoSymm(fvc::grad(U_)))
229 tmp<fvVectorMatrix> LRR::divDevReff(volVectorField& U) const
231 if (couplingFactor_.value() > 0.0)
235 fvc::div(R_ + couplingFactor_*nut_*fvc::grad(U), "div(R)")
238 (1.0 - couplingFactor_)*nut_,
242 - fvm::laplacian(nuEff(), U)
250 + fvc::laplacian(nut_, U, "laplacian(nuEff,U)")
251 - fvm::laplacian(nuEff(), U)
259 if (RASModel::read())
261 Cmu_.readIfPresent(coeffDict());
262 Clrr1_.readIfPresent(coeffDict());
263 Clrr2_.readIfPresent(coeffDict());
264 C1_.readIfPresent(coeffDict());
265 C2_.readIfPresent(coeffDict());
266 Cs_.readIfPresent(coeffDict());
267 Ceps_.readIfPresent(coeffDict());
268 sigmaEps_.readIfPresent(coeffDict());
270 couplingFactor_.readIfPresent(coeffDict());
272 if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
274 FatalErrorIn("LRR::read()")
275 << "couplingFactor = " << couplingFactor_
276 << " is not in range 0 - 1"
298 volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
299 volScalarField G("RASModel::G", 0.5*mag(tr(P)));
301 // Update espsilon and G at the wall
302 epsilon_.boundaryField().updateCoeffs();
304 // Dissipation equation
305 tmp<fvScalarMatrix> epsEqn
308 + fvm::div(phi_, epsilon_)
309 + fvm::SuSp(-fvc::div(phi_), epsilon_)
310 //- fvm::laplacian(Ceps*(K/epsilon_)*R, epsilon_)
311 - fvm::laplacian(DepsilonEff(), epsilon_)
314 - fvm::Sp(C2_*epsilon_/k_, epsilon_)
319 epsEqn().boundaryManipulate(epsilon_.boundaryField());
322 bound(epsilon_, epsilon0_);
325 // Reynolds stress equation
327 const fvPatchList& patches = mesh_.boundary();
329 forAll(patches, patchi)
331 const fvPatch& curPatch = patches[patchi];
333 if (curPatch.isWall())
335 forAll(curPatch, facei)
337 label faceCelli = curPatch.faceCells()[facei];
339 *= min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 1.0);
345 tmp<fvSymmTensorMatrix> REqn
349 + fvm::SuSp(-fvc::div(phi_), R_)
350 //- fvm::laplacian(Cs*(k_/epsilon_)*R_, R_)
351 - fvm::laplacian(DREff(), R_)
352 + fvm::Sp(Clrr1_*epsilon_/k_, R_)
355 - (2.0/3.0*(1 - Clrr1_)*I)*epsilon_
364 dimensionedSymmTensor
370 k0_.value(), -GREAT, -GREAT,
381 // Re-calculate viscosity
382 nut_ = Cmu_*sqr(k_)/epsilon_;
383 nut_.correctBoundaryConditions();
386 // Correct wall shear stresses
388 forAll(patches, patchi)
390 const fvPatch& curPatch = patches[patchi];
392 if (curPatch.isWall())
394 symmTensorField& Rw = R_.boundaryField()[patchi];
396 const scalarField& nutw = nut_.boundaryField()[patchi];
398 vectorField snGradU = U_.boundaryField()[patchi].snGrad();
400 const vectorField& faceAreas
401 = mesh_.Sf().boundaryField()[patchi];
403 const scalarField& magFaceAreas
404 = mesh_.magSf().boundaryField()[patchi];
406 forAll(curPatch, facei)
408 // Calculate near-wall velocity gradient
410 = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
412 // Calculate near-wall shear-stress tensor
413 tensor tauw = -nutw[facei]*2*symm(gradUw);
415 // Reset the shear components of the stress tensor
416 Rw[facei].xy() = tauw.xy();
417 Rw[facei].xz() = tauw.xz();
418 Rw[facei].yz() = tauw.yz();
425 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
427 } // End namespace RASModels
428 } // End namespace incompressible
429 } // End namespace Foam
431 // ************************************************************************* //