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

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