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) 2013-2015 OpenFOAM Foundation
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"
27 
28 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
29 
30 template<class BasicTurbulenceModel>
32 {
33  if (printCoeffs_)
34  {
35  Info<< type << "Coeffs" << coeffDict_ << endl;
36  }
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
42 template<class BasicTurbulenceModel>
44 (
45  const word& type,
46  const alphaField& alpha,
47  const rhoField& rho,
48  const volVectorField& U,
49  const surfaceScalarField& alphaRhoPhi,
50  const surfaceScalarField& phi,
51  const transportModel& transport,
52  const word& propertiesName
53 )
54 :
55  BasicTurbulenceModel
56  (
57  type,
58  alpha,
59  rho,
60  U,
61  alphaRhoPhi,
62  phi,
63  transport,
64  propertiesName
65  ),
66 
67  LESDict_(this->subOrEmptyDict("LES")),
68  turbulence_(LESDict_.lookup("turbulence")),
69  printCoeffs_(LESDict_.lookupOrDefault<Switch>("printCoeffs", false)),
70  coeffDict_(LESDict_.subOrEmptyDict(type + "Coeffs")),
71 
72  kMin_
73  (
75  (
76  "kMin",
77  LESDict_,
79  SMALL
80  )
81  ),
82 
83  omegaMin_
84  (
86  (
87  "omegaMin",
88  LESDict_,
90  SMALL
91  )
92  ),
93 
94  delta_
95  (
97  (
98  IOobject::groupName("delta", U.group()),
99  *this,
100  LESDict_
101  )
102  )
103 {
104  // Force the construction of the mesh deltaCoeffs which may be needed
105  // for the construction of the derived models and BCs
106  this->mesh_.deltaCoeffs();
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
111 
112 template<class BasicTurbulenceModel>
115 (
116  const alphaField& alpha,
117  const rhoField& rho,
118  const volVectorField& U,
119  const surfaceScalarField& alphaRhoPhi,
120  const surfaceScalarField& phi,
121  const transportModel& transport,
122  const word& propertiesName
123 )
124 {
125  // get model name, but do not register the dictionary
126  // otherwise it is registered in the database twice
127  const word modelType
128  (
130  (
131  IOobject
132  (
133  IOobject::groupName(propertiesName, U.group()),
134  U.time().constant(),
135  U.db(),
136  IOobject::MUST_READ_IF_MODIFIED,
137  IOobject::NO_WRITE,
138  false
139  )
140  ).subDict("LES").lookup("LESModel")
141  );
142 
143  Info<< "Selecting LES turbulence model " << modelType << endl;
144 
145  typename dictionaryConstructorTable::iterator cstrIter =
146  dictionaryConstructorTablePtr_->find(modelType);
147 
148  if (cstrIter == dictionaryConstructorTablePtr_->end())
149  {
151  << "Unknown LESModel type "
152  << modelType << nl << nl
153  << "Valid LESModel types:" << endl
154  << dictionaryConstructorTablePtr_->sortedToc()
155  << exit(FatalError);
156  }
157 
158  return autoPtr<LESModel>
159  (
160  cstrIter()(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
161  );
162 }
163 
164 
165 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
166 
167 template<class BasicTurbulenceModel>
169 {
171  {
172  LESDict_ <<= this->subDict("LES");
173  LESDict_.lookup("turbulence") >> turbulence_;
174 
175  if (const dictionary* dictPtr = LESDict_.subDictPtr(type() + "Coeffs"))
176  {
177  coeffDict_ <<= *dictPtr;
178  }
179 
180  delta_().read(LESDict_);
181 
182  kMin_.readIfPresent(LESDict_);
183 
184  return true;
185  }
186  else
187  {
188  return false;
189  }
190 }
191 
192 
193 template<class BasicTurbulenceModel>
195 {
196  delta_().correct();
198 }
199 
200 
201 // ************************************************************************* //
Foam::LESModel::rhoField
BasicTurbulenceModel::rhoField rhoField
Definition: LESModel.H:107
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::dimVelocity
const dimensionSet dimVelocity
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::LESModel::New
static autoPtr< LESModel > New(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const transportModel &transport, const word &propertiesName=turbulenceModel::propertiesName)
Return a reference to the selected LES model.
Definition: LESModel.C:115
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
U
U
Definition: pEqn.H:46
Foam::LESModel::correct
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Definition: LESModel.C:194
Foam::LESModel::transportModel
BasicTurbulenceModel::transportModel transportModel
Definition: LESModel.H:108
Foam::LESModel::LESModel
LESModel(const LESModel &)
Disallow default bitwise copy construct.
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::LESModel::read
virtual bool read()
Read model coefficients if they have changed.
Definition: LESModel.C:168
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::LESModel::printCoeffs
virtual void printCoeffs(const word &type)
Print model coefficients.
Definition: LESModel.C:31
correct
fvOptions correct(rho)
LESModel.H
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
rho
rho
Definition: pEqn.H:3
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::LESModel::alphaField
BasicTurbulenceModel::alphaField alphaField
Definition: LESModel.H:106
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::dictionary::subDictPtr
const dictionary * subDictPtr(const word &) const
Find and return a sub-dictionary pointer if present.
Definition: dictionary.C:616