turbulenceFields.H
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-2016 OpenFOAM Foundation
9  Copyright (C) 2015-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 Class
28  Foam::functionObjects::turbulenceFields
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Computes various turbulence-related quantities that are not typically
35  output during calculations, and stores/writes them on the mesh database
36  for further manipulation.
37 
38  Fields are stored as copies of the original with a user-defined prefix
39  e.g. a prefix of \c turbulenceModel yields the following for field \c R:
40 
41  \verbatim
42  turbulenceModel:R
43  \endverbatim
44 
45  Operands:
46  \table
47  Operand | Type | Location
48  input | - | -
49  output file | - | -
50  output field | vol<Type>Field | $FOAM_CASE/<time>/<outField>
51  \endtable
52 
53  where \c <Type>=Scalar/SymmTensor.
54 
55  References:
56  \verbatim
57  Estimation expressions for L (tag:P), Eq. 10.37:
58  Pope, S. B. (2000).
59  Turbulent flows.
60  Cambridge, UK: Cambridge Univ. Press
61  DOI:10.1017/CBO9780511840531
62  \endverbatim
63 
64 Usage
65  Minimal example by using \c system/controlDict.functions:
66  \verbatim
67  turbulenceFields1
68  {
69  // Mandatory entries (unmodifiable)
70  type turbulenceFields;
71  libs (fieldFunctionObjects);
72 
73  // Mandatory entries (runtime modifiable)
74 
75  // Either of the below
76  // Option-1
77  fields (R devRhoReff);
78 
79  // Option-2
80  field R;
81 
82  // Optional entries (runtime modifiable)
83  prefix <word>;
84 
85  // Inherited entries
86  ...
87  }
88  \endverbatim
89 
90  where the entries mean:
91  \table
92  Property | Description | Type | Reqd | Deflt
93  type | Type name: turbulenceFields | word | yes | -
94  libs | Library name: fieldFunctionObjects | word | yes | -
95  fields | Names of fields to store (see below) | wordList | yes | -
96  field | Name of a field to store (see below) | word | yes | -
97  prefix | Name of output-field prefix | word | no | turbulenceProperties
98  \endtable
99 
100  where \c fields can include:
101  \verbatim
102  k | turbulent kinetic energy
103  epsilon | turbulent kinetic energy dissipation rate
104  omega | specific dissipation rate
105  nuTilda | modified turbulent viscosity
106  nut | turbulent viscosity (incompressible)
107  nuEff | effective turbulent viscosity (incompressible)
108  mut | turbulent viscosity (compressible)
109  muEff | effective turbulent viscosity (compressible)
110  alphat | turbulence thermal diffusivity (compressible)
111  alphaEff | effective turbulence thermal diffusivity (compressible)
112  R | Reynolds stress tensor
113  devReff | deviatoric part of the effective Reynolds stress
114  devRhoReff | divergence of the Reynolds stress
115  L | integral-length scale / mixing-length scale
116  I | turbulence intensity
117  \endverbatim
118 
119  The inherited entries are elaborated in:
120  - \link functionObject.H \endlink
121 
122  Minimal example by using the \c postProcess utility:
123  \verbatim
124  <solver> -postProcess -func turbulenceFields
125  \endverbatim
126 
127 Note
128  - Multiphase applications are not supported.
129  - The governing expression of \c nuTilda is
130  an approximation based on a dimensional analysis.
131 
132 See also
133  - Foam::functionObject
134  - Foam::functionObjects::fvMeshFunctionObject
135  - ExtendedCodeGuide::functionObjects::field::turbulenceFields
136 
137 SourceFiles
138  turbulenceFields.C
139  turbulenceFieldsTemplates.C
140 
141 \*---------------------------------------------------------------------------*/
142 
143 #ifndef functionObjects_turbulenceFields_H
144 #define functionObjects_turbulenceFields_H
145 
146 #include "fvMeshFunctionObject.H"
147 #include "HashSet.H"
148 #include "Enum.H"
149 #include "volFieldsFwd.H"
150 #include "Switch.H"
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 namespace Foam
155 {
156 namespace functionObjects
157 {
158 
159 /*---------------------------------------------------------------------------*\
160  Class turbulenceFields Declaration
161 \*---------------------------------------------------------------------------*/
162 
163 class turbulenceFields
164 :
165  public fvMeshFunctionObject
166 {
167 public:
168 
169  // Public Enumerations
170 
171  //- Options for the turbulence fields (compressible)
172  enum compressibleField
173  {
174  cfK,
175  cfEpsilon,
176  cfOmega,
177  cfNuTilda,
178  cfMut,
179  cfMuEff,
180  cfAlphat,
181  cfAlphaEff,
182  cfR,
183  cfDevRhoReff,
184  cfL,
185  cfI
186  };
187 
188  //- Names for compressibleField turbulence fields
189  static const Enum<compressibleField> compressibleFieldNames_;
190 
191  //- Options for the turbulence fields (incompressible)
193  {
194  ifK,
195  ifEpsilon,
196  ifOmega,
197  ifNuTilda,
198  ifNut,
199  ifNuEff,
200  ifR,
201  ifDevReff,
202  ifL,
203  ifI
204  };
205 
206  //- Names for incompressibleField turbulence fields
207  static const Enum<incompressibleField> incompressibleFieldNames_;
208 
209  //- Name of the turbulence properties dictionary
210  static const word modelName_;
211 
212 
213 protected:
214 
215  // Protected Data
216 
217  //- Flag to track initialisation
218  bool initialised_;
219 
220  //- Name of output-field prefix
221  word prefix_;
222 
223  //- Fields to load
225 
226 
227  // Protected Member Functions
228 
229  //- Unset duplicate fields already registered by other function objects
230  void initialise();
231 
232  //- Return true if compressible turbulence model is identified
233  bool compressible();
234 
235  //- Process the turbulence field
236  template<class Type>
237  void processField
238  (
239  const word& fieldName,
241  );
242 
243  //- Return nuTilda calculated from k and omega
244  template<class Model>
245  tmp<volScalarField> nuTilda(const Model& model) const;
246 
247  //- Return integral length scale, L, calculated from k and epsilon
248  template<class Model>
249  tmp<volScalarField> L(const Model& model) const;
250 
251  //- Return turbulence intensity, I, calculated from k and U
252  template<class Model>
253  tmp<volScalarField> I(const Model& model) const;
254 
255 
256 public:
257 
258  //- Runtime type information
259  TypeName("turbulenceFields");
260 
261 
262  // Constructors
263 
264  //- Construct from Time and dictionary
266  (
267  const word& name,
268  const Time& runTime,
270  );
271 
272  //- No copy construct
273  turbulenceFields(const turbulenceFields&) = delete;
274 
275  //- No copy assignment
276  void operator=(const turbulenceFields&) = delete;
277 
278 
279  //- Destructor
280  virtual ~turbulenceFields() = default;
281 
282 
283  // Member Functions
284 
285  //- Read the controls
286  virtual bool read(const dictionary&);
287 
288  //- Calculate turbulence fields
289  virtual bool execute();
290 
291  //- Do nothing.
292  // The turbulence fields are registered and written automatically
293  virtual bool write();
294 };
295 
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 } // End namespace functionObjects
300 } // End namespace Foam
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 #ifdef NoRepository
305  #include "turbulenceFieldsTemplates.C"
306 #endif
307 
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 
310 #endif
311 
312 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
volFieldsFwd.H
Foam::functionObjects::turbulenceFields::initialise
void initialise()
Unset duplicate fields already registered by other function objects.
Definition: turbulenceFields.C:93
Foam::functionObjects::turbulenceFields::processField
void processField(const word &fieldName, const tmp< GeometricField< Type, fvPatchField, volMesh >> &tvalue)
Process the turbulence field.
Definition: turbulenceFieldsTemplates.C:35
Foam::functionObjects::turbulenceFields::ifK
"Turbulent kinetic energy"
Definition: turbulenceFields.H:245
Foam::Enum< compressibleField >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::turbulenceFields::ifL
"Integral-length/Mixing-length scale"
Definition: turbulenceFields.H:253
turbulenceFieldsTemplates.C
fvMeshFunctionObject.H
Foam::functionObjects::turbulenceFields::incompressibleFieldNames_
static const Enum< incompressibleField > incompressibleFieldNames_
Names for incompressibleField turbulence fields.
Definition: turbulenceFields.H:258
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::functionObjects::turbulenceFields::modelName_
static const word modelName_
Name of the turbulence properties dictionary.
Definition: turbulenceFields.H:261
Foam::functionObjects::turbulenceFields::cfI
"Turbulence intensity"
Definition: turbulenceFields.H:236
Foam::functionObjects::turbulenceFields::compressibleField
compressibleField
Options for the turbulence fields (compressible)
Definition: turbulenceFields.H:223
Foam::functionObjects::turbulenceFields::turbulenceFields
turbulenceFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: turbulenceFields.C:136
Foam::functionObjects::turbulenceFields::cfAlphat
"Turbulence thermal diffusivity"
Definition: turbulenceFields.H:231
Foam::functionObjects::turbulenceFields::ifOmega
"Specific dissipation rate"
Definition: turbulenceFields.H:247
Foam::functionObjects::turbulenceFields::cfL
"Integral-length/Mixing-length scale"
Definition: turbulenceFields.H:235
Foam::HashSet< word, Hash< word > >
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::turbulenceFields::cfOmega
"Specific dissipation rate"
Definition: turbulenceFields.H:227
Foam::functionObjects::turbulenceFields::L
tmp< volScalarField > L(const Model &model) const
Return integral length scale, L, calculated from k and epsilon.
Foam::functionObjects::turbulenceFields::ifNuTilda
"Modified turbulent viscosity"
Definition: turbulenceFields.H:248
Foam::functionObjects::turbulenceFields::cfDevRhoReff
"Divergence of the Reynolds stress"
Definition: turbulenceFields.H:234
Foam::functionObjects::turbulenceFields::prefix_
word prefix_
Name of output-field prefix.
Definition: turbulenceFields.H:272
Foam::functionObjects::turbulenceFields::cfMuEff
"Effective turbulent dynamic viscosity"
Definition: turbulenceFields.H:230
Foam::functionObjects::turbulenceFields::fieldSet_
wordHashSet fieldSet_
Fields to load.
Definition: turbulenceFields.H:275
Foam::functionObjects::turbulenceFields::write
virtual bool write()
Do nothing.
Definition: turbulenceFields.C:350
Foam::functionObjects::turbulenceFields::~turbulenceFields
virtual ~turbulenceFields()=default
Destructor.
Foam::functionObjects::turbulenceFields::ifDevReff
"Deviatoric part of the effective Reynolds stress"
Definition: turbulenceFields.H:252
Switch.H
Foam::functionObjects::turbulenceFields::cfNuTilda
"Modified turbulent viscosity"
Definition: turbulenceFields.H:228
Foam::functionObjects::turbulenceFields::TypeName
TypeName("turbulenceFields")
Runtime type information.
Foam::functionObjects::turbulenceFields::cfEpsilon
"Turbulent kinetic energy dissipation rate"
Definition: turbulenceFields.H:226
HashSet.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::turbulenceFields::read
virtual bool read(const dictionary &)
Read the controls.
Definition: turbulenceFields.C:153
Foam::functionObjects::turbulenceFields::operator=
void operator=(const turbulenceFields &)=delete
No copy assignment.
Foam::functionObjects::turbulenceFields::ifNuEff
"Effective turbulent viscosity"
Definition: turbulenceFields.H:250
Foam::functionObjects::turbulenceFields::nuTilda
tmp< volScalarField > nuTilda(const Model &model) const
Return nuTilda calculated from k and omega.
Foam::functionObjects::turbulenceFields::compressibleFieldNames_
static const Enum< compressibleField > compressibleFieldNames_
Names for compressibleField turbulence fields.
Definition: turbulenceFields.H:240
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::turbulenceFields::cfK
"Turbulent kinetic energy"
Definition: turbulenceFields.H:225
Foam::functionObjects::turbulenceFields::I
tmp< volScalarField > I(const Model &model) const
Return turbulence intensity, I, calculated from k and U.
Foam::functionObjects::turbulenceFields::incompressibleField
incompressibleField
Options for the turbulence fields (incompressible)
Definition: turbulenceFields.H:243
Foam::functionObjects::turbulenceFields::ifNut
"Turbulent viscosity"
Definition: turbulenceFields.H:249
Foam::functionObjects::turbulenceFields::ifEpsilon
"Turbulent kinetic energy dissipation rate"
Definition: turbulenceFields.H:246
Foam::functionObjects::turbulenceFields::initialised_
bool initialised_
Flag to track initialisation.
Definition: turbulenceFields.H:269
Foam::functionObjects::turbulenceFields::cfAlphaEff
"Effective turbulence thermal diffusivity"
Definition: turbulenceFields.H:232
Foam::functionObjects::turbulenceFields::compressible
bool compressible()
Return true if compressible turbulence model is identified.
Definition: turbulenceFields.C:114
Foam::functionObjects::turbulenceFields::execute
virtual bool execute()
Calculate turbulence fields.
Definition: turbulenceFields.C:192
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::functionObjects::turbulenceFields::ifI
"Turbulence intensity"
Definition: turbulenceFields.H:254
Foam::functionObjects::turbulenceFields::ifR
"Reynolds stress tensor"
Definition: turbulenceFields.H:251
Foam::functionObjects::turbulenceFields::cfR
"Reynolds stress tensor"
Definition: turbulenceFields.H:233
Foam::functionObjects::turbulenceFields::cfMut
"Turbulent dynamic viscosity"
Definition: turbulenceFields.H:229
Enum.H
Foam::functionObjects::turbulenceFields
Computes various turbulence-related quantities that are not typically output during calculations,...
Definition: turbulenceFields.H:214