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-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::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  // Private Data
69 
70  //- Components names/order
71  static const wordList componentHeader4;
72 
73  //- Components names/order
74  static const wordList componentHeader7;
75 
76 
77  // Private Member Functions
78 
79  //- Construct name of thermo package from dictionary components
80  static word makeThermoName
81  (
82  const dictionary& dict,
83  const wordList*& cmptHeaderPtr
84  );
85 
86  //- Look up field from registry or construct and store
87  static volScalarField& lookupOrConstruct
88  (
89  const fvMesh& mesh,
90  const word& fieldName,
91  bool& isOwner
92  );
93 
94  //- Generic lookup for thermodynamics package thermoTypeName
95  // \return constructor pointer, or FatalError
96  template<class Thermo, class ThermoConstructTable>
97  static typename ThermoConstructTable::mapped_type
98  getThermoOrDie
99  (
100  const dictionary& thermoTypeDict,
101  ThermoConstructTable& thermoTable,
102  const word& thermoTypeName,
103  const wordList& cmptNames
104  );
105 
106  //- Generic lookup for each of the related thermodynamics packages
107  // \return constructor pointer, or FatalError
108  template<class Thermo, class ThermoConstructTable>
109  static typename ThermoConstructTable::mapped_type
110  getThermoOrDie
111  (
112  const dictionary& thermoDict,
113  ThermoConstructTable& thermoTable
114  );
115 
116 
117 protected:
118 
119  // Protected Data
120 
121  //- Phase-name
122  const word& phaseName_;
123 
124  //- Pressure created and stored by this instance
125  bool pOwner_;
126 
127  //- Temperature created and stored by this instance
128  bool TOwner_;
129 
130  //- Include dpdt term in the enthalpy equation?
131  bool dpdt_;
132 
133 
134  // Fields
135 
136  //- Pressure [Pa]
138 
139  //- Temperature [K]
141 
142  //- Laminar thermal diffusivity [kg/m/s]
144 
145 
146  // Protected Member Functions
147 
148  //- Return the enthalpy/internal energy field boundary types
149  //- by interrogating the temperature field boundary types
151 
152  //- Return the enthalpy/internal energy field boundary base types
153  //- by interrogating the temperature field boundary types
155 
156  //- No copy construct
157  basicThermo(const basicThermo&) = delete;
158 
159 
160 public:
161 
162  //- Runtime type information
163  TypeName("basicThermo");
164 
165 
166  //- Declare run-time constructor selection table
168  (
169  autoPtr,
170  basicThermo,
171  fvMesh,
172  (const fvMesh& mesh, const word& phaseName),
173  (mesh, phaseName)
174  );
175 
176 
177  //- Declare run-time constructor selection table for dictionary based
179  (
180  autoPtr,
181  basicThermo,
182  fvMeshDictPhase,
183  (const fvMesh& mesh, const word& phaseName, const word& dictName),
184  (mesh, phaseName, dictName)
185  );
186 
187 
188  // Constructors
189 
190  //- Construct from mesh and phase name
192  (
193  const fvMesh&,
194  const word& phaseName
195  );
196 
197  //- Construct from mesh, dictionary and phase name
199  (
200  const fvMesh&,
201  const dictionary&,
202  const word& phaseName
203  );
204 
205  //- Construct from mesh, phase name and explicit naming of the
206  //- dictionary (so it can be shared amongst phases).
208  (
209  const fvMesh&,
210  const word& phaseName,
211  const word& dictionaryName
212  );
213 
214 
215  // Selectors
216 
217  //- Generic New for each of the related thermodynamics packages
218  template<class Thermo>
219  static autoPtr<Thermo> New
220  (
221  const fvMesh&,
222  const word& phaseName=word::null
223  );
224 
225  //- Generic New for each of the related thermodynamics packages
226  template<class Thermo>
227  static autoPtr<Thermo> New
228  (
229  const fvMesh&,
230  const dictionary&,
231  const word& phaseName=word::null
232  );
233 
234  //- Generic New for each of the related thermodynamics packages
235  template<class Thermo>
236  static autoPtr<Thermo> New
237  (
238  const fvMesh&,
239  const word& phaseName,
240  const word& dictName
241  );
242 
243  //- Specialisation of the Generic New for basicThermo
245  (
246  const fvMesh&,
247  const word& phaseName=word::null
248  );
249 
250 
251  //- Destructor
252  virtual ~basicThermo();
253 
254 
255  // Member Functions
256 
257  static const word dictName;
258 
260  (
261  const word& name,
262  const word& phaseName
263  )
264  {
265  return IOobject::groupName(name, phaseName);
266  }
267 
268  word phasePropertyName(const word& name) const
269  {
271  }
272 
273  static const basicThermo& lookupThermo(const fvPatchScalarField& pf);
274 
275  //- Print (filtered) table of thermo names, splits on \c " ,<>"
276  static Ostream& printThermoNames
277  (
278  Ostream& os,
279  const wordList& cmptNames,
280  const wordList& thermoNames
281  );
282 
283  //- Check that the thermodynamics package is consistent
284  // with energy forms supported by the application
285  void validate
286  (
287  const string& app,
288  const word&
289  ) const;
290 
291  //- Check that the thermodynamics package is consistent
292  // with energy forms supported by the application
293  void validate
294  (
295  const string& app,
296  const word&,
297  const word&
298  ) const;
299 
300  //- Check that the thermodynamics package is consistent
301  // with energy forms supported by the application
302  void validate
303  (
304  const string& app,
305  const word&,
306  const word&,
307  const word&
308  ) const;
309 
310  //- Check that the thermodynamics package is consistent
311  // with energy forms supported by the application
312  void validate
313  (
314  const string& app,
315  const word&,
316  const word&,
317  const word&,
318  const word&
319  ) const;
320 
321  //- Split thermo package name into a list of components names
322  // Splits on \c " ,<>"
323  // \return empty list if the split name does not have the
324  // expected number of components (non-zero).
326  (
327  const std::string& thermoName,
328  const int nExpectedCmpts
329  );
330 
331  //- Update properties
332  virtual void correct() = 0;
333 
334  //- Return the name of the thermo physics
335  virtual word thermoName() const = 0;
336 
337  //- Return true if the equation of state is incompressible
338  // i.e. rho != f(p)
339  virtual bool incompressible() const = 0;
340 
341  //- Return true if the equation of state is isochoric
342  // i.e. rho = const
343  virtual bool isochoric() const = 0;
344 
345  //- True if dpdt term should be included in enthalpy equation
346  bool dpdt() const noexcept
347  {
348  return dpdt_;
349  }
350 
351  //- True if T should be updated
352  bool updateT() const noexcept
353  {
354  return TOwner_;
355  }
356 
357 
358  // Access to thermodynamic state variables
359 
360  //- Pressure [Pa]
361  // Non-const access allowed for transport equations
362  virtual volScalarField& p();
363 
364  //- Pressure [Pa]
365  virtual const volScalarField& p() const;
366 
367  //- Density [kg/m^3]
368  virtual tmp<volScalarField> rho() const = 0;
369 
370  //- Density for patch [kg/m^3]
371  virtual tmp<scalarField> rho(const label patchi) const = 0;
372 
373  //- Enthalpy/Internal energy [J/kg]
374  // Non-const access allowed for transport equations
375  virtual volScalarField& he() = 0;
376 
377  //- Enthalpy/Internal energy [J/kg]
378  virtual const volScalarField& he() const = 0;
379 
380  //- Enthalpy/Internal energy
381  // for given pressure and temperature [J/kg]
382  virtual tmp<volScalarField> he
383  (
384  const volScalarField& p,
385  const volScalarField& T
386  ) const = 0;
387 
388  //- Enthalpy/Internal energy for cell-set [J/kg]
389  virtual tmp<scalarField> he
390  (
391  const scalarField& p,
392  const scalarField& T,
393  const labelList& cells
394  ) const = 0;
395 
396  //- Enthalpy/Internal energy for patch [J/kg]
397  virtual tmp<scalarField> he
398  (
399  const scalarField& p,
400  const scalarField& T,
401  const label patchi
402  ) const = 0;
403 
404  //- Chemical enthalpy [J/kg]
405  virtual tmp<volScalarField> hc() const = 0;
406 
407  //- Temperature from enthalpy/internal energy for cell-set
408  virtual tmp<scalarField> THE
409  (
410  const scalarField& h,
411  const scalarField& p,
412  const scalarField& T0, // starting temperature
413  const labelList& cells
414  ) const = 0;
415 
416  //- Temperature from enthalpy/internal energy for patch
417  virtual tmp<scalarField> THE
418  (
419  const scalarField& h,
420  const scalarField& p,
421  const scalarField& T0, // starting temperature
422  const label patchi
423  ) const = 0;
424 
425 
426  // Fields derived from thermodynamic state variables
427 
428  //- Temperature [K]
429  virtual const volScalarField& T() const;
430 
431  //- Temperature [K]
432  // Non-const access allowed for transport equations
433  virtual volScalarField& T();
434 
435  //- Heat capacity at constant pressure [J/kg/K]
436  virtual tmp<volScalarField> Cp() const = 0;
437 
438  //- Heat capacity at constant pressure for patch [J/kg/K]
439  virtual tmp<scalarField> Cp
440  (
441  const scalarField& p,
442  const scalarField& T,
443  const label patchi
444  ) const = 0;
445 
446  //- Heat capacity using pressure and temperature [J/kg/K]
447  virtual tmp<scalarField> Cp
448  (
449  const scalarField& p,
450  const scalarField& T,
451  const labelList& cells
452  ) const = 0;
453 
454  //- Heat capacity at constant volume [J/kg/K]
455  virtual tmp<volScalarField> Cv() const = 0;
456 
457  //- Heat capacity at constant volume for patch [J/kg/K]
458  virtual tmp<scalarField> Cv
459  (
460  const scalarField& p,
461  const scalarField& T,
462  const label patchi
463  ) const = 0;
464 
465  //- Density from pressure and temperature from EoS
466  virtual tmp<scalarField> rhoEoS
467  (
468  const scalarField& p,
469  const scalarField& T,
470  const labelList& cells
471  ) const = 0;
472 
473  //- Gamma = Cp/Cv []
474  virtual tmp<volScalarField> gamma() const = 0;
475 
476  //- Gamma = Cp/Cv for patch []
477  virtual tmp<scalarField> gamma
478  (
479  const scalarField& p,
480  const scalarField& T,
481  const label patchi
482  ) const = 0;
483 
484  //- Heat capacity at constant pressure/volume [J/kg/K]
485  virtual tmp<volScalarField> Cpv() const = 0;
486 
487  //- Heat capacity at constant pressure/volume for patch [J/kg/K]
488  virtual tmp<scalarField> Cpv
489  (
490  const scalarField& p,
491  const scalarField& T,
492  const label patchi
493  ) const = 0;
494 
495  //- Heat capacity ratio []
496  virtual tmp<volScalarField> CpByCpv() const = 0;
497 
498  //- Heat capacity ratio for patch []
499  virtual tmp<scalarField> CpByCpv
500  (
501  const scalarField& p,
502  const scalarField& T,
503  const label patchi
504  ) const = 0;
505 
506  //- Molecular weight [kg/kmol]
507  virtual tmp<volScalarField> W() const = 0;
508 
509 
510  // Access to transport state variables
511 
512  //- Thermal diffusivity for enthalpy of mixture [kg/m/s]
513  virtual const volScalarField& alpha() const;
514 
515  //- Thermal diffusivity for enthalpy of mixture for patch [kg/m/s]
516  virtual const scalarField& alpha
517  (
518  const label patchi
519  ) const;
520 
521 
522  // Fields derived from transport state variables
523 
524  //- Thermal diffusivity for temperature of mixture [J/m/s/K]
525  virtual tmp<volScalarField> kappa() const = 0;
526 
527  //- Thermal diffusivity for temperature
528  // of mixture for patch [J/m/s/K]
529  virtual tmp<scalarField> kappa
530  (
531  const label patchi
532  ) const = 0;
533 
534  //- Thermal diffusivity for energy of mixture [kg/m/s]
535  virtual tmp<volScalarField> alphahe() const = 0;
536 
537  //- Thermal diffusivity for energy of mixture for patch [kg/m/s]
538  virtual tmp<scalarField> alphahe(const label patchi) const = 0;
539 
540  //- Effective thermal diffusivity for temperature
541  // of mixture [J/m/s/K]
543  (
544  const volScalarField&
545  ) const = 0;
546 
547  //- Effective thermal diffusivity for temperature
548  // of mixture for patch [J/m/s/K]
549  virtual tmp<scalarField> kappaEff
550  (
551  const scalarField& alphat,
552  const label patchi
553  ) const = 0;
554 
555  //- Effective thermal diffusivity of mixture [kg/m/s]
557  (
558  const volScalarField& alphat
559  ) const = 0;
560 
561  //- Effective thermal diffusivity of mixture for patch [kg/m/s]
562  virtual tmp<scalarField> alphaEff
563  (
564  const scalarField& alphat,
565  const label patchi
566  ) const = 0;
567 
568 
569  //- Read thermophysical properties dictionary
570  virtual bool read();
571 };
572 
573 
574 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
575 
576 } // End namespace Foam
577 
578 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
579 
580 #ifdef NoRepository
581  #include "basicThermoTemplates.C"
582 #endif
583 
584 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
585 
586 #endif
587 
588 // ************************************************************************* //
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()
Definition: basicThermo.C:198
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::basicThermo::W
virtual tmp< volScalarField > W() const =0
Molecular weight [kg/kmol].
basicThermoTemplates.C
Foam::basicThermo::~basicThermo
virtual ~basicThermo()
Destructor.
Definition: basicThermo.C:437
typeInfo.H
Foam::basicThermo::p
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:602
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:256
Foam::basicThermo::read
virtual bool read()
Read thermophysical properties dictionary.
Definition: basicThermo.C:638
Foam::basicThermo::phasePropertyName
word phasePropertyName(const word &name) const
Definition: basicThermo.H:267
Foam::basicThermo::alpha_
volScalarField alpha_
Laminar thermal diffusivity [kg/m/s].
Definition: basicThermo.H:142
Foam::basicThermo::dpdt
bool dpdt() const noexcept
True if dpdt term should be included in enthalpy equation.
Definition: basicThermo.H:345
Foam::basicThermo::TOwner_
bool TOwner_
Temperature created and stored by this instance.
Definition: basicThermo.H:127
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:85
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::lookupThermo
static const basicThermo & lookupThermo(const fvPatchScalarField &pf)
Definition: basicThermo.C:446
Foam::basicThermo::hc
virtual tmp< volScalarField > hc() const =0
Chemical enthalpy [J/kg].
Foam::basicThermo::dpdt_
bool dpdt_
Include dpdt term in the enthalpy equation?
Definition: basicThermo.H:130
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()
Definition: basicThermo.C:164
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:259
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::printThermoNames
static Ostream & printThermoNames(Ostream &os, const wordList &cmptNames, const wordList &thermoNames)
Print (filtered) table of thermo names, splits on " ,<>".
Definition: basicThermo.C:75
Foam::basicThermo::pOwner_
bool pOwner_
Pressure created and stored by this instance.
Definition: basicThermo.H:124
Foam::basicThermo::kappa
virtual tmp< volScalarField > kappa() const =0
Thermal diffusivity for temperature of mixture [J/m/s/K].
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::basicThermo::New
static autoPtr< Thermo > New(const fvMesh &, const word &phaseName=word::null)
Generic New for each of the related thermodynamics packages.
os
OBJstream os(runTime.globalPath()/outputName)
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:85
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:478
Foam::basicThermo::T_
volScalarField & T_
Temperature [K].
Definition: basicThermo.H:139
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:626
thermoDict
const dictionary & thermoDict
Definition: EEqn.H:16
Foam::basicThermo::p_
volScalarField & p_
Pressure [Pa].
Definition: basicThermo.H:136
Foam::basicThermo::T
virtual const volScalarField & T() const
Temperature [K].
Definition: basicThermo.C:614
Foam::List< word >
Foam::basicThermo::Cpv
virtual tmp< volScalarField > Cpv() const =0
Heat capacity at constant pressure/volume [J/kg/K].
Foam::word::null
static const word null
An empty word.
Definition: word.H:80
Foam::basicThermo::updateT
bool updateT() const noexcept
True if T should be updated.
Definition: basicThermo.H:351
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::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::basicThermo::phaseName_
const word & phaseName_
Phase-name.
Definition: basicThermo.H:121
Foam::basicThermo::Cv
virtual tmp< volScalarField > Cv() const =0
Heat capacity at constant volume [J/kg/K].
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::basicThermo::he
virtual volScalarField & he()=0
Enthalpy/Internal energy [J/kg].
T0
scalar T0
Definition: createFields.H:22
Foam::basicThermo::splitThermoName
static wordList splitThermoName(const std::string &thermoName, const int nExpectedCmpts)
Split thermo package name into a list of components names.
Definition: basicThermo.C:572
Foam::basicThermo::rhoEoS
virtual tmp< scalarField > rhoEoS(const scalarField &p, const scalarField &T, const labelList &cells) const =0
Density from pressure and temperature from EoS.
Foam::basicThermo::basicThermo
basicThermo(const basicThermo &)=delete
No copy construct.
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.
Foam::dictionary::dictName
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionaryI.H:60