Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / turbulenceModels / incompressible / RAS / LienLeschzinerLowRe / LienLeschzinerLowRe.C
blob24a3f9ca173d1d245fb33dec8572f818a79f6701
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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 "LienLeschzinerLowRe.H"
27 #include "wallFvPatch.H"
28 #include "addToRunTimeSelectionTable.H"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
36 namespace incompressible
38 namespace RASModels
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(LienLeschzinerLowRe, 0);
44 addToRunTimeSelectionTable(RASModel, LienLeschzinerLowRe, dictionary);
46 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
48 LienLeschzinerLowRe::LienLeschzinerLowRe
50     const volVectorField& U,
51     const surfaceScalarField& phi,
52     transportModel& lamTransportModel
55     RASModel(typeName, U, phi, lamTransportModel),
57     C1_
58     (
59         dimensionedScalar::lookupOrAddToDict
60         (
61             "C1",
62             coeffDict_,
63             1.44
64         )
65     ),
66     C2_
67     (
68         dimensionedScalar::lookupOrAddToDict
69         (
70             "C2",
71             coeffDict_,
72             1.92
73         )
74     ),
75     sigmak_
76     (
77         dimensionedScalar::lookupOrAddToDict
78         (
79             "sigmak",
80             coeffDict_,
81             1.0
82         )
83     ),
84     sigmaEps_
85     (
86         dimensionedScalar::lookupOrAddToDict
87         (
88             "sigmaEps",
89             coeffDict_,
90             1.3
91         )
92     ),
93     Cmu_
94     (
95         dimensionedScalar::lookupOrAddToDict
96         (
97             "Cmu",
98             coeffDict_,
99             0.09
100         )
101     ),
102     kappa_
103     (
104         dimensionedScalar::lookupOrAddToDict
105         (
106             "kappa",
107             coeffDict_,
108             0.41
109         )
110     ),
111     Am_
112     (
113         dimensionedScalar::lookupOrAddToDict
114         (
115             "Am",
116             coeffDict_,
117             0.016
118         )
119     ),
120     Aepsilon_
121     (
122         dimensionedScalar::lookupOrAddToDict
123         (
124             "Aepsilon",
125             coeffDict_,
126             0.263
127         )
128     ),
129     Amu_
130     (
131         dimensionedScalar::lookupOrAddToDict
132         (
133             "Amu",
134             coeffDict_,
135             0.00222
136         )
137     ),
139     k_
140     (
141         IOobject
142         (
143             "k",
144             runTime_.timeName(),
145             U_.db(),
146             IOobject::MUST_READ,
147             IOobject::AUTO_WRITE
148         ),
149         mesh_
150     ),
152     epsilon_
153     (
154         IOobject
155         (
156             "epsilon",
157             runTime_.timeName(),
158             U_.db(),
159             IOobject::MUST_READ,
160             IOobject::AUTO_WRITE
161         ),
162         mesh_
163     ),
165     y_(mesh_),
167     yStar_(sqrt(k_)*y_/nu() + SMALL),
169     nut_
170     (
171         IOobject
172         (
173             "epsilon",
174             runTime_.timeName(),
175             U_.db(),
176             IOobject::NO_READ,
177             IOobject::AUTO_WRITE
178         ),
179         autoCreateLowReNut("nut", mesh_)
180     )
182     nut_ = Cmu_*(scalar(1) - exp(-Am_*yStar_))
183        /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL)*sqr(k_)
184        /(epsilon_ + epsilonSmall_);
185     nut_ = min(nut_, nuRatio()*nu());
186     nut_.correctBoundaryConditions();
188     printCoeffs();
192 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
194 tmp<volSymmTensorField> LienLeschzinerLowRe::R() const
196     volTensorField gradU = fvc::grad(U_);
198     return tmp<volSymmTensorField>
199     (
200         new volSymmTensorField
201         (
202             IOobject
203             (
204                 "R",
205                 runTime_.timeName(),
206                 U_.db(),
207                 IOobject::NO_READ,
208                 IOobject::NO_WRITE
209             ),
210             ((2.0/3.0)*I)*k_ - nut_*twoSymm(gradU),
211             k_.boundaryField().types()
212         )
213     );
217 tmp<volSymmTensorField> LienLeschzinerLowRe::devReff() const
219     return tmp<volSymmTensorField>
220     (
221         new volSymmTensorField
222         (
223             IOobject
224             (
225                 "devRhoReff",
226                 runTime_.timeName(),
227                 U_.db(),
228                 IOobject::NO_READ,
229                 IOobject::NO_WRITE
230             ),
231            -nuEff()*dev(twoSymm(fvc::grad(U_)))
232         )
233     );
237 tmp<fvVectorMatrix> LienLeschzinerLowRe::divDevReff(volVectorField& U) const
239     return
240     (
241       - fvm::laplacian(nuEff(), U)
242     //- (fvc::grad(U) & fvc::grad(nuEff()))
243       - fvc::div(nuEff()*fvc::grad(U)().T())
244     );
248 bool LienLeschzinerLowRe::read()
250     if (RASModel::read())
251     {
252         C1_.readIfPresent(coeffDict());
253         C2_.readIfPresent(coeffDict());
254         sigmak_.readIfPresent(coeffDict());
255         sigmaEps_.readIfPresent(coeffDict());
256         Cmu_.readIfPresent(coeffDict());
257         kappa_.readIfPresent(coeffDict());
258         Am_.readIfPresent(coeffDict());
259         Aepsilon_.readIfPresent(coeffDict());
260         Amu_.readIfPresent(coeffDict());
262         return true;
263     }
264     else
265     {
266         return false;
267     }
271 void LienLeschzinerLowRe::correct()
273     // Bound in case of topological change
274     // HJ, 22/Aug/2007
275     if (mesh_.changing())
276     {
277         bound(k_, k0_);
278         bound(epsilon_, epsilon0_);
279     }
281     RASModel::correct();
283     if (!turbulence_)
284     {
285         return;
286     }
288     if (mesh_.changing())
289     {
290         y_.correct();
291     }
293     scalar Cmu75 = pow(Cmu_.value(), 0.75);
295     volTensorField gradU = fvc::grad(U_);
297     // generation term
298     volScalarField S2 = symm(gradU) && gradU;
300     yStar_ = sqrt(k_)*y_/nu() + SMALL;
301     volScalarField Rt = sqr(k_)/(nu()*epsilon_);
303     volScalarField fMu =
304         (scalar(1) - exp(-Am_*yStar_))
305        /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL);
307     volScalarField f2 = scalar(1) - 0.3*exp(-sqr(Rt));
309     volScalarField G("RASModel::G", Cmu_*fMu*sqr(k_)/epsilon_*S2);
312     // Dissipation equation
313     tmp<fvScalarMatrix> epsEqn
314     (
315         fvm::ddt(epsilon_)
316       + fvm::div(phi_, epsilon_)
317       + fvm::SuSp(-fvc::div(phi_), epsilon_)
318       - fvm::laplacian(DepsilonEff(), epsilon_)
319       ==
320         C1_*G*epsilon_/k_
321         // E-term
322         + C2_*f2*Cmu75*sqrt(k_)
323         /(kappa_*y_*(scalar(1) - exp(-Aepsilon_*yStar_)))
324        *exp(-Amu_*sqr(yStar_))*epsilon_
325       - fvm::Sp(C2_*f2*epsilon_/k_, epsilon_)
326     );
328     epsEqn().relax();
330 #   include "LienLeschzinerLowReSetWallDissipation.H"
331 #   include "wallDissipationI.H"
333     solve(epsEqn);
334     bound(epsilon_, epsilon0_);
337     // Turbulent kinetic energy equation
339     tmp<fvScalarMatrix> kEqn
340     (
341         fvm::ddt(k_)
342       + fvm::div(phi_, k_)
343       + fvm::SuSp(-fvc::div(phi_), k_)
344       - fvm::laplacian(DkEff(), k_)
345       ==
346         G
347       - fvm::Sp(epsilon_/k_, k_)
348     );
350     kEqn().relax();
351     solve(kEqn);
352     bound(k_, k0_);
355     // Re-calculate viscosity
356     nut_ = Cmu_*fMu*sqr(k_)/epsilon_;
357     nut_ = min(nut_, nuRatio()*nu());
358     nut_.correctBoundaryConditions();
362 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 } // End namespace RASModels
365 } // End namespace incompressible
366 } // End namespace Foam
368 // ************************************************************************* //