FreeFOAM The Cross-Platform CFD Toolkit
LESModel.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "LESModel.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace compressible
34 {
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 defineTypeNameAndDebug(LESModel, 0);
39 defineRunTimeSelectionTable(LESModel, dictionary);
40 addToRunTimeSelectionTable(turbulenceModel, LESModel, turbulenceModel);
41 
42 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
43 
44 void LESModel::printCoeffs()
45 {
46  if (printCoeffs_)
47  {
48  Info<< type() << "Coeffs" << coeffDict_ << endl;
49  }
50 }
51 
52 
53 // * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * * //
54 
55 LESModel::LESModel
56 (
57  const word& type,
58  const volScalarField& rho,
59  const volVectorField& U,
60  const surfaceScalarField& phi,
61  const basicThermo& thermoPhysicalModel
62 )
63 :
64  turbulenceModel(rho, U, phi, thermoPhysicalModel),
65 
67  (
68  IOobject
69  (
70  "LESProperties",
71  U.time().constant(),
72  U.db(),
75  )
76  ),
77 
78  printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
79  coeffDict_(subOrEmptyDict(type + "Coeffs")),
80 
81  k0_("k0", dimVelocity*dimVelocity, SMALL),
82 
83  delta_(LESdelta::New("delta", U.mesh(), *this))
84 {
85  readIfPresent("k0", k0_);
86 
87  // Force the construction of the mesh deltaCoeffs which may be needed
88  // for the construction of the derived models and BCs
89  mesh_.deltaCoeffs();
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
94 
95 autoPtr<LESModel> LESModel::New
96 (
97  const volScalarField& rho,
98  const volVectorField& U,
99  const surfaceScalarField& phi,
100  const basicThermo& thermoPhysicalModel
101 )
102 {
103  word modelName;
104 
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
108  {
109  IOdictionary dict
110  (
111  IOobject
112  (
113  "LESProperties",
114  U.time().constant(),
115  U.db(),
118  )
119  );
120 
121  dict.lookup("LESModel") >> modelName;
122  }
123 
124  Info<< "Selecting LES turbulence model " << modelName << endl;
125 
126  dictionaryConstructorTable::iterator cstrIter =
127  dictionaryConstructorTablePtr_->find(modelName);
128 
129  if (cstrIter == dictionaryConstructorTablePtr_->end())
130  {
132  (
133  "LESModel::New(const volVectorField& U, const "
134  "surfaceScalarField& phi, const basicThermo&)"
135  ) << "Unknown LESModel type " << modelName
136  << endl << endl
137  << "Valid LESModel types are :" << endl
138  << dictionaryConstructorTablePtr_->sortedToc()
139  << exit(FatalError);
140  }
141 
142  return autoPtr<LESModel>(cstrIter()(rho, U, phi, thermoPhysicalModel));
143 }
144 
145 
146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
147 
149 {
150  delta_().correct();
151 }
152 
153 
155 {
156  correct(fvc::grad(U_));
157 }
158 
159 
160 bool LESModel::read()
161 {
162  if (regIOobject::read())
163  {
164  if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs"))
165  {
166  coeffDict_ <<= *dictPtr;
167  }
168 
169  readIfPresent("k0", k0_);
170 
171  delta_().read(*this);
172 
173  return true;
174  }
175  else
176  {
177  return false;
178  }
179 }
180 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace compressible
185 } // End namespace Foam
186 
187 // ************************ vim: set sw=4 sts=4 et: ************************ //