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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "LESModel.H"
30 
31 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
32 
33 template<class BasicTurbulenceModel>
35 {
36  if (printCoeffs_)
37  {
38  Info<< coeffDict_.dictName() << coeffDict_ << endl;
39  }
40 }
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
45 template<class BasicTurbulenceModel>
47 (
48  const word& type,
49  const alphaField& alpha,
50  const rhoField& rho,
51  const volVectorField& U,
52  const surfaceScalarField& alphaRhoPhi,
53  const surfaceScalarField& phi,
54  const transportModel& transport,
55  const word& propertiesName
56 )
57 :
58  BasicTurbulenceModel
59  (
60  type,
61  alpha,
62  rho,
63  U,
64  alphaRhoPhi,
65  phi,
66  transport,
67  propertiesName
68  ),
69  LESDict_(this->subOrEmptyDict("LES")),
70  turbulence_(LESDict_.getOrDefault<Switch>("turbulence", true)),
71  printCoeffs_(LESDict_.getOrDefault<Switch>("printCoeffs", false)),
72  coeffDict_(LESDict_.optionalSubDict(type + "Coeffs")),
73  Ce_
74  (
75  dimensioned<scalar>::getOrAddToDict
76  (
77  "Ce",
78  LESDict_,
79  1.048
80  )
81  ),
82  kMin_
83  (
84  dimensioned<scalar>::getOrAddToDict
85  (
86  "kMin",
87  LESDict_,
89  SMALL
90  )
91  ),
92  epsilonMin_
93  (
94  dimensioned<scalar>::getOrAddToDict
95  (
96  "epsilonMin",
97  LESDict_,
98  kMin_.dimensions()/dimTime,
99  SMALL
100  )
101  ),
102  omegaMin_
103  (
104  dimensioned<scalar>::getOrAddToDict
105  (
106  "omegaMin",
107  LESDict_,
109  SMALL
110  )
111  ),
112  delta_
113  (
114  LESdelta::New
115  (
116  IOobject::groupName("delta", alphaRhoPhi.group()),
117  *this,
118  LESDict_
119  )
120  )
121 {
122  // Force the construction of the mesh deltaCoeffs which may be needed
123  // for the construction of the derived models and BCs
124  this->mesh_.deltaCoeffs();
125 }
127 
128 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
129 
130 template<class BasicTurbulenceModel>
133 (
134  const alphaField& alpha,
135  const rhoField& rho,
136  const volVectorField& U,
137  const surfaceScalarField& alphaRhoPhi,
138  const surfaceScalarField& phi,
139  const transportModel& transport,
140  const word& propertiesName
141 )
142 {
143  const IOdictionary modelDict
144  (
145  IOobject
146  (
147  IOobject::groupName(propertiesName, alphaRhoPhi.group()),
148  U.time().constant(),
149  U.db(),
153  )
154  );
155 
156  const dictionary& dict = modelDict.subDict("LES");
157 
158  const word modelType
159  (
160  // "LESModel" for v2006 and earlier
161  dict.getCompat<word>("model", {{"LESModel", -2006}})
162  );
163 
164  Info<< "Selecting LES turbulence model " << modelType << endl;
165 
166  auto* ctorPtr = dictionaryConstructorTable(modelType);
167 
168  if (!ctorPtr)
169  {
171  (
172  dict,
173  "LES model",
174  modelType,
175  *dictionaryConstructorTablePtr_
176  ) << exit(FatalIOError);
177  }
178 
179  return autoPtr<LESModel>
180  (
181  ctorPtr(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
182  );
183 }
184 
185 
186 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
187 
188 template<class BasicTurbulenceModel>
190 {
192  {
193  LESDict_ <<= this->subDict("LES");
194  LESDict_.readEntry("turbulence", turbulence_);
195 
196  coeffDict_ <<= LESDict_.optionalSubDict(type() + "Coeffs");
197 
198  delta_().read(LESDict_);
199 
200  Ce_.readIfPresent(LESDict_);
201 
202  kMin_.readIfPresent(LESDict_);
203 
204  return true;
205  }
207  return false;
208 }
209 
210 
211 template<class BasicTurbulenceModel>
214 {
216  (
217  IOobject
218  (
219  IOobject::groupName("epsilon", this->alphaRhoPhi_.group()),
220  this->mesh_.time().timeName(),
221  this->mesh_
222  ),
223  this->Ce()*pow(this->k(), 1.5)/this->delta()
224  );
225 }
226 
227 
228 template<class BasicTurbulenceModel>
231 {
232  const scalar betaStar = 0.09;
233  const dimensionedScalar k0(sqr(dimLength/dimTime), SMALL);
234 
236  (
237  IOobject
238  (
239  IOobject::groupName("omega", this->alphaRhoPhi_.group()),
240  this->mesh_.time().timeName(),
241  this->mesh_
242  ),
243  this->epsilon()/(betaStar*(this->k() + k0))
244  );
245 }
246 
247 
248 template<class BasicTurbulenceModel>
250 {
251  delta_().correct();
253 }
254 
255 
256 // ************************************************************************* //
BasicTurbulenceModel::transportModel transportModel
Definition: LESModel.H:132
scalar delta
static word group(const word &name)
Return group (extension part of name)
Definition: IOobject.C:300
dictionary dict
type
Types of root.
Definition: Roots.H:52
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Abstract base class for LES deltas.
Definition: LESdelta.H:49
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
BasicTurbulenceModel::alphaField alphaField
Definition: LESModel.H:130
virtual void printCoeffs(const word &type)
Print model coefficients.
Definition: LESModel.C:27
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
label k
Boltzmann constant.
Generic dimensioned Type class.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:441
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
constexpr const char *const group
Group name for atomic constants.
virtual tmp< volScalarField > omega() const
Return the specific dissipation rate.
Definition: LESModel.C:223
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
A class for handling words, derived from Foam::string.
Definition: word.H:63
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
BasicTurbulenceModel::rhoField rhoField
Definition: LESModel.H:131
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Definition: LESModel.C:242
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(psi *p+alphal *rhol0+((alphav *psiv+alphal *psil) - psi) *pSat, rhoMin);# 1 "/home/chef2/andy/OpenFOAM/release/v2312/OpenFOAM-v2312/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=clamp((rho - rholSat)/(rhovSat - rholSat), zero_one{});alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
Definition: pEqn.H:63
T getCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T using any compatibility names if needed. FatalIOError if not found, or if there are excess tokens.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
virtual tmp< volScalarField > epsilon() const
Return the turbulence kinetic energy dissipation rate.
Definition: LESModel.C:206
U
Definition: pEqn.H:72
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
virtual bool read()
Read model coefficients if they have changed.
Definition: LESModel.C:182
Base-class for all transport models used by the incompressible turbulence models. ...
scalar epsilon
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
LESModel(const LESModel &)=delete
No copy construct.
messageStream Info
Information stream (stdout output on master, null elsewhere)
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:126
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
Do not request registration (bool: false)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...
const dimensionSet dimVelocity