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 incompressible
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 volVectorField& U,
59  const surfaceScalarField& phi,
60  transportModel& lamTransportModel
61 )
62 :
63  turbulenceModel(U, phi, lamTransportModel),
64 
66  (
67  IOobject
68  (
69  "LESProperties",
70  U.time().constant(),
71  U.db(),
74  )
75  ),
76 
77  printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
78  coeffDict_(subOrEmptyDict(type + "Coeffs")),
79 
80  k0_("k0", dimVelocity*dimVelocity, SMALL),
81  delta_(LESdelta::New("delta", U.mesh(), *this))
82 {
83  readIfPresent("k0", k0_);
84 
85  // Force the construction of the mesh deltaCoeffs which may be needed
86  // for the construction of the derived models and BCs
87  mesh_.deltaCoeffs();
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
92 
94 (
95  const volVectorField& U,
96  const surfaceScalarField& phi,
97  transportModel& transport
98 )
99 {
100  word modelName;
101 
102  // Enclose the creation of the dictionary to ensure it is deleted
103  // before the turbulenceModel is created otherwise the dictionary is
104  // entered in the database twice
105  {
106  IOdictionary dict
107  (
108  IOobject
109  (
110  "LESProperties",
111  U.time().constant(),
112  U.db(),
115  )
116  );
117 
118  dict.lookup("LESModel") >> modelName;
119  }
120 
121  Info<< "Selecting LES turbulence model " << modelName << endl;
122 
123  dictionaryConstructorTable::iterator cstrIter =
124  dictionaryConstructorTablePtr_->find(modelName);
125 
126  if (cstrIter == dictionaryConstructorTablePtr_->end())
127  {
129  (
130  "LESModel::New(const volVectorField& U, const "
131  "surfaceScalarField& phi, transportModel&)"
132  ) << "Unknown LESModel type " << modelName
133  << endl << endl
134  << "Valid LESModel types are :" << endl
135  << dictionaryConstructorTablePtr_->sortedToc()
136  << exit(FatalError);
137  }
138 
139  return autoPtr<LESModel>(cstrIter()(U, phi, transport));
140 }
141 
142 
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 
146 {
148  delta_().correct();
149 }
150 
151 
153 {
154  correct(fvc::grad(U_));
155 }
156 
157 
158 bool LESModel::read()
159 {
160  if (regIOobject::read())
161  {
162  if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs"))
163  {
164  coeffDict_ <<= *dictPtr;
165  }
166 
167  delta_().read(*this);
168 
169  readIfPresent("k0", k0_);
170 
171  return true;
172  }
173  else
174  {
175  return false;
176  }
177 }
178 
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace incompressible
183 } // End namespace Foam
184 
185 // ************************ vim: set sw=4 sts=4 et: ************************ //