FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

Smagorinsky.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "Smagorinsky.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 namespace compressible
00034 {
00035 namespace LESModels
00036 {
00037 
00038 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00039 
00040 defineTypeNameAndDebug(Smagorinsky, 0);
00041 addToRunTimeSelectionTable(LESModel, Smagorinsky, dictionary);
00042 
00043 
00044 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00045 
00046 void Smagorinsky::updateSubGridScaleFields(const volTensorField& gradU)
00047 {
00048     volSymmTensorField D = symm(gradU);
00049 
00050     volScalarField a = ce_/delta();
00051     volScalarField b = (2.0/3.0)*tr(D);
00052     volScalarField c = 2*ck_*delta()*(dev(D) && D);
00053 
00054     k_ = sqr((-b + sqrt(sqr(b) + 4*a*c))/(2*a));
00055 
00056     muSgs_ = ck_*rho()*delta()*sqrt(k_);
00057     muSgs_.correctBoundaryConditions();
00058 
00059     alphaSgs_ = muSgs_/Prt_;
00060     alphaSgs_.correctBoundaryConditions();
00061 }
00062 
00063 
00064 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00065 
00066 Smagorinsky::Smagorinsky
00067 (
00068     const volScalarField& rho,
00069     const volVectorField& U,
00070     const surfaceScalarField& phi,
00071     const basicThermo& thermoPhysicalModel
00072 )
00073 :
00074     LESModel(typeName, rho, U, phi, thermoPhysicalModel),
00075     GenEddyVisc(rho, U, phi, thermoPhysicalModel),
00076 
00077     ck_
00078     (
00079         dimensioned<scalar>::lookupOrAddToDict
00080         (
00081             "ck",
00082             coeffDict_,
00083             0.02
00084         )
00085     )
00086 {
00087     updateSubGridScaleFields(fvc::grad(U));
00088 
00089     printCoeffs();
00090 }
00091 
00092 
00093 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00094 
00095 void Smagorinsky::correct(const tmp<volTensorField>& gradU)
00096 {
00097     GenEddyVisc::correct(gradU);
00098     updateSubGridScaleFields(gradU());
00099 }
00100 
00101 
00102 bool Smagorinsky::read()
00103 {
00104     if (GenEddyVisc::read())
00105     {
00106         ck_.readIfPresent(coeffDict());
00107 
00108         return true;
00109     }
00110     else
00111     {
00112         return false;
00113     }
00114 }
00115 
00116 
00117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00118 
00119 } // End namespace LESModels
00120 } // End namespace compressible
00121 } // End namespace Foam
00122 
00123 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines