turbulenceFields.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-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2018 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 "turbulenceFields.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace functionObjects
39 {
40  defineTypeNameAndDebug(turbulenceFields, 0);
41 
43  (
44  functionObject,
45  turbulenceFields,
46  dictionary
47  );
48 }
49 }
50 
51 const Foam::Enum
52 <
54 >
56 ({
57  { compressibleField::cfK, "k" },
58  { compressibleField::cfEpsilon, "epsilon" },
59  { compressibleField::cfOmega, "omega" },
60  { compressibleField::cfNuTilda, "nuTilda" },
61  { compressibleField::cfMut, "mut" },
62  { compressibleField::cfMuEff, "muEff" },
63  { compressibleField::cfAlphat, "alphat" },
64  { compressibleField::cfAlphaEff, "alphaEff" },
65  { compressibleField::cfR, "R" },
66  { compressibleField::cfDevRhoReff, "devRhoReff" },
67  { compressibleField::cfL, "L" },
68  { compressibleField::cfI, "I" },
69 });
70 
71 
72 const Foam::Enum
73 <
75 >
77 ({
78  { incompressibleField::ifK, "k" },
79  { incompressibleField::ifEpsilon, "epsilon" },
80  { incompressibleField::ifOmega, "omega" },
81  { incompressibleField::ifNuTilda, "nuTilda" },
82  { incompressibleField::ifNut, "nut" },
83  { incompressibleField::ifNuEff, "nuEff" },
84  { incompressibleField::ifR, "R" },
85  { incompressibleField::ifDevReff, "devReff" },
86  { incompressibleField::ifL, "L" },
87  { incompressibleField::ifI, "I" },
88 });
89 
90 
92 (
94 );
95 
96 
97 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
98 
100 {
102  {
103  return true;
104  }
106  {
107  return false;
108  }
109 
111  << "Turbulence model not found in database, deactivating"
112  << exit(FatalError);
113 
114  return false;
115 }
116 
117 
118 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
119 
120 Foam::functionObjects::turbulenceFields::turbulenceFields
121 (
122  const word& name,
123  const Time& runTime,
124  const dictionary& dict
125 )
126 :
128  fieldSet_()
129 {
130  read(dict);
131 }
132 
133 
134 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
135 
137 {}
138 
139 
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 
143 {
145 
146  if (dict.found("field"))
147  {
148  fieldSet_.insert(dict.get<word>("field"));
149  }
150  else
151  {
152  fieldSet_.insert(dict.get<wordList>("fields"));
153  }
154 
155  Info<< type() << " " << name() << ": ";
156  if (fieldSet_.size())
157  {
158  Info<< "storing fields:" << nl;
159  for (const word& f : fieldSet_)
160  {
161  Info<< " " << modelName << ':' << f << nl;
162  }
163  Info<< endl;
164  }
165  else
166  {
167  Info<< "no fields requested to be stored" << nl << endl;
168  }
169 
170  return true;
171 }
172 
173 
175 {
176  bool comp = compressible();
177 
178  if (comp)
179  {
180  const compressible::turbulenceModel& model =
181  obr_.lookupObject<compressible::turbulenceModel>(modelName);
182 
183  for (const word& f : fieldSet_)
184  {
185  switch (compressibleFieldNames_[f])
186  {
187  case cfK:
188  {
189  processField<scalar>(f, model.k());
190  break;
191  }
192  case cfEpsilon:
193  {
194  processField<scalar>(f, model.epsilon());
195  break;
196  }
197  case cfOmega:
198  {
199  processField<scalar>(f, omega(model));
200  break;
201  }
202  case cfNuTilda:
203  {
204  processField<scalar>(f, nuTilda(model));
205  break;
206  }
207  case cfMut:
208  {
209  processField<scalar>(f, model.mut());
210  break;
211  }
212  case cfMuEff:
213  {
214  processField<scalar>(f, model.muEff());
215  break;
216  }
217  case cfAlphat:
218  {
219  processField<scalar>(f, model.alphat());
220  break;
221  }
222  case cfAlphaEff:
223  {
224  processField<scalar>(f, model.alphaEff());
225  break;
226  }
227  case cfR:
228  {
229  processField<symmTensor>(f, model.R());
230  break;
231  }
232  case cfDevRhoReff:
233  {
234  processField<symmTensor>(f, model.devRhoReff());
235  break;
236  }
237  case cfL:
238  {
239  processField<scalar>(f, L(model));
240  break;
241  }
242  case cfI:
243  {
244  processField<scalar>(f, I(model));
245  break;
246  }
247  default:
248  {
250  << "Invalid field selection" << abort(FatalError);
251  }
252  }
253  }
254  }
255  else
256  {
257  const incompressible::turbulenceModel& model =
258  obr_.lookupObject<incompressible::turbulenceModel>(modelName);
259 
260  for (const word& f : fieldSet_)
261  {
262  switch (incompressibleFieldNames_[f])
263  {
264  case ifK:
265  {
266  processField<scalar>(f, model.k());
267  break;
268  }
269  case ifEpsilon:
270  {
271  processField<scalar>(f, model.epsilon());
272  break;
273  }
274  case ifOmega:
275  {
276  processField<scalar>(f, omega(model));
277  break;
278  }
279  case ifNuTilda:
280  {
281  processField<scalar>(f, nuTilda(model));
282  break;
283  }
284  case ifNut:
285  {
286  processField<scalar>(f, model.nut());
287  break;
288  }
289  case ifNuEff:
290  {
291  processField<scalar>(f, model.nuEff());
292  break;
293  }
294  case ifR:
295  {
296  processField<symmTensor>(f, model.R());
297  break;
298  }
299  case ifDevReff:
300  {
301  processField<symmTensor>(f, model.devReff());
302  break;
303  }
304  case ifL:
305  {
306  processField<scalar>(f, L(model));
307  break;
308  }
309  case ifI:
310  {
311  processField<scalar>(f, I(model));
312  break;
313  }
314  default:
315  {
317  << "Invalid field selection" << abort(FatalError);
318  }
319  }
320  }
321  }
322 
323  return true;
324 }
325 
326 
328 {
329  for (const word& f : fieldSet_)
330  {
331  const word fieldName = modelName + ':' + f;
332  writeObject(fieldName);
333  }
334 
335  return true;
336 }
337 
338 
339 // ************************************************************************* //
Foam::turbulenceModel::R
virtual tmp< volSymmTensorField > R() const =0
Return the Reynolds stress tensor.
runTime
engineTime & runTime
Definition: createEngineTime.H:13
L
const vector L(dict.get< vector >("L"))
Foam::functionObjects::regionFunctionObject::obr_
const objectRegistry & obr_
Reference to the region objectRegistry.
Definition: regionFunctionObject.H:100
Foam::Enum
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: IOstreamOption.H:51
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:62
Foam::functionObjects::turbulenceFields::incompressibleFieldNames_
static const Enum< incompressibleField > incompressibleFieldNames_
Definition: turbulenceFields.H:224
Foam::functionObjects::turbulenceFields::modelName
static const word modelName
Definition: turbulenceFields.H:226
Foam::turbulenceModel::nut
virtual tmp< volScalarField > nut() const =0
Return the turbulence viscosity.
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::functionObjects::turbulenceFields::compressibleField
compressibleField
Definition: turbulenceFields.H:194
turbulentTransportModel.H
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:100
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::addToRunTimeSelectionTable
addToRunTimeSelectionTable(functionObject, add, dictionary)
Foam::objectRegistry::foundObject
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
Definition: objectRegistryTemplates.C:379
Foam::IncompressibleTurbulenceModel::devReff
virtual tmp< volSymmTensorField > devReff() const
Return the effective stress tensor.
Definition: IncompressibleTurbulenceModel.C:104
Foam::functionObjects::turbulenceFields::write
virtual bool write()
Do nothing.
Definition: turbulenceFields.C:327
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
compressible
bool compressible
Definition: pEqn.H:3
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::functionObjects::regionFunctionObject::read
virtual bool read(const dictionary &dict)
Read optional controls.
Definition: regionFunctionObject.C:166
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::turbulenceModel::k
virtual tmp< volScalarField > k() const =0
Return the turbulence kinetic energy.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::functionObjects::turbulenceFields::read
virtual bool read(const dictionary &)
Read the controls.
Definition: turbulenceFields.C:142
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::functionObjects::defineTypeNameAndDebug
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
Foam::functionObjects::turbulenceFields::compressibleFieldNames_
static const Enum< compressibleField > compressibleFieldNames_
Definition: turbulenceFields.H:209
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::functionObjects::turbulenceFields::incompressibleField
incompressibleField
Definition: turbulenceFields.H:211
Foam::ThermalDiffusivity::alphaEff
virtual tmp< volScalarField > alphaEff() const
Return the effective turbulent thermal diffusivity for enthalpy.
Definition: ThermalDiffusivity.H:160
f
labelList f(nPoints)
Foam::ThermalDiffusivity
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
Definition: phaseCompressibleTurbulenceModelFwd.H:47
Foam::ThermalDiffusivity::alphat
virtual tmp< volScalarField > alphat() const
Return the turbulent thermal diffusivity for enthalpy [kg/m/s].
Definition: ThermalDiffusivity.C:121
Foam::List< word >
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
turbulenceFields.H
Foam::IncompressibleTurbulenceModel
Templated abstract base class for single-phase incompressible turbulence models.
Definition: IncompressibleTurbulenceModel.H:55
Foam::functionObjects::turbulenceFields::compressible
bool compressible()
Return true if compressible turbulence model is identified.
Definition: turbulenceFields.C:99
Foam::functionObjects::turbulenceFields::execute
virtual bool execute()
Calculate turbulence fields.
Definition: turbulenceFields.C:174
Foam::turbulenceModel::nuEff
virtual tmp< volScalarField > nuEff() const =0
Return the effective viscosity.
Foam::turbulenceModel::epsilon
virtual tmp< volScalarField > epsilon() const =0
Return the turbulence kinetic energy dissipation rate.
turbulentFluidThermoModel.H
Foam::functionObjects::turbulenceFields::~turbulenceFields
virtual ~turbulenceFields()
Destructor.
Definition: turbulenceFields.C:136
Foam::I
static const Identity< scalar > I
Definition: Identity.H:95