initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / turbulenceModels / compressible / LES / DeardorffDiffStress / DeardorffDiffStress.C
blob41063cd2cd9ceab0c265ad068e8223471ed21427
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "DeardorffDiffStress.H"
28 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
34 namespace compressible
36 namespace LESModels
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 defineTypeNameAndDebug(DeardorffDiffStress, 0);
42 addToRunTimeSelectionTable(LESModel, DeardorffDiffStress, dictionary);
45 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
47 void DeardorffDiffStress::updateSubGridScaleFields(const volScalarField& K)
49     muSgs_ = ck_*rho()*sqrt(K)*delta();
50     muSgs_.correctBoundaryConditions();
52     alphaSgs_ = muSgs_/Prt_;
53     alphaSgs_.correctBoundaryConditions();
57 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
59 DeardorffDiffStress::DeardorffDiffStress
61     const volScalarField& rho,
62     const volVectorField& U,
63     const surfaceScalarField& phi,
64     const basicThermo& thermoPhysicalModel
67     LESModel(typeName, rho, U, phi, thermoPhysicalModel),
68     GenSGSStress(rho, U, phi, thermoPhysicalModel),
70     ck_
71     (
72         dimensioned<scalar>::lookupOrAddToDict
73         (
74             "ck",
75             coeffDict_,
76             0.094
77         )
78     ),
79     cm_
80     (
81         dimensioned<scalar>::lookupOrAddToDict
82         (
83             "cm",
84             coeffDict_,
85             4.13
86         )
87     )
89     updateSubGridScaleFields(0.5*tr(B_));
91     printCoeffs();
95 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
97 void DeardorffDiffStress::correct(const tmp<volTensorField>& tgradU)
99     const volTensorField& gradU = tgradU();
101     GenSGSStress::correct(gradU);
103     volSymmTensorField D = symm(gradU);
105     volSymmTensorField P = -rho()*twoSymm(B_ & gradU);
107     volScalarField K = 0.5*tr(B_);
109     solve
110     (
111         fvm::ddt(rho(), B_)
112       + fvm::div(phi(), B_)
113       - fvm::laplacian(DBEff(), B_)
114       + fvm::Sp(cm_*rho()*sqrt(K)/delta(), B_)
115      ==
116         P
117       + 0.8*rho()*K*D
118       - (2*ce_ - 0.667*cm_)*I*rho()*epsilon()
119     );
122     // Bounding the component kinetic energies
124     forAll(B_, celli)
125     {
126         B_[celli].component(symmTensor::XX) =
127             max(B_[celli].component(symmTensor::XX), 1.0e-10);
128         B_[celli].component(symmTensor::YY) =
129             max(B_[celli].component(symmTensor::YY), 1.0e-10);
130         B_[celli].component(symmTensor::ZZ) =
131             max(B_[celli].component(symmTensor::ZZ), 1.0e-10);
132     }
134     K = 0.5*tr(B_);
135     bound(K, k0());
137     updateSubGridScaleFields(K);
141 bool DeardorffDiffStress::read()
143     if (GenSGSStress::read())
144     {
145         ck_.readIfPresent(coeffDict());
146         cm_.readIfPresent(coeffDict());
148         return true;
149     }
150     else
151     {
152         return false;
153     }
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 } // End namespace LESModels
160 } // End namespace compressible
161 } // End namespace Foam
163 // ************************************************************************* //