1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "addToRunTimeSelectionTable.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace compressible
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(LESModel, 0);
39 defineRunTimeSelectionTable(LESModel, dictionary);
40 addToRunTimeSelectionTable(turbulenceModel, LESModel, turbulenceModel);
42 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
44 void LESModel::printCoeffs()
48 Info<< type() << "Coeffs" << coeffDict_ << endl;
53 // * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * * //
58 const volScalarField& rho,
59 const volVectorField& U,
60 const surfaceScalarField& phi,
61 const basicThermo& thermoPhysicalModel
64 turbulenceModel(rho, U, phi, thermoPhysicalModel),
78 printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
79 coeffDict_(subOrEmptyDict(type + "Coeffs")),
81 k0_("k0", dimVelocity*dimVelocity, SMALL),
83 delta_(LESdelta::New("delta", U.mesh(), *this))
85 readIfPresent("k0", k0_);
87 // Force the construction of the mesh deltaCoeffs which may be needed
88 // for the construction of the derived models and BCs
93 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
95 autoPtr<LESModel> LESModel::New
97 const volScalarField& rho,
98 const volVectorField& U,
99 const surfaceScalarField& phi,
100 const basicThermo& thermoPhysicalModel
105 // Enclose the creation of the dictionary to ensure it is deleted
106 // before the turbulenceModel is created otherwise the dictionary is
107 // entered in the database twice
121 dict.lookup("LESModel") >> modelName;
124 Info<< "Selecting LES turbulence model " << modelName << endl;
126 dictionaryConstructorTable::iterator cstrIter =
127 dictionaryConstructorTablePtr_->find(modelName);
129 if (cstrIter == dictionaryConstructorTablePtr_->end())
133 "LESModel::New(const volVectorField& U, const "
134 "surfaceScalarField& phi, const basicThermo&)"
135 ) << "Unknown LESModel type " << modelName
137 << "Valid LESModel types are :" << endl
138 << dictionaryConstructorTablePtr_->sortedToc()
142 return autoPtr<LESModel>(cstrIter()(rho, U, phi, thermoPhysicalModel));
146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
148 void LESModel::correct(const tmp<volTensorField>&)
154 void LESModel::correct()
156 correct(fvc::grad(U_));
160 bool LESModel::read()
162 if (regIOobject::read())
164 if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs"))
166 coeffDict_ <<= *dictPtr;
169 readIfPresent("k0", k0_);
171 delta_().read(*this);
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 } // End namespace compressible
185 } // End namespace Foam
187 // ************************************************************************* //