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 / LamBremhorstKE / LamBremhorstKE.C
blob97363cc3dd2a412d03bcc6a6340d105904ed5a48
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 "LamBremhorstKE.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(LamBremhorstKE, 0);
43 addToRunTimeSelectionTable(RASModel, LamBremhorstKE, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 LamBremhorstKE::LamBremhorstKE
49     const volVectorField& U,
50     const surfaceScalarField& phi,
51     transportModel& lamTransportModel
54     RASModel(typeName, U, phi, lamTransportModel),
56     Cmu_
57     (
58         dimensionedScalar::lookupOrAddToDict
59         (
60             "Cmu",
61             coeffDict_,
62             0.09
63         )
64     ),
65     C1_
66     (
67         dimensionedScalar::lookupOrAddToDict
68         (
69             "C1",
70             coeffDict_,
71             1.44
72         )
73     ),
74     C2_
75     (
76         dimensionedScalar::lookupOrAddToDict
77         (
78             "C2",
79             coeffDict_,
80             1.92
81         )
82     ),
83     sigmaEps_
84     (
85         dimensionedScalar::lookupOrAddToDict
86         (
87             "alphaEps",
88             coeffDict_,
89             1.3
90         )
91     ),
93     k_
94     (
95         IOobject
96         (
97             "k",
98             runTime_.timeName(),
99             U_.db(),
100             IOobject::MUST_READ,
101             IOobject::AUTO_WRITE
102         ),
103         mesh_
104     ),
106     epsilon_
107     (
108         IOobject
109         (
110             "epsilon",
111             runTime_.timeName(),
112             U_.db(),
113             IOobject::MUST_READ,
114             IOobject::AUTO_WRITE
115         ),
116         mesh_
117     ),
119     y_(mesh_),
121     Rt_(sqr(k_)/(nu()*epsilon_)),
123     fMu_
124     (
125         sqr(scalar(1) - exp(-0.0165*(sqrt(k_)*y_/nu())))
126        *(scalar(1) + 20.5/(Rt_ + SMALL))
127     ),
129     nut_
130     (
131         IOobject
132         (
133             "nut",
134             runTime_.timeName(),
135             U_.db(),
136             IOobject::NO_READ,
137             IOobject::AUTO_WRITE
138         ),
139         autoCreateLowReNut("nut", mesh_)
140     )
142     nut_ = Cmu_*fMu_*sqr(k_)/(epsilon_ + epsilonSmall_);
143     nut_ = min(nut_, nuRatio()*nu());
144     nut_.correctBoundaryConditions();
146     printCoeffs();
150 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
152 tmp<volSymmTensorField> LamBremhorstKE::R() const
154     return tmp<volSymmTensorField>
155     (
156         new volSymmTensorField
157         (
158             IOobject
159             (
160                 "R",
161                 runTime_.timeName(),
162                 U_.db(),
163                 IOobject::NO_READ,
164                 IOobject::NO_WRITE
165             ),
166             ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
167             k_.boundaryField().types()
168         )
169     );
173 tmp<volSymmTensorField> LamBremhorstKE::devReff() const
175     return tmp<volSymmTensorField>
176     (
177         new volSymmTensorField
178         (
179             IOobject
180             (
181                 "devRhoReff",
182                 runTime_.timeName(),
183                 U_.db(),
184                 IOobject::NO_READ,
185                 IOobject::NO_WRITE
186             ),
187            -nuEff()*dev(twoSymm(fvc::grad(U_)))
188         )
189     );
193 tmp<fvVectorMatrix> LamBremhorstKE::divDevReff(volVectorField& U) const
195     return
196     (
197       - fvm::laplacian(nuEff(), U)
198       - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
199     );
203 bool LamBremhorstKE::read()
205     if (RASModel::read())
206     {
207         Cmu_.readIfPresent(coeffDict());
208         C1_.readIfPresent(coeffDict());
209         C2_.readIfPresent(coeffDict());
210         sigmaEps_.readIfPresent(coeffDict());
212         return true;
213     }
214     else
215     {
216         return false;
217     }
221 void LamBremhorstKE::correct()
223     // Bound in case of topological change
224     // HJ, 22/Aug/2007
225     if (mesh_.changing())
226     {
227         bound(k_, k0_);
228         bound(epsilon_, epsilon0_);
229     }
231     RASModel::correct();
233     if (!turbulence_)
234     {
235         return;
236     }
238     if (mesh_.changing())
239     {
240         y_.correct();
241     }
243     volScalarField G("RASModel::G", nut_*2*magSqr(symm(fvc::grad(U_))));
246     // Calculate parameters and coefficients for low-Reynolds number model
248     Rt_ = sqr(k_)/(nu()*epsilon_);
249     volScalarField Ry = sqrt(k_)*y_/nu();
251     fMu_ = sqr(scalar(1) - exp(-0.0165*Ry))*(scalar(1) + 20.5/(Rt_ + SMALL));
253     volScalarField f1 = scalar(1) + pow(0.05/(fMu_ + SMALL), 3);
254     volScalarField f2 = scalar(1) - exp(-sqr(Rt_));
257     // Dissipation equation
259     tmp<fvScalarMatrix> epsEqn
260     (
261         fvm::ddt(epsilon_)
262       + fvm::div(phi_, epsilon_)
263       + fvm::SuSp(-fvc::div(phi_), epsilon_)
264       - fvm::laplacian(DepsilonEff(), epsilon_)
265      ==
266         C1_*f1*G*epsilon_/k_
267       - fvm::Sp(C2_*f2*epsilon_/k_, epsilon_)
268     );
270     epsEqn().relax();
271     solve(epsEqn);
272     bound(epsilon_, epsilon0_);
275     // Turbulent kinetic energy equation
277     tmp<fvScalarMatrix> kEqn
278     (
279         fvm::ddt(k_)
280       + fvm::div(phi_, k_)
281       + fvm::SuSp(-fvc::div(phi_), k_)
282       - fvm::laplacian(DkEff(), k_)
283      ==
284         G - fvm::Sp(epsilon_/k_, k_)
285     );
287     kEqn().relax();
288     solve(kEqn);
289     bound(k_, k0_);
292     // Re-calculate viscosity
293     nut_ == Cmu_*fMu_*sqr(k_)/epsilon_;
294     nut_ == min(nut_, nuRatio()*nu());
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 } // End namespace RASModels
301 } // End namespace incompressible
302 } // End namespace Foam
304 // ************************************************************************* //