Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / LES / spectEddyVisc / spectEddyVisc.C
blob6e76030712a9e325d70c92171922e20c24ac9283
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
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 "spectEddyVisc.H"
27 #include "addToRunTimeSelectionTable.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
33 namespace incompressible
35 namespace LESModels
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(spectEddyVisc, 0);
41 addToRunTimeSelectionTable(LESModel, spectEddyVisc, dictionary);
43 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
45 void spectEddyVisc::updateSubGridScaleFields(const volTensorField& gradU)
47     const volScalarField Re(sqr(delta())*mag(symm(gradU))/nu());
48     for (label i=0; i<5; i++)
49     {
50         nuSgs_ =
51             nu()
52            /(
53                  scalar(1)
54                - exp(-cB_*pow(nu()/(nuSgs_ + nu()), 1.0/3.0)*pow(Re, -2.0/3.0))
55             );
56     }
58     nuSgs_.correctBoundaryConditions();
62 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
64 spectEddyVisc::spectEddyVisc
66     const volVectorField& U,
67     const surfaceScalarField& phi,
68     transportModel& transport,
69     const word& turbulenceModelName,
70     const word& modelName
73     LESModel(modelName, U, phi, transport, turbulenceModelName),
74     GenEddyVisc(U, phi, transport),
76     cB_
77     (
78         dimensioned<scalar>::lookupOrAddToDict
79         (
80             "cB",
81             coeffDict_,
82             8.22
83         )
84     ),
85     cK1_
86     (
87         dimensioned<scalar>::lookupOrAddToDict
88         (
89             "cK1",
90             coeffDict_,
91             0.83
92         )
93     ),
94     cK2_
95     (
96         dimensioned<scalar>::lookupOrAddToDict
97         (
98             "cK2",
99             coeffDict_,
100             1.03
101         )
102     ),
103     cK3_
104     (
105         dimensioned<scalar>::lookupOrAddToDict
106         (
107             "cK3",
108             coeffDict_,
109             4.75
110         )
111     ),
112     cK4_
113     (
114         dimensioned<scalar>::lookupOrAddToDict
115         (
116             "cK4",
117             coeffDict_,
118             2.55
119         )
120     )
122     printCoeffs();
124     updateSubGridScaleFields(fvc::grad(U));
128 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
130 tmp<volScalarField> spectEddyVisc::k() const
132     const volScalarField eps(2*nuEff()*magSqr(symm(fvc::grad(U()))));
134     return
135         cK1_*pow(delta()*eps, 2.0/3.0)
136        *exp(-cK2_*pow(delta(), -4.0/3.0)*nu()/pow(eps, 1.0/3.0))
137       - cK3_*sqrt(eps*nu())
138        *erfc(cK4_*pow(delta(), -2.0/3.0)*sqrt(nu())*pow(eps, -1.0/6.0));
142 void spectEddyVisc::correct(const tmp<volTensorField>& gradU)
144     GenEddyVisc::correct(gradU);
145     updateSubGridScaleFields(gradU());
149 bool spectEddyVisc::read()
151     if (GenEddyVisc::read())
152     {
153         cB_.readIfPresent(coeffDict());
154         cK1_.readIfPresent(coeffDict());
155         cK2_.readIfPresent(coeffDict());
156         cK3_.readIfPresent(coeffDict());
157         cK4_.readIfPresent(coeffDict());
159         return true;
160     }
161     else
162     {
163         return false;
164     }
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 } // End namespace LESModels
171 } // End namespace incompressible
172 } // End namespace Foam
174 // ************************************************************************* //