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 \*---------------------------------------------------------------------------*/
26 #include "coupledKOmegaSST.H"
27 #include "fvBlockMatrix.H"
28 #include "addToRunTimeSelectionTable.H"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace incompressible
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(coupledKOmegaSST, 0);
44 addToRunTimeSelectionTable(RASModel, coupledKOmegaSST, dictionary);
46 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
48 tmp<volScalarField> coupledKOmegaSST::F1(const volScalarField& CDkOmega) const
50 volScalarField CDkOmegaPlus = max
53 dimensionedScalar("1.0e-10", dimless/sqr(dimTime), 1.0e-10)
56 volScalarField arg1 = min
62 (scalar(1)/betaStar_)*sqrt(k_)/(omega_*y_),
63 scalar(500)*nu()/(sqr(y_)*omega_)
65 (4*alphaOmega2_)*k_/(CDkOmegaPlus*sqr(y_))
70 return tanh(pow4(arg1));
73 tmp<volScalarField> coupledKOmegaSST::F2() const
75 volScalarField arg2 = min
79 (scalar(2)/betaStar_)*sqrt(k_)/(omega_*y_),
80 scalar(500)*nu()/(sqr(y_)*omega_)
85 return tanh(sqr(arg2));
89 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91 coupledKOmegaSST::coupledKOmegaSST
93 const volVectorField& U,
94 const surfaceScalarField& phi,
95 transportModel& lamTransportModel
98 RASModel(typeName, U, phi, lamTransportModel),
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
212 autoCreateK("k", mesh_, U_.db())
224 autoCreateOmega("omega", mesh_, U_.db())
236 autoCreateNut("nut", mesh_, U_.db())
249 dimensionedVector2("zero", dimless, vector2::zero)
252 bound(omega_, omega0_);
254 nut_ = a1_*k_/max(a1_*omega_, F2()*sqrt(2.0)*mag(symm(fvc::grad(U_))));
255 nut_.correctBoundaryConditions();
261 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
263 tmp<volSymmTensorField> coupledKOmegaSST::R() const
265 return tmp<volSymmTensorField>
267 new volSymmTensorField
277 ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
278 k_.boundaryField().types()
284 tmp<volSymmTensorField> coupledKOmegaSST::devReff() const
286 return tmp<volSymmTensorField>
288 new volSymmTensorField
298 -nuEff()*dev(twoSymm(fvc::grad(U_)))
304 tmp<fvVectorMatrix> coupledKOmegaSST::divDevReff(volVectorField& U) const
308 - fvm::laplacian(nuEff(), U)
309 - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
314 bool coupledKOmegaSST::read()
316 if (RASModel::read())
318 alphaK1_.readIfPresent(coeffDict());
319 alphaK2_.readIfPresent(coeffDict());
320 alphaOmega1_.readIfPresent(coeffDict());
321 alphaOmega2_.readIfPresent(coeffDict());
322 gamma1_.readIfPresent(coeffDict());
323 gamma2_.readIfPresent(coeffDict());
324 beta1_.readIfPresent(coeffDict());
325 beta2_.readIfPresent(coeffDict());
326 betaStar_.readIfPresent(coeffDict());
327 a1_.readIfPresent(coeffDict());
328 c1_.readIfPresent(coeffDict());
339 void coupledKOmegaSST::correct()
341 // Bound in case of topological change
343 if (mesh_.changing())
346 bound(omega_, omega0_);
356 if (mesh_.changing())
361 volScalarField S2 = magSqr(symm(fvc::grad(U_)));
362 volScalarField G("RASModel::G", nut_*2*S2);
364 // Make coupled matrix
365 fvBlockMatrix<vector2> kOmegaEqn(kOmega_);
367 // Update omega and G at the wall
368 omega_.boundaryField().updateCoeffs();
370 volScalarField CDkOmega =
371 (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_;
373 volScalarField F1 = this->F1(CDkOmega);
375 Info<< "Coupled k-omega" << endl;
377 // Turbulent frequency equation
379 fvScalarMatrix omegaEqn
382 + fvm::div(phi_, omega_)
383 + fvm::SuSp(-fvc::div(phi_), omega_)
384 - fvm::laplacian(DomegaEff(F1), omega_)
388 + (F1 - scalar(1))*CDkOmega/omega_,
396 omegaEqn.completeAssembly();
398 kOmegaEqn.insertEquation(1, omegaEqn);
401 volScalarField coupling
406 scalarField& couplingIn = coupling.internalField();
408 // Eliminate coupling in wall function cells
409 labelList eliminated = omegaEqn.eliminatedEqns().toc();
411 forAll (eliminated, cellI)
413 couplingIn[eliminated[cellI]] *= 0;
417 kOmegaEqn.insertEquationCoupling(1, 0, coupling);
420 // Turbulent kinetic energy equation
426 + fvm::SuSp(-fvc::div(phi_), k_)
427 - fvm::laplacian(DkEff(F1), k_)
431 - min(G/k_, c1_*betaStar_*omega_),
438 kOmegaEqn.insertEquation(0, kEqn);
441 // Update source coupling: coupling terms eliminated from source
442 kOmegaEqn.updateSourceCoupling();
447 kOmegaEqn.retrieveSolution(0, k_.internalField());
448 kOmegaEqn.retrieveSolution(1, omega_.internalField());
450 k_.correctBoundaryConditions();
451 omega_.correctBoundaryConditions();
454 bound(omega_, omega0_);
456 // Re-calculate viscosity
457 nut_ = a1_*k_/max(a1_*omega_, F2()*sqrt(2*S2));
458 nut_ = min(nut_, nuRatio()*nu());
459 nut_.correctBoundaryConditions();
463 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
465 } // End namespace RASModels
466 } // End namespace incompressible
467 } // End namespace Foam
469 // ************************************************************************* //