1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "addToRunTimeSelectionTable.H"
29 #include "backwardsCompatibilityWallFunctions.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace incompressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(LRR, 0);
43 addToRunTimeSelectionTable(RASModel, LRR, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 const volVectorField& U,
50 const surfaceScalarField& phi,
51 transportModel& lamTransportModel
54 RASModel(typeName, U, phi, lamTransportModel),
58 dimensionedScalar::lookupOrAddToDict
67 dimensionedScalar::lookupOrAddToDict
76 dimensionedScalar::lookupOrAddToDict
85 dimensionedScalar::lookupOrAddToDict
94 dimensionedScalar::lookupOrAddToDict
103 dimensionedScalar::lookupOrAddToDict
112 dimensionedScalar::lookupOrAddToDict
121 dimensionedScalar::lookupOrAddToDict
130 dimensionedScalar::lookupOrAddToDict
148 autoCreateR("R", mesh_)
160 autoCreateK("k", mesh_)
172 autoCreateEpsilon("epsilon", mesh_)
184 autoCreateNut("nut", mesh_)
187 nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
188 nut_ = min(nut_, nuRatio()*nu());
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"
291 // Bound in case of topological change
293 if (mesh_.changing())
295 R_.correctBoundaryConditions();
296 bound(epsilon_, epsilon0_);
306 volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
307 volScalarField G("RASModel::G", 0.5*mag(tr(P)));
309 // Update epsilon and G at the wall
310 epsilon_.boundaryField().updateCoeffs();
312 // Dissipation equation
313 tmp<fvScalarMatrix> epsEqn
316 + fvm::div(phi_, epsilon_)
317 + fvm::SuSp(-fvc::div(phi_), epsilon_)
318 //- fvm::laplacian(Ceps*(K/epsilon_)*R, epsilon_)
319 - fvm::laplacian(DepsilonEff(), epsilon_)
322 - fvm::Sp(C2_*epsilon_/k_, epsilon_)
327 // No longer needed: matrix completes at the point of solution
329 // epsEqn().completeAssembly();
332 bound(epsilon_, epsilon0_);
335 // Reynolds stress equation
337 const fvPatchList& patches = mesh_.boundary();
339 forAll(patches, patchi)
341 const fvPatch& curPatch = patches[patchi];
343 if (curPatch.isWall())
345 forAll(curPatch, facei)
347 label faceCelli = curPatch.faceCells()[facei];
352 G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL),
360 tmp<fvSymmTensorMatrix> REqn
364 + fvm::SuSp(-fvc::div(phi_), R_)
365 //- fvm::laplacian(Cs*(k_/epsilon_)*R_, R_)
366 - fvm::laplacian(DREff(), R_)
367 + fvm::Sp(Clrr1_*epsilon_/k_, R_)
370 - (2.0/3.0*(1 - Clrr1_)*I)*epsilon_
379 dimensionedSymmTensor
385 k0_.value(), -GREAT, -GREAT,
396 // Re-calculate viscosity
397 nut_ = Cmu_*sqr(k_)/epsilon_;
398 nut_ = min(nut_, nuRatio()*nu());
399 nut_.correctBoundaryConditions();
402 // Correct wall shear stresses
404 forAll(patches, patchi)
406 const fvPatch& curPatch = patches[patchi];
408 if (curPatch.isWall())
410 symmTensorField& Rw = R_.boundaryField()[patchi];
412 const scalarField& nutw = nut_.boundaryField()[patchi];
414 vectorField snGradU = U_.boundaryField()[patchi].snGrad();
416 const vectorField& faceAreas
417 = mesh_.Sf().boundaryField()[patchi];
419 const scalarField& magFaceAreas
420 = mesh_.magSf().boundaryField()[patchi];
422 forAll(curPatch, facei)
424 // Calculate near-wall velocity gradient
426 = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
428 // Calculate near-wall shear-stress tensor
429 tensor tauw = -nutw[facei]*2*symm(gradUw);
431 // Reset the shear components of the stress tensor
432 Rw[facei].xy() = tauw.xy();
433 Rw[facei].xz() = tauw.xz();
434 Rw[facei].yz() = tauw.yz();
441 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
443 } // End namespace RASModels
444 } // End namespace incompressible
445 } // End namespace Foam
447 // ************************************************************************* //