Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / LES / locDynOneEqEddy / locDynOneEqEddy.C
blob868796683caf930878880f01757792fe13c0e779
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 "locDynOneEqEddy.H"
27 #include "addToRunTimeSelectionTable.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
33 namespace incompressible
35 namespace LESModels
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(locDynOneEqEddy, 0);
41 addToRunTimeSelectionTable(LESModel, locDynOneEqEddy, dictionary);
43 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
45 void locDynOneEqEddy::updateSubGridScaleFields
47     const volSymmTensorField& D,
48     const volScalarField& KK
51     nuSgs_ = ck(D, KK)*sqrt(k_)*delta();
52     nuSgs_.correctBoundaryConditions();
56 volScalarField locDynOneEqEddy::ck
58     const volSymmTensorField& D,
59     const volScalarField& KK
60 ) const
62     const volSymmTensorField LL
63     (
64         simpleFilter_(dev(filter_(sqr(U())) - (sqr(filter_(U())))))
65     );
67     const volSymmTensorField MM
68     (
69         simpleFilter_(-2.0*delta()*pow(KK, 0.5)*filter_(D))
70     );
72     const volScalarField ck
73     (
74         simpleFilter_(0.5*(LL && MM))
75        /(
76             simpleFilter_(magSqr(MM))
77           + dimensionedScalar("small", sqr(MM.dimensions()), VSMALL)
78         )
79     );
81     tmp<volScalarField> tfld = 0.5*(mag(ck) + ck);
82     return tfld();
86 volScalarField locDynOneEqEddy::ce
88     const volSymmTensorField& D,
89     const volScalarField& KK
90 ) const
92     const volScalarField ce
93     (
94         simpleFilter_(nuEff()*(filter_(magSqr(D)) - magSqr(filter_(D))))
95        /simpleFilter_(pow(KK, 1.5)/(2.0*delta()))
96     );
98     tmp<volScalarField> tfld = 0.5*(mag(ce) + ce);
99     return tfld();
103 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
105 locDynOneEqEddy::locDynOneEqEddy
107     const volVectorField& U,
108     const surfaceScalarField& phi,
109     transportModel& transport,
110     const word& turbulenceModelName,
111     const word& modelName
114     LESModel(modelName, U, phi, transport, turbulenceModelName),
115     GenEddyVisc(U, phi, transport),
117     k_
118     (
119         IOobject
120         (
121             "k",
122             runTime_.timeName(),
123             mesh_,
124             IOobject::MUST_READ,
125             IOobject::AUTO_WRITE
126         ),
127         mesh_
128     ),
130     simpleFilter_(U.mesh()),
131     filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
132     filter_(filterPtr_())
134     bound(k_, kMin_);
136     const volScalarField KK(0.5*(filter_(magSqr(U)) - magSqr(filter_(U))));
137     updateSubGridScaleFields(symm(fvc::grad(U)), KK);
139     printCoeffs();
143 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
145 void locDynOneEqEddy::correct(const tmp<volTensorField>& gradU)
147     LESModel::correct(gradU);
149     const volSymmTensorField D(symm(gradU));
151     volScalarField KK(0.5*(filter_(magSqr(U())) - magSqr(filter_(U()))));
152     KK.max(dimensionedScalar("small", KK.dimensions(), SMALL));
154     const volScalarField P(2.0*nuSgs_*magSqr(D));
156     tmp<fvScalarMatrix> kEqn
157     (
158        fvm::ddt(k_)
159      + fvm::div(phi(), k_)
160      - fvm::laplacian(DkEff(), k_)
161     ==
162        P
163      - fvm::Sp(ce(D, KK)*sqrt(k_)/delta(), k_)
164     );
166     kEqn().relax();
167     kEqn().solve();
169     bound(k_, kMin_);
171     updateSubGridScaleFields(D, KK);
175 bool locDynOneEqEddy::read()
177     if (GenEddyVisc::read())
178     {
179         filter_.read(coeffDict());
181         return true;
182     }
183     else
184     {
185         return false;
186     }
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 } // End namespace LESModels
193 } // End namespace incompressible
194 } // End namespace Foam
196 // ************************************************************************* //