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

LESModel.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 "LESModel.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 namespace compressible
00035 {
00036 
00037 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00038 
00039 defineTypeNameAndDebug(LESModel, 0);
00040 defineRunTimeSelectionTable(LESModel, dictionary);
00041 addToRunTimeSelectionTable(turbulenceModel, LESModel, turbulenceModel);
00042 
00043 // * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //
00044 
00045 void LESModel::printCoeffs()
00046 {
00047     if (printCoeffs_)
00048     {
00049         Info<< type() << "Coeffs" << coeffDict_ << endl;
00050     }
00051 }
00052 
00053 
00054 // * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * * //
00055 
00056 LESModel::LESModel
00057 (
00058     const word& type,
00059     const volScalarField& rho,
00060     const volVectorField& U,
00061     const surfaceScalarField& phi,
00062     const basicThermo& thermoPhysicalModel
00063 )
00064 :
00065     turbulenceModel(rho, U, phi, thermoPhysicalModel),
00066 
00067     IOdictionary
00068     (
00069         IOobject
00070         (
00071             "LESProperties",
00072             U.time().constant(),
00073             U.db(),
00074             IOobject::MUST_READ,
00075             IOobject::NO_WRITE
00076         )
00077     ),
00078 
00079     printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
00080     coeffDict_(subDictPtr(type + "Coeffs")),
00081 
00082     k0_("k0", dimVelocity*dimVelocity, SMALL),
00083 
00084     delta_(LESdelta::New("delta", U.mesh(), *this))
00085 {
00086     readIfPresent("k0", k0_);
00087 }
00088 
00089 
00090 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
00091 
00092 autoPtr<LESModel> LESModel::New
00093 (
00094     const volScalarField& rho,
00095     const volVectorField& U,
00096     const surfaceScalarField& phi,
00097     const basicThermo& thermoPhysicalModel
00098 )
00099 {
00100     word modelName;
00101 
00102     // Enclose the creation of the dictionary to ensure it is deleted
00103     // before the turbulenceModel is created otherwise the dictionary is
00104     // entered in the database twice
00105     {
00106         IOdictionary dict
00107         (
00108             IOobject
00109             (
00110                 "LESProperties",
00111                 U.time().constant(),
00112                 U.db(),
00113                 IOobject::MUST_READ,
00114                 IOobject::NO_WRITE
00115             )
00116         );
00117 
00118         dict.lookup("LESModel") >> modelName;
00119     }
00120 
00121     Info<< "Selecting LES turbulence model " << modelName << endl;
00122 
00123     dictionaryConstructorTable::iterator cstrIter =
00124         dictionaryConstructorTablePtr_->find(modelName);
00125 
00126     if (cstrIter == dictionaryConstructorTablePtr_->end())
00127     {
00128         FatalErrorIn
00129         (
00130             "LESModel::New(const volVectorField& U, const "
00131             "surfaceScalarField& phi, const basicThermo&)"
00132         )   << "Unknown LESModel type " << modelName
00133             << endl << endl
00134             << "Valid LESModel types are :" << endl
00135             << dictionaryConstructorTablePtr_->toc()
00136             << exit(FatalError);
00137     }
00138 
00139     return autoPtr<LESModel>(cstrIter()(rho, U, phi, thermoPhysicalModel));
00140 }
00141 
00142 
00143 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00144 
00145 void LESModel::correct(const tmp<volTensorField>&)
00146 {
00147     delta_().correct();
00148 }
00149 
00150 
00151 void LESModel::correct()
00152 {
00153     correct(fvc::grad(U_));
00154 }
00155 
00156 
00157 bool LESModel::read()
00158 {
00159     if (regIOobject::read())
00160     {
00161         if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs"))
00162         {
00163             coeffDict_ <<= *dictPtr;
00164         }
00165 
00166         readIfPresent("k0", k0_);
00167 
00168         delta_().read(*this);
00169 
00170         return true;
00171     }
00172     else
00173     {
00174         return false;
00175     }
00176 }
00177 
00178 
00179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00180 
00181 } // End namespace compressible
00182 } // End namespace Foam
00183 
00184 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd