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 | Copyright (C) 2013-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 "turbulenceFields.H"
27 #include "dictionary.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(turbulenceFields, 0);
36 
37  template<>
39  {
40  "k",
41  "epsilon",
42  "mut",
43  "muEff",
44  "alphat",
45  "alphaEff",
46  "R",
47  "devRhoReff"
48  };
51 
52  template<>
54  {
55  "k",
56  "epsilon",
57  "nut",
58  "nuEff",
59  "R",
60  "devReff"
61  };
64 
66 }
67 
68 
69 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
70 
72 {
74  {
75  return true;
76  }
78  {
79  return false;
80  }
81  else
82  {
84  << "Turbulence model not found in database, deactivating";
85  active_ = false;
86  }
87 
88  return false;
89 }
90 
91 
92 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
93 
95 (
96  const word& name,
97  const objectRegistry& obr,
98  const dictionary& dict,
99  const bool loadFromFiles
100 )
101 :
102  name_(name),
103  obr_(obr),
104  active_(true),
105  fieldSet_(),
106  log_(true)
107 {
108  // Check if the available mesh is an fvMesh otherise deactivate
109  if (isA<fvMesh>(obr_))
110  {
111  read(dict);
112  }
113  else
114  {
115  active_ = false;
117  << "No fvMesh available, deactivating " << name_
118  << endl;
119  }
120 }
121 
122 
123 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
124 
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
130 
132 {
133  if (active_)
134  {
135  log_.readIfPresent("log", dict);
136  fieldSet_.insert(wordList(dict.lookup("fields")));
137 
138  Info<< type() << " " << name_ << ": ";
139  if (log_)
140  {
141  Info<< type() << " " << name_ << " output:" << nl;
142  if (fieldSet_.size())
143  {
144  Info<< "storing fields:" << nl;
145  forAllConstIter(wordHashSet, fieldSet_, iter)
146  {
147  Info<< " " << modelName << ':' << iter.key() << nl;
148  }
149  Info<< endl;
150  }
151  else
152  {
153  Info<< "no fields requested to be stored" << nl << endl;
154  }
155  }
156  }
157 }
158 
159 
161 {
162  bool comp = compressible();
163 
164  if (!active_)
165  {
166  return;
167  }
168 
169  if (comp)
170  {
171  const compressible::turbulenceModel& model =
172  obr_.lookupObject<compressible::turbulenceModel>(modelName);
173 
174  forAllConstIter(wordHashSet, fieldSet_, iter)
175  {
176  const word& f = iter.key();
177  switch (compressibleFieldNames_[f])
178  {
179  case cfK:
180  {
181  processField<scalar>(f, model.k());
182  break;
183  }
184  case cfEpsilon:
185  {
186  processField<scalar>(f, model.epsilon());
187  break;
188  }
189  case cfMut:
190  {
191  processField<scalar>(f, model.mut());
192  break;
193  }
194  case cfMuEff:
195  {
196  processField<scalar>(f, model.muEff());
197  break;
198  }
199  case cfAlphat:
200  {
201  processField<scalar>(f, model.alphat());
202  break;
203  }
204  case cfAlphaEff:
205  {
206  processField<scalar>(f, model.alphaEff());
207  break;
208  }
209  case cfR:
210  {
211  processField<symmTensor>(f, model.R());
212  break;
213  }
214  case cfDevRhoReff:
215  {
216  processField<symmTensor>(f, model.devRhoReff());
217  break;
218  }
219  default:
220  {
222  << "Invalid field selection" << abort(FatalError);
223  }
224  }
225  }
226  }
227  else
228  {
229  const incompressible::turbulenceModel& model =
230  obr_.lookupObject<incompressible::turbulenceModel>(modelName);
231 
232  forAllConstIter(wordHashSet, fieldSet_, iter)
233  {
234  const word& f = iter.key();
235  switch (incompressibleFieldNames_[f])
236  {
237  case ifK:
238  {
239  processField<scalar>(f, model.k());
240  break;
241  }
242  case ifEpsilon:
243  {
244  processField<scalar>(f, model.epsilon());
245  break;
246  }
247  case ifNut:
248  {
249  processField<scalar>(f, model.nut());
250  break;
251  }
252  case ifNuEff:
253  {
254  processField<scalar>(f, model.nuEff());
255  break;
256  }
257  case ifR:
258  {
259  processField<symmTensor>(f, model.R());
260  break;
261  }
262  case ifDevReff:
263  {
264  processField<symmTensor>(f, model.devReff());
265  break;
266  }
267  default:
268  {
270  << "Invalid field selection" << abort(FatalError);
271  }
272  }
273  }
274  }
275 }
276 
277 
279 {}
280 
281 
283 {}
284 
285 
287 {}
288 
289 
290 // ************************************************************************* //
Foam::turbulenceModel::R
virtual tmp< volSymmTensorField > R() const =0
Return the Reynolds stress tensor.
Foam::turbulenceFields::active_
bool active_
on/off switch
Definition: turbulenceFields.H:208
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::turbulenceModel::nut
virtual tmp< volScalarField > nut() const =0
Return the turbulence viscosity.
Foam::turbulenceFields::read
virtual void read(const dictionary &)
Read the field min/max data.
Definition: turbulenceFields.C:131
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
turbulentTransportModel.H
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::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:97
Foam::turbulenceFields::turbulenceFields
turbulenceFields(const turbulenceFields &)
Disallow default bitwise copy construct.
Foam::turbulenceFields::compressibleFieldNames_
static const NamedEnum< compressibleField, 8 > compressibleFieldNames_
Definition: turbulenceFields.H:182
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::HashSet
A HashTable with keys but without contents.
Definition: HashSet.H:59
Foam::turbulenceFields::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: turbulenceFields.C:282
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::IncompressibleTurbulenceModel::devReff
virtual tmp< volSymmTensorField > devReff() const
Return the effective stress tensor.
Definition: IncompressibleTurbulenceModel.C:102
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
dict
dictionary dict
Definition: searchingEngine.H:14
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::turbulenceModel::k
virtual tmp< volScalarField > k() const =0
Return the turbulence kinetic energy.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::turbulenceFields::obr_
const objectRegistry & obr_
Definition: turbulenceFields.H:205
Foam::turbulenceFields::modelName
static const word modelName
Definition: turbulenceFields.H:195
Foam::turbulenceFields::~turbulenceFields
virtual ~turbulenceFields()
Destructor.
Definition: turbulenceFields.C:125
Foam::objectRegistry::foundObject
bool foundObject(const word &name) const
Is the named Type found?
Definition: objectRegistryTemplates.C:142
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::ThermalDiffusivity::alphaEff
virtual tmp< volScalarField > alphaEff() const
Return the effective turbulent thermal diffusivity for enthalpy.
Definition: ThermalDiffusivity.H:158
Foam::turbulenceFields::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: turbulenceFields.C:278
f
labelList f(nPoints)
Foam::ThermalDiffusivity
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
Definition: ThermalDiffusivity.H:48
Foam::ThermalDiffusivity::alphat
virtual tmp< volScalarField > alphat() const
Return the turbulent thermal diffusivity for enthalpy [kg/m/s].
Definition: ThermalDiffusivity.C:119
compressible
bool compressible
Definition: pEqn.H:40
dictionary.H
Foam::turbulenceFields::write
virtual void write()
Write.
Definition: turbulenceFields.C:286
Foam::turbulenceFields::execute
virtual void execute()
Execute, currently does nothing.
Definition: turbulenceFields.C:160
turbulenceFields.H
Foam::IncompressibleTurbulenceModel
Templated abstract base class for single-phase incompressible turbulence models.
Definition: IncompressibleTurbulenceModel.H:52
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::turbulenceModel::nuEff
virtual tmp< volScalarField > nuEff() const =0
Return the effective viscosity.
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::turbulenceModel::epsilon
virtual tmp< volScalarField > epsilon() const =0
Return the turbulence kinetic energy dissipation rate.
Foam::turbulenceFields::incompressibleFieldNames_
static const NamedEnum< incompressibleField, 6 > incompressibleFieldNames_
Definition: turbulenceFields.H:193
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
turbulentFluidThermoModel.H
Foam::turbulenceFields::compressible
bool compressible()
Return true if compressible turbulence model is identified.
Definition: turbulenceFields.C:71
Foam::NamedEnum
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52