1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-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 \*---------------------------------------------------------------------------*/
26 #include "kOmegaSST.H"
27 #include "addToRunTimeSelectionTable.H"
29 #include "backwardsCompatibilityWallFunctions.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace compressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(kOmegaSST, 0);
43 addToRunTimeSelectionTable(RASModel, kOmegaSST, dictionary);
45 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
47 tmp<volScalarField> kOmegaSST::F1(const volScalarField& CDkOmega) const
49 volScalarField CDkOmegaPlus = max
52 dimensionedScalar("1.0e-10", dimless/sqr(dimTime), 1.0e-10)
55 volScalarField arg1 = min
61 (scalar(1)/betaStar_)*sqrt(k_)/(omega_*y_),
62 scalar(500)*(mu()/rho_)/(sqr(y_)*omega_)
64 (4*alphaOmega2_)*k_/(CDkOmegaPlus*sqr(y_))
69 return tanh(pow4(arg1));
72 tmp<volScalarField> kOmegaSST::F2() const
74 volScalarField arg2 = min
78 (scalar(2)/betaStar_)*sqrt(k_)/(omega_*y_),
79 scalar(500)*(mu()/rho_)/(sqr(y_)*omega_)
84 return tanh(sqr(arg2));
88 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
92 const volScalarField& rho,
93 const volVectorField& U,
94 const surfaceScalarField& phi,
95 const basicThermo& thermophysicalModel
98 RASModel(typeName, rho, U, phi, thermophysicalModel),
102 dimensioned<scalar>::lookupOrAddToDict
111 dimensioned<scalar>::lookupOrAddToDict
120 dimensioned<scalar>::lookupOrAddToDict
129 dimensioned<scalar>::lookupOrAddToDict
138 dimensioned<scalar>::lookupOrAddToDict
147 dimensioned<scalar>::lookupOrAddToDict
156 dimensioned<scalar>::lookupOrAddToDict
165 dimensioned<scalar>::lookupOrAddToDict
174 dimensioned<scalar>::lookupOrAddToDict
183 dimensioned<scalar>::lookupOrAddToDict
192 dimensioned<scalar>::lookupOrAddToDict
201 dimensioned<scalar>::lookupOrAddToDict
221 autoCreateK("k", mesh_)
233 autoCreateOmega("omega", mesh_)
245 autoCreateMut("mut", mesh_)
257 autoCreateAlphat("alphat", mesh_)
260 bound(omega_, omega0_);
268 F2()*sqrt(2.0*magSqr(symm(fvc::grad(U_))))
271 mut_.correctBoundaryConditions();
274 alphat_.correctBoundaryConditions();
280 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
282 tmp<volSymmTensorField> kOmegaSST::R() const
284 return tmp<volSymmTensorField>
286 new volSymmTensorField
296 ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
297 k_.boundaryField().types()
303 tmp<volSymmTensorField> kOmegaSST::devRhoReff() const
305 return tmp<volSymmTensorField>
307 new volSymmTensorField
317 -muEff()*dev(twoSymm(fvc::grad(U_)))
323 tmp<fvVectorMatrix> kOmegaSST::divDevRhoReff(volVectorField& U) const
327 - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
332 bool kOmegaSST::read()
334 if (RASModel::read())
336 alphaK1_.readIfPresent(coeffDict());
337 alphaK2_.readIfPresent(coeffDict());
338 alphaOmega1_.readIfPresent(coeffDict());
339 alphaOmega2_.readIfPresent(coeffDict());
340 Prt_.readIfPresent(coeffDict());
341 gamma1_.readIfPresent(coeffDict());
342 gamma2_.readIfPresent(coeffDict());
343 beta1_.readIfPresent(coeffDict());
344 beta2_.readIfPresent(coeffDict());
345 betaStar_.readIfPresent(coeffDict());
346 a1_.readIfPresent(coeffDict());
347 c1_.readIfPresent(coeffDict());
358 void kOmegaSST::correct()
362 // Re-calculate viscosity
365 /max(a1_*omega_, F2()*sqrt(2.0*magSqr(symm(fvc::grad(U_)))));
366 mut_.correctBoundaryConditions();
368 // Re-calculate thermal diffusivity
370 alphat_.correctBoundaryConditions();
377 volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
379 if (mesh_.changing())
386 divU += fvc::div(mesh_.phi());
389 tmp<volTensorField> tgradU = fvc::grad(U_);
390 volScalarField S2 = magSqr(symm(tgradU()));
391 volScalarField GbyMu = (tgradU() && dev(twoSymm(tgradU())));
392 volScalarField G("RASModel::G", mut_*GbyMu);
395 // Update omega and G at the wall
396 omega_.boundaryField().updateCoeffs();
398 volScalarField CDkOmega =
399 (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_;
401 volScalarField F1 = this->F1(CDkOmega);
402 volScalarField rhoGammaF1 = rho_*gamma(F1);
404 // Turbulent frequency equation
405 tmp<fvScalarMatrix> omegaEqn
407 fvm::ddt(rho_, omega_)
408 + fvm::div(phi_, omega_)
409 - fvm::laplacian(DomegaEff(F1), omega_)
412 - fvm::SuSp((2.0/3.0)*rhoGammaF1*divU, omega_)
413 - fvm::Sp(rho_*beta(F1)*omega_, omega_)
416 rho_*(F1 - scalar(1))*CDkOmega/omega_,
423 omegaEqn().boundaryManipulate(omega_.boundaryField());
426 bound(omega_, omega0_);
428 // Turbulent kinetic energy equation
429 tmp<fvScalarMatrix> kEqn
433 - fvm::laplacian(DkEff(F1), k_)
435 min(G, (c1_*betaStar_)*rho_*k_*omega_)
436 - fvm::SuSp(2.0/3.0*rho_*divU, k_)
437 - fvm::Sp(rho_*betaStar_*omega_, k_)
445 // Re-calculate viscosity
446 mut_ = a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(2.0*S2));
447 mut_.correctBoundaryConditions();
449 // Re-calculate thermal diffusivity
451 alphat_.correctBoundaryConditions();
455 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
457 } // End namespace RASModels
458 } // End namespace compressible
459 } // End namespace Foam
461 // ************************************************************************* //