OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

dynSmagorinsky.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "dynSmagorinsky.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 namespace incompressible
00035 {
00036 namespace LESModels
00037 {
00038 
00039 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00040 
00041 defineTypeNameAndDebug(dynSmagorinsky, 0);
00042 addToRunTimeSelectionTable(LESModel, dynSmagorinsky, dictionary);
00043 
00044 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00045 
00046 void dynSmagorinsky::updateSubGridScaleFields(const volSymmTensorField& D)
00047 {
00048     nuSgs_ = cD(D)*sqr(delta())*sqrt(magSqr(D));
00049     nuSgs_.correctBoundaryConditions();
00050 }
00051 
00052 
00053 dimensionedScalar dynSmagorinsky::cD(const volSymmTensorField& D) const
00054 {
00055     volSymmTensorField LL = dev(filter_(sqr(U())) - (sqr(filter_(U()))));
00056 
00057     volSymmTensorField MM =
00058         sqr(delta())*(filter_(mag(D)*(D)) - 4*mag(filter_(D))*filter_(D));
00059 
00060     dimensionedScalar MMMM = average(magSqr(MM));
00061 
00062     if (MMMM.value() > VSMALL)
00063     {
00064         return average(LL && MM)/MMMM;
00065     }
00066     else
00067     {
00068         return 0.0;
00069     }
00070 }
00071 
00072 
00073 dimensionedScalar dynSmagorinsky::cI(const volSymmTensorField& D) const
00074 {
00075     volScalarField KK = 0.5*(filter_(magSqr(U())) - magSqr(filter_(U())));
00076 
00077     volScalarField mm =
00078         sqr(delta())*(4*sqr(mag(filter_(D))) - filter_(sqr(mag(D))));
00079 
00080     dimensionedScalar mmmm = average(magSqr(mm));
00081 
00082     if (mmmm.value() > VSMALL)
00083     {
00084         return average(KK*mm)/mmmm;
00085     }
00086     else
00087     {
00088         return 0.0;
00089     }
00090 }
00091 
00092 
00093 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00094 
00095 dynSmagorinsky::dynSmagorinsky
00096 (
00097     const volVectorField& U,
00098     const surfaceScalarField& phi,
00099     transportModel& transport
00100 )
00101 :
00102     LESModel(typeName, U, phi, transport),
00103     GenEddyVisc(U, phi, transport),
00104 
00105     k_
00106     (
00107         IOobject
00108         (
00109             "k",
00110             runTime_.timeName(),
00111             mesh_,
00112             IOobject::MUST_READ,
00113             IOobject::AUTO_WRITE
00114         ),
00115         mesh_
00116     ),
00117 
00118     filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
00119     filter_(filterPtr_())
00120 {
00121     updateSubGridScaleFields(dev(symm(fvc::grad(U))));
00122 
00123     printCoeffs();
00124 }
00125 
00126 
00127 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00128 
00129 void dynSmagorinsky::correct(const tmp<volTensorField>& gradU)
00130 {
00131     LESModel::correct(gradU);
00132 
00133     volSymmTensorField D = dev(symm(gradU));
00134 
00135     k_ = cI(D)*sqr(delta())*magSqr(D);
00136 
00137     updateSubGridScaleFields(D);
00138 }
00139 
00140 
00141 bool dynSmagorinsky::read()
00142 {
00143     if (GenEddyVisc::read())
00144     {
00145         filter_.read(coeffDict());
00146 
00147         return true;
00148     }
00149     else
00150     {
00151         return false;
00152     }
00153 }
00154 
00155 
00156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00157 
00158 } // End namespace LESModels
00159 } // End namespace incompressible
00160 } // End namespace Foam
00161 
00162 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd