ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / RAS / LaunderSharmaKE / LaunderSharmaKE.C
blobf0fa6e60c8d3abc3fd363025c6f45d39e9e85afb
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "LaunderSharmaKE.H"
27 #include "addToRunTimeSelectionTable.H"
29 #include "backwardsCompatibilityWallFunctions.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
35 namespace incompressible
37 namespace RASModels
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(LaunderSharmaKE, 0);
43 addToRunTimeSelectionTable(RASModel, LaunderSharmaKE, dictionary);
45 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
47 tmp<volScalarField> LaunderSharmaKE::fMu() const
49     return exp(-3.4/sqr(scalar(1) + sqr(k_)/(nu()*epsilonTilda_)/50.0));
53 tmp<volScalarField> LaunderSharmaKE::f2() const
55     return
56         scalar(1)
57       - 0.3*exp(-min(sqr(sqr(k_)/(nu()*epsilonTilda_)), scalar(50.0)));
61 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
63 LaunderSharmaKE::LaunderSharmaKE
65     const volVectorField& U,
66     const surfaceScalarField& phi,
67     transportModel& transport,
68     const word& turbulenceModelName,
69     const word& modelName
72     RASModel(modelName, U, phi, transport, turbulenceModelName),
74     Cmu_
75     (
76         dimensioned<scalar>::lookupOrAddToDict
77         (
78             "Cmu",
79             coeffDict_,
80             0.09
81         )
82     ),
83     C1_
84     (
85         dimensioned<scalar>::lookupOrAddToDict
86         (
87             "C1",
88             coeffDict_,
89             1.44
90         )
91     ),
92     C2_
93     (
94         dimensioned<scalar>::lookupOrAddToDict
95         (
96             "C2",
97             coeffDict_,
98             1.92
99         )
100     ),
101     sigmaEps_
102     (
103         dimensioned<scalar>::lookupOrAddToDict
104         (
105             "sigmaEps",
106             coeffDict_,
107             1.3
108         )
109     ),
111     k_
112     (
113         IOobject
114         (
115             "k",
116             runTime_.timeName(),
117             mesh_,
118             IOobject::MUST_READ,
119             IOobject::AUTO_WRITE
120         ),
121         mesh_
122     ),
124     epsilonTilda_
125     (
126         IOobject
127         (
128             "epsilon",
129             runTime_.timeName(),
130             mesh_,
131             IOobject::MUST_READ,
132             IOobject::AUTO_WRITE
133         ),
134         mesh_
135     ),
137     nut_
138     (
139         IOobject
140         (
141             "nut",
142             runTime_.timeName(),
143             mesh_,
144             IOobject::NO_READ,
145             IOobject::AUTO_WRITE
146         ),
147         autoCreateLowReNut("nut", mesh_)
148     )
150     bound(k_, kMin_);
151     bound(epsilonTilda_, epsilonMin_);
153     nut_ = Cmu_*fMu()*sqr(k_)/epsilonTilda_;
154     nut_.correctBoundaryConditions();
156     printCoeffs();
160 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
162 tmp<volSymmTensorField> LaunderSharmaKE::R() const
164     return tmp<volSymmTensorField>
165     (
166         new volSymmTensorField
167         (
168             IOobject
169             (
170                 "R",
171                 runTime_.timeName(),
172                 mesh_,
173                 IOobject::NO_READ,
174                 IOobject::NO_WRITE
175             ),
176             ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
177             k_.boundaryField().types()
178         )
179     );
183 tmp<volSymmTensorField> LaunderSharmaKE::devReff() const
185     return tmp<volSymmTensorField>
186     (
187         new volSymmTensorField
188         (
189             IOobject
190             (
191                 "devRhoReff",
192                 runTime_.timeName(),
193                 mesh_,
194                 IOobject::NO_READ,
195                 IOobject::NO_WRITE
196             ),
197            -nuEff()*dev(twoSymm(fvc::grad(U_)))
198         )
199     );
203 tmp<fvVectorMatrix> LaunderSharmaKE::divDevReff(volVectorField& U) const
205     return
206     (
207       - fvm::laplacian(nuEff(), U)
208       - fvc::div(nuEff()*dev(T(fvc::grad(U))))
209     );
213 bool LaunderSharmaKE::read()
215     if (RASModel::read())
216     {
217         Cmu_.readIfPresent(coeffDict());
218         C1_.readIfPresent(coeffDict());
219         C2_.readIfPresent(coeffDict());
220         sigmaEps_.readIfPresent(coeffDict());
222         return true;
223     }
224     else
225     {
226         return false;
227     }
231 void LaunderSharmaKE::correct()
233     RASModel::correct();
235     if (!turbulence_)
236     {
237         return;
238     }
240     tmp<volScalarField> S2 = 2*magSqr(symm(fvc::grad(U_)));
242     volScalarField G("RASModel::G", nut_*S2);
244     const volScalarField E(2.0*nu()*nut_*fvc::magSqrGradGrad(U_));
245     const volScalarField D(2.0*nu()*magSqr(fvc::grad(sqrt(k_))));
248     // Dissipation rate equation
250     tmp<fvScalarMatrix> epsEqn
251     (
252         fvm::ddt(epsilonTilda_)
253       + fvm::div(phi_, epsilonTilda_)
254       - fvm::laplacian(DepsilonEff(), epsilonTilda_)
255      ==
256         C1_*G*epsilonTilda_/k_
257       - fvm::Sp(C2_*f2()*epsilonTilda_/k_, epsilonTilda_)
258       + E
259     );
261     epsEqn().relax();
262     solve(epsEqn);
263     bound(epsilonTilda_, epsilonMin_);
266     // Turbulent kinetic energy equation
268     tmp<fvScalarMatrix> kEqn
269     (
270         fvm::ddt(k_)
271       + fvm::div(phi_, k_)
272       - fvm::laplacian(DkEff(), k_)
273      ==
274         G - fvm::Sp((epsilonTilda_ + D)/k_, k_)
275     );
277     kEqn().relax();
278     solve(kEqn);
279     bound(k_, kMin_);
282     // Re-calculate viscosity
283     nut_ == Cmu_*fMu()*sqr(k_)/epsilonTilda_;
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 } // End namespace RASModels
290 } // End namespace incompressible
291 } // End namespace Foam
293 // ************************************************************************* //