basicThermo.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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2017-2019 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::basicThermo
29 
30 Description
31  Abstract base-class for fluid and solid thermodynamic properties
32 
33  An important concept is that the thermo can share an existing T
34  (similar to p) in which case it will not try to update it. This gets
35  triggered purely on construction order - the first one to register
36  T is responsible for updating it. Note that the mechanism also means
37  that if multiple thermos are running on the same mesh, only the first one
38  will update the temperature. The behaviour can be overridden using the
39  'updateT' dictionary entry.
40 
41 SourceFiles
42  basicThermo.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef basicThermo_H
47 #define basicThermo_H
48 
49 #include "volFields.H"
50 #include "typeInfo.H"
51 #include "IOdictionary.H"
52 #include "autoPtr.H"
53 #include "wordIOList.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class basicThermo Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class basicThermo
65 :
66  public IOdictionary
67 {
68 
69 protected:
70 
71  // Protected data
72 
73  //- Phase-name
74  const word& phaseName_;
75 
76 
77  // Fields
78 
79  //- Pressure [Pa]
81 
82  bool pOwner_;
83 
84  //- Temperature [K]
86 
87  bool TOwner_;
88 
89  //- Laminar thermal diffusivity [kg/m/s]
91 
92  //- Should the dpdt term be included in the enthalpy equation
93  Switch dpdt_;
94 
95 
96  // Protected Member Functions
97 
98  //- Construct as copy (not implemented)
99  basicThermo(const basicThermo&);
100 
101  //- Look up or construct field
103  (
104  const fvMesh& mesh,
105  const word&,
106  bool& isOwner
107  );
108 
109  //- Return the enthalpy/internal energy field boundary types
110  // by interrogating the temperature field boundary types
112 
113  //- Return the enthalpy/internal energy field boundary base types
114  // by interrogating the temperature field boundary types
116 
117 
118 public:
119 
120  //- Runtime type information
121  TypeName("basicThermo");
122 
123 
124  //- Declare run-time constructor selection table
126  (
127  autoPtr,
128  basicThermo,
129  fvMesh,
130  (const fvMesh& mesh, const word& phaseName),
131  (mesh, phaseName)
132  );
133 
134 
135  //- Declare run-time constructor selection table for dictionary based
137  (
138  autoPtr,
139  basicThermo,
140  fvMeshDictPhase,
141  (const fvMesh& mesh, const word& phaseName, const word& dictName),
142  (mesh, phaseName, dictName)
143  );
144 
145 
146  // Constructors
147 
148  //- Construct from mesh and phase name
150  (
151  const fvMesh&,
152  const word& phaseName
153  );
154 
155  //- Construct from mesh, dictionary and phase name
157  (
158  const fvMesh&,
159  const dictionary&,
160  const word& phaseName
161  );
162 
163  //- Construct from mesh, phase name and explicit naming of the
164  // dictionary (so it can be shared amongst phases).
166  (
167  const fvMesh&,
168  const word& phaseName,
169  const word& dictionaryName
170  );
171 
172 
173  // Selectors
174 
175  //- Generic lookup for thermodynamics package thermoTypeName
176  template<class Thermo, class Table>
177  static typename Table::iterator lookupThermo
178  (
179  const dictionary& thermoTypeDict,
180  Table* tablePtr,
181  std::initializer_list<const char*> cmptNames,
182  const word& thermoTypeName
183  );
184 
185  //- Generic lookup for each of the related thermodynamics packages
186  template<class Thermo, class Table>
187  static typename Table::iterator lookupThermo
188  (
189  const dictionary& thermoDict,
190  Table* tablePtr
191  );
192 
193  //- Generic New for each of the related thermodynamics packages
194  template<class Thermo>
195  static autoPtr<Thermo> New
196  (
197  const fvMesh&,
198  const word& phaseName=word::null
199  );
200 
201  //- Generic New for each of the related thermodynamics packages
202  template<class Thermo>
203  static autoPtr<Thermo> New
204  (
205  const fvMesh&,
206  const dictionary&,
207  const word& phaseName=word::null
208  );
209 
210  //- Generic New for each of the related thermodynamics packages
211  template<class Thermo>
212  static autoPtr<Thermo> New
213  (
214  const fvMesh&,
215  const word& phaseName,
216  const word& dictName
217  );
218 
219  //- Specialisation of the Generic New for basicThermo
221  (
222  const fvMesh&,
223  const word& phaseName=word::null
224  );
225 
226 
227  //- Destructor
228  virtual ~basicThermo();
229 
230 
231  // Member functions
232 
233  static const word dictName;
234 
236  (
237  const word& name,
238  const word& phaseName
239  )
240  {
241  return IOobject::groupName(name, phaseName);
242  }
243 
244  word phasePropertyName(const word& name) const
245  {
247  }
248 
249  static const basicThermo& lookupThermo(const fvPatchScalarField& pf);
250 
251  //- Check that the thermodynamics package is consistent
252  // with energy forms supported by the application
253  void validate
254  (
255  const string& app,
256  const word&
257  ) const;
258 
259  //- Check that the thermodynamics package is consistent
260  // with energy forms supported by the application
261  void validate
262  (
263  const string& app,
264  const word&,
265  const word&
266  ) const;
267 
268  //- Check that the thermodynamics package is consistent
269  // with energy forms supported by the application
270  void validate
271  (
272  const string& app,
273  const word&,
274  const word&,
275  const word&
276  ) const;
277 
278  //- Check that the thermodynamics package is consistent
279  // with energy forms supported by the application
280  void validate
281  (
282  const string& app,
283  const word&,
284  const word&,
285  const word&,
286  const word&
287  ) const;
288 
289  //- Split name of thermo package into a list of the components names
291  (
292  const word& thermoName,
293  const int nCmpt
294  );
295 
296  //- Update properties
297  virtual void correct() = 0;
298 
299  //- Return the name of the thermo physics
300  virtual word thermoName() const = 0;
301 
302  //- Return true if the equation of state is incompressible
303  // i.e. rho != f(p)
304  virtual bool incompressible() const = 0;
305 
306  //- Return true if the equation of state is isochoric
307  // i.e. rho = const
308  virtual bool isochoric() const = 0;
309 
310  //- Should the dpdt term be included in the enthalpy equation
311  Switch dpdt() const
312  {
313  return dpdt_;
314  }
315 
316  //- Should T be updated
317  Switch updateT() const
318  {
319  return TOwner_;
320  }
321 
322 
323  // Access to thermodynamic state variables
324 
325  //- Pressure [Pa]
326  // Non-const access allowed for transport equations
327  virtual volScalarField& p();
328 
329  //- Pressure [Pa]
330  virtual const volScalarField& p() const;
331 
332  //- Density [kg/m^3]
333  virtual tmp<volScalarField> rho() const = 0;
334 
335  //- Density for patch [kg/m^3]
336  virtual tmp<scalarField> rho(const label patchi) const = 0;
337 
338  //- Enthalpy/Internal energy [J/kg]
339  // Non-const access allowed for transport equations
340  virtual volScalarField& he() = 0;
341 
342  //- Enthalpy/Internal energy [J/kg]
343  virtual const volScalarField& he() const = 0;
344 
345  //- Enthalpy/Internal energy
346  // for given pressure and temperature [J/kg]
347  virtual tmp<volScalarField> he
348  (
349  const volScalarField& p,
350  const volScalarField& T
351  ) const = 0;
352 
353  //- Enthalpy/Internal energy for cell-set [J/kg]
354  virtual tmp<scalarField> he
355  (
356  const scalarField& p,
357  const scalarField& T,
358  const labelList& cells
359  ) const = 0;
360 
361  //- Enthalpy/Internal energy for patch [J/kg]
362  virtual tmp<scalarField> he
363  (
364  const scalarField& p,
365  const scalarField& T,
366  const label patchi
367  ) const = 0;
368 
369  //- Chemical enthalpy [J/kg]
370  virtual tmp<volScalarField> hc() const = 0;
371 
372  //- Temperature from enthalpy/internal energy for cell-set
373  virtual tmp<scalarField> THE
374  (
375  const scalarField& h,
376  const scalarField& p,
377  const scalarField& T0, // starting temperature
378  const labelList& cells
379  ) const = 0;
380 
381  //- Temperature from enthalpy/internal energy for patch
382  virtual tmp<scalarField> THE
383  (
384  const scalarField& h,
385  const scalarField& p,
386  const scalarField& T0, // starting temperature
387  const label patchi
388  ) const = 0;
389 
390 
391  // Fields derived from thermodynamic state variables
392 
393  //- Temperature [K]
394  virtual const volScalarField& T() const;
395 
396  //- Temperature [K]
397  // Non-const access allowed for transport equations
398  virtual volScalarField& T();
399 
400  //- Heat capacity at constant pressure [J/kg/K]
401  virtual tmp<volScalarField> Cp() const = 0;
402 
403  //- Heat capacity at constant pressure for patch [J/kg/K]
404  virtual tmp<scalarField> Cp
405  (
406  const scalarField& p,
407  const scalarField& T,
408  const label patchi
409  ) const = 0;
410 
411  //- Heat capacity at constant volume [J/kg/K]
412  virtual tmp<volScalarField> Cv() const = 0;
413 
414  //- Heat capacity at constant volume for patch [J/kg/K]
415  virtual tmp<scalarField> Cv
416  (
417  const scalarField& p,
418  const scalarField& T,
419  const label patchi
420  ) const = 0;
421 
422  //- Gamma = Cp/Cv []
423  virtual tmp<volScalarField> gamma() const = 0;
424 
425  //- Gamma = Cp/Cv for patch []
426  virtual tmp<scalarField> gamma
427  (
428  const scalarField& p,
429  const scalarField& T,
430  const label patchi
431  ) const = 0;
432 
433  //- Heat capacity at constant pressure/volume [J/kg/K]
434  virtual tmp<volScalarField> Cpv() const = 0;
435 
436  //- Heat capacity at constant pressure/volume for patch [J/kg/K]
437  virtual tmp<scalarField> Cpv
438  (
439  const scalarField& p,
440  const scalarField& T,
441  const label patchi
442  ) const = 0;
443 
444  //- Heat capacity ratio []
445  virtual tmp<volScalarField> CpByCpv() const = 0;
446 
447  //- Heat capacity ratio for patch []
448  virtual tmp<scalarField> CpByCpv
449  (
450  const scalarField& p,
451  const scalarField& T,
452  const label patchi
453  ) const = 0;
454 
455  //- Molecular weight [kg/kmol]
456  virtual tmp<volScalarField> W() const = 0;
457 
458 
459  // Access to transport state variables
460 
461  //- Thermal diffusivity for enthalpy of mixture [kg/m/s]
462  virtual const volScalarField& alpha() const;
463 
464  //- Thermal diffusivity for enthalpy of mixture for patch [kg/m/s]
465  virtual const scalarField& alpha
466  (
467  const label patchi
468  ) const;
469 
470 
471  // Fields derived from transport state variables
472 
473  //- Thermal diffusivity for temperature of mixture [J/m/s/K]
474  virtual tmp<volScalarField> kappa() const = 0;
475 
476  //- Thermal diffusivity for temperature
477  // of mixture for patch [J/m/s/K]
478  virtual tmp<scalarField> kappa
479  (
480  const label patchi
481  ) const = 0;
482 
483  //- Thermal diffusivity for energy of mixture [kg/m/s]
484  virtual tmp<volScalarField> alphahe() const = 0;
485 
486  //- Thermal diffusivity for energy of mixture for patch [kg/m/s]
487  virtual tmp<scalarField> alphahe(const label patchi) const = 0;
488 
489  //- Effective thermal diffusivity for temperature
490  // of mixture [J/m/s/K]
492  (
493  const volScalarField&
494  ) const = 0;
495 
496  //- Effective thermal diffusivity for temperature
497  // of mixture for patch [J/m/s/K]
498  virtual tmp<scalarField> kappaEff
499  (
500  const scalarField& alphat,
501  const label patchi
502  ) const = 0;
503 
504  //- Effective thermal diffusivity of mixture [kg/m/s]
506  (
507  const volScalarField& alphat
508  ) const = 0;
509 
510  //- Effective thermal diffusivity of mixture for patch [kg/m/s]
511  virtual tmp<scalarField> alphaEff
512  (
513  const scalarField& alphat,
514  const label patchi
515  ) const = 0;
516 
517 
518  //- Read thermophysical properties dictionary
519  virtual bool read();
520 };
521 
522 
523 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
524 
525 } // End namespace Foam
526 
527 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
528 
529 #ifdef NoRepository
530  #include "basicThermoTemplates.C"
531 #endif
532 
533 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
534 
535 #endif
536 
537 // ************************************************************************* //
Foam::fvPatchField< scalar >
wordIOList.H
volFields.H
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::basicThermo::heBoundaryTypes
wordList heBoundaryTypes()
Return the enthalpy/internal energy field boundary types.
Definition: basicThermo.C:85
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::basicThermo::W
virtual tmp< volScalarField > W() const =0
Molecular weight [kg/kmol].
basicThermoTemplates.C
Foam::basicThermo::~basicThermo
virtual ~basicThermo()
Destructor.
Definition: basicThermo.C:317
typeInfo.H
Foam::basicThermo::p
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:512
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::basicThermo::Cp
virtual tmp< volScalarField > Cp() const =0
Heat capacity at constant pressure [J/kg/K].
Foam::basicThermo::dictName
static const word dictName
Definition: basicThermo.H:232
Foam::basicThermo::read
virtual bool read()
Read thermophysical properties dictionary.
Definition: basicThermo.C:548
Foam::basicThermo::phasePropertyName
word phasePropertyName(const word &name) const
Definition: basicThermo.H:243
Foam::basicThermo::alpha_
volScalarField alpha_
Laminar thermal diffusivity [kg/m/s].
Definition: basicThermo.H:89
Foam::basicThermo::TOwner_
bool TOwner_
Definition: basicThermo.H:86
Foam::basicThermo
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:63
Foam::basicThermo::gamma
virtual tmp< volScalarField > gamma() const =0
Gamma = Cp/Cv [].
Foam::baseIOdictionary::name
const word & name() const
Definition: baseIOdictionary.C:82
Foam::basicThermo::kappaEff
virtual tmp< volScalarField > kappaEff(const volScalarField &) const =0
Effective thermal diffusivity for temperature.
Foam::basicThermo::isochoric
virtual bool isochoric() const =0
Return true if the equation of state is isochoric.
Foam::basicThermo::hc
virtual tmp< volScalarField > hc() const =0
Chemical enthalpy [J/kg].
Foam::basicThermo::THE
virtual tmp< scalarField > THE(const scalarField &h, const scalarField &p, const scalarField &T0, const labelList &cells) const =0
Temperature from enthalpy/internal energy for cell-set.
Foam::basicThermo::rho
virtual tmp< volScalarField > rho() const =0
Density [kg/m^3].
Foam::basicThermo::heBoundaryBaseTypes
wordList heBoundaryBaseTypes()
Return the enthalpy/internal energy field boundary base types.
Definition: basicThermo.C:54
Foam::basicThermo::dpdt_
Switch dpdt_
Should the dpdt term be included in the enthalpy equation.
Definition: basicThermo.H:92
Foam::basicThermo::alphaEff
virtual tmp< volScalarField > alphaEff(const volScalarField &alphat) const =0
Effective thermal diffusivity of mixture [kg/m/s].
Foam::basicThermo::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, basicThermo, fvMesh,(const fvMesh &mesh, const word &phaseName),(mesh, phaseName))
Declare run-time constructor selection table.
Foam::basicThermo::correct
virtual void correct()=0
Update properties.
Foam::basicThermo::phasePropertyName
static word phasePropertyName(const word &name, const word &phaseName)
Definition: basicThermo.H:235
Foam::basicThermo::updateT
Switch updateT() const
Should T be updated.
Definition: basicThermo.H:316
Foam::Field< scalar >
Foam::constant::universal::h
const dimensionedScalar h
Planck constant.
Definition: setRegionSolidFields.H:33
Foam::basicThermo::thermoName
virtual word thermoName() const =0
Return the name of the thermo physics.
Foam::basicThermo::alphahe
virtual tmp< volScalarField > alphahe() const =0
Thermal diffusivity for energy of mixture [kg/m/s].
Foam::basicThermo::splitThermoName
static wordList splitThermoName(const word &thermoName, const int nCmpt)
Split name of thermo package into a list of the components names.
Definition: basicThermo.C:451
Foam::basicThermo::pOwner_
bool pOwner_
Definition: basicThermo.H:81
Foam::basicThermo::kappa
virtual tmp< volScalarField > kappa() const =0
Thermal diffusivity for temperature of mixture [J/m/s/K].
Foam::dictionary::dictName
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionary.H:458
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::basicThermo::New
static autoPtr< Thermo > New(const fvMesh &, const word &phaseName=word::null)
Generic New for each of the related thermodynamics packages.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::basicThermo::CpByCpv
virtual tmp< volScalarField > CpByCpv() const =0
Heat capacity ratio [].
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::basicThermo::validate
void validate(const string &app, const word &) const
Check that the thermodynamics package is consistent.
Definition: basicThermo.C:357
Foam::basicThermo::T_
volScalarField & T_
Temperature [K].
Definition: basicThermo.H:84
IOdictionary.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::basicThermo::alpha
virtual const volScalarField & alpha() const
Thermal diffusivity for enthalpy of mixture [kg/m/s].
Definition: basicThermo.C:536
thermoDict
const dictionary & thermoDict
Definition: EEqn.H:16
Foam::basicThermo::basicThermo
basicThermo(const basicThermo &)
Construct as copy (not implemented)
Foam::basicThermo::p_
volScalarField & p_
Pressure [Pa].
Definition: basicThermo.H:79
Foam::basicThermo::T
virtual const volScalarField & T() const
Temperature [K].
Definition: basicThermo.C:524
Foam::List< word >
Foam::basicThermo::Cpv
virtual tmp< volScalarField > Cpv() const =0
Heat capacity at constant pressure/volume [J/kg/K].
Foam::basicThermo::dpdt
Switch dpdt() const
Should the dpdt term be included in the enthalpy equation.
Definition: basicThermo.H:310
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
Foam::basicThermo::phaseName_
const word & phaseName_
Phase-name.
Definition: basicThermo.H:73
Foam::basicThermo::Cv
virtual tmp< volScalarField > Cv() const =0
Heat capacity at constant volume [J/kg/K].
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::basicThermo::he
virtual volScalarField & he()=0
Enthalpy/Internal energy [J/kg].
T0
scalar T0
Definition: createFields.H:22
Foam::basicThermo::lookupThermo
static Table::iterator lookupThermo(const dictionary &thermoTypeDict, Table *tablePtr, std::initializer_list< const char * > cmptNames, const word &thermoTypeName)
Generic lookup for thermodynamics package thermoTypeName.
Definition: basicThermoTemplates.C:35
Foam::basicThermo::lookupOrConstruct
static volScalarField & lookupOrConstruct(const fvMesh &mesh, const word &, bool &isOwner)
Look up or construct field.
Definition: basicThermo.C:126
Foam::basicThermo::TypeName
TypeName("basicThermo")
Runtime type information.
autoPtr.H
Foam::basicThermo::incompressible
virtual bool incompressible() const =0
Return true if the equation of state is incompressible.