Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / LES / LRRDiffStress / LRRDiffStress.C
blobac6a186d5cfb2f5ab12ccb650bd6863a08b20fbf
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 "LRRDiffStress.H"
27 #include "addToRunTimeSelectionTable.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
33 namespace incompressible
35 namespace LESModels
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(LRRDiffStress, 0);
41 addToRunTimeSelectionTable(LESModel, LRRDiffStress, dictionary);
43 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
45 void LRRDiffStress::updateSubGridScaleFields(const volScalarField& K)
47     nuSgs_ = ck_*sqrt(K)*delta();
48     nuSgs_.correctBoundaryConditions();
52 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
54 LRRDiffStress::LRRDiffStress
56     const volVectorField& U,
57     const surfaceScalarField& phi,
58     transportModel& transport,
59     const word& turbulenceModelName,
60     const word& modelName
63     LESModel(modelName, U, phi, transport, turbulenceModelName),
64     GenSGSStress(U, phi, transport),
66     ck_
67     (
68         dimensioned<scalar>::lookupOrAddToDict
69         (
70             "ck",
71             coeffDict_,
72             0.09
73         )
74     ),
75     c1_
76     (
77         dimensioned<scalar>::lookupOrAddToDict
78         (
79             "c1",
80             coeffDict_,
81             1.8
82         )
83     ),
84     c2_
85     (
86         dimensioned<scalar>::lookupOrAddToDict
87         (
88             "c2",
89             coeffDict_,
90             0.6
91         )
92     )
94     volScalarField K(0.5*tr(B_));
95     bound(K, kMin_);
97     updateSubGridScaleFields(K);
99     printCoeffs();
103 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
105 void LRRDiffStress::correct(const tmp<volTensorField>& tgradU)
107     const volTensorField& gradU = tgradU();
109     GenSGSStress::correct(gradU);
111     const volSymmTensorField D(symm(gradU));
113     const volSymmTensorField P(-twoSymm(B_ & gradU));
115     volScalarField K(0.5*tr(B_));
116     const volScalarField Epsilon(2*nuEff()*magSqr(D));
118     tmp<fvSymmTensorMatrix> BEqn
119     (
120         fvm::ddt(B_)
121       + fvm::div(phi(), B_)
122       - fvm::laplacian(DBEff(), B_)
123       + fvm::Sp(c1_*Epsilon/K, B_)
124      ==
125         P
126       - (0.667*(1.0 - c1_)*I)*Epsilon
127       - c2_*(P - 0.333*I*tr(P))
128       - (0.667 - 2*c1_)*I*pow(K, 1.5)/delta()
129     );
131     BEqn().relax();
132     BEqn().solve();
134     // Bounding the component kinetic energies
136     forAll(B_, celli)
137     {
138         B_[celli].component(symmTensor::XX) =
139             max(B_[celli].component(symmTensor::XX), kMin_.value());
140         B_[celli].component(symmTensor::YY) =
141             max(B_[celli].component(symmTensor::YY), kMin_.value());
142         B_[celli].component(symmTensor::ZZ) =
143             max(B_[celli].component(symmTensor::ZZ), kMin_.value());
144     }
146     K = 0.5*tr(B_);
147     bound(K, kMin_);
149     updateSubGridScaleFields(K);
153 bool LRRDiffStress::read()
155     if (GenSGSStress::read())
156     {
157         ck_.readIfPresent(coeffDict());
158         c1_.readIfPresent(coeffDict());
159         c2_.readIfPresent(coeffDict());
161         return true;
162     }
163     else
164     {
165         return false;
166     }
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 } // End namespace LESModels
173 } // End namespace incompressible
174 } // End namespace Foam
176 // ************************************************************************* //