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