basicThermo.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
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 Class
25  Foam::basicThermo
26 
27 Description
28  Abstract base-class for fluid and solid thermodynamic properties
29 
30 SourceFiles
31  basicThermo.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef basicThermo_H
36 #define basicThermo_H
37 
38 #include "volFields.H"
39 #include "typeInfo.H"
40 #include "IOdictionary.H"
41 #include "autoPtr.H"
42 #include "wordIOList.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class basicThermo Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class basicThermo
54 :
55  public IOdictionary
56 {
57 
58 protected:
59 
60  // Protected data
61 
62  //- Phase-name
63  const word& phaseName_;
64 
65 
66  // Fields
67 
68  //- Temperature [K]
70 
71  //- Laminar thermal diffusivity [kg/m/s]
73 
74 
75  //- Should the dpdt term be included in the enthalpy equation
76  Switch dpdt_;
77 
78 
79  // Protected Member Functions
80 
81  //- Construct as copy (not implemented)
82  basicThermo(const basicThermo&);
83 
85  (
86  const fvMesh& mesh,
87  const char* name
88  ) const;
89 
90  //- Return the enthalpy/internal energy field boundary types
91  // by interrogating the temperature field boundary types
93 
94  //- Return the enthalpy/internal energy field boundary base types
95  // by interrogating the temperature field boundary types
97 
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("basicThermo");
103 
104 
105  //- Declare run-time constructor selection table
107  (
108  autoPtr,
109  basicThermo,
110  fvMesh,
111  (const fvMesh& mesh, const word& phaseName),
112  (mesh, phaseName)
113  );
114 
115 
116  // Constructors
117 
118  //- Construct from mesh and phase name
120  (
121  const fvMesh&,
122  const word& phaseName
123  );
124 
125  //- Construct from mesh, dictionary and phase name
127  (
128  const fvMesh&,
129  const dictionary&,
130  const word& phaseName
131  );
132 
133 
134  // Selectors
135 
136  //- Generic lookup for thermodynamics package thermoTypeName
137  template<class Thermo, class Table>
138  static typename Table::iterator lookupThermo
139  (
140  const dictionary& thermoTypeDict,
141  Table* tablePtr,
142  const int nCmpt,
143  const char* cmptNames[],
144  const word& thermoTypeName
145  );
146 
147  //- Generic lookup for each of the related thermodynamics packages
148  template<class Thermo, class Table>
149  static typename Table::iterator lookupThermo
150  (
151  const dictionary& thermoDict,
152  Table* tablePtr
153  );
154 
155  //- Generic New for each of the related thermodynamics packages
156  template<class Thermo>
157  static autoPtr<Thermo> New
158  (
159  const fvMesh&,
160  const word& phaseName=word::null
161  );
162 
163  //- Generic New for each of the related thermodynamics packages
164  template<class Thermo>
165  static autoPtr<Thermo> New
166  (
167  const fvMesh&,
168  const dictionary&,
169  const word& phaseName=word::null
170  );
171 
172  //- Specialisation of the Generic New for basicThermo
174  (
175  const fvMesh&,
176  const word& phaseName=word::null
177  );
178 
179 
180  //- Destructor
181  virtual ~basicThermo();
182 
183 
184  // Member Functions
186  static const word dictName;
187 
189  (
190  const word& name,
191  const word& phaseName
192  )
193  {
194  return IOobject::groupName(name, phaseName);
195  }
197  word phasePropertyName(const word& name) const
198  {
199  return basicThermo::phasePropertyName(name, phaseName_);
200  }
201 
202  static const basicThermo& lookupThermo(const fvPatchScalarField& pf);
203 
204  //- Check that the thermodynamics package is consistent
205  // with energy forms supported by the application
206  void validate
207  (
208  const string& app,
209  const word&
210  ) const;
211 
212  //- Check that the thermodynamics package is consistent
213  // with energy forms supported by the application
214  void validate
215  (
216  const string& app,
217  const word&,
218  const word&
219  ) const;
220 
221  //- Check that the thermodynamics package is consistent
222  // with energy forms supported by the application
223  void validate
224  (
225  const string& app,
226  const word&,
227  const word&,
228  const word&
229  ) const;
230 
231  //- Check that the thermodynamics package is consistent
232  // with energy forms supported by the application
233  void validate
234  (
235  const string& app,
236  const word&,
237  const word&,
238  const word&,
239  const word&
240  ) const;
241 
242  //- Split name of thermo package into a list of the components names
244  (
245  const word& thermoName,
246  const int nCmpt
247  );
248 
249  //- Update properties
250  virtual void correct() = 0;
251 
252  //- Return the name of the thermo physics
253  virtual word thermoName() const = 0;
254 
255  //- Return true if the equation of state is incompressible
256  // i.e. rho != f(p)
257  virtual bool incompressible() const = 0;
258 
259  //- Return true if the equation of state is isochoric
260  // i.e. rho = const
261  virtual bool isochoric() const = 0;
262 
263  //- Should the dpdt term be included in the enthalpy equation
264  Switch dpdt() const
265  {
266  return dpdt_;
267  }
268 
269 
270  // Access to thermodynamic state variables
271 
272  //- Density [kg/m^3]
273  virtual tmp<volScalarField> rho() const = 0;
274 
275  //- Density for patch [kg/m^3]
276  virtual tmp<scalarField> rho(const label patchi) const = 0;
277 
278  //- Enthalpy/Internal energy [J/kg]
279  // Non-const access allowed for transport equations
280  virtual volScalarField& he() = 0;
281 
282  //- Enthalpy/Internal energy [J/kg]
283  virtual const volScalarField& he() const = 0;
284 
285  //- Enthalpy/Internal energy
286  // for given pressure and temperature [J/kg]
287  virtual tmp<volScalarField> he
288  (
289  const volScalarField& p,
290  const volScalarField& T
291  ) const = 0;
292 
293  //- Enthalpy/Internal energy for cell-set [J/kg]
294  virtual tmp<scalarField> he
295  (
296  const scalarField& T,
297  const labelList& cells
298  ) const = 0;
299 
300  //- Enthalpy/Internal energy for patch [J/kg]
301  virtual tmp<scalarField> he
302  (
303  const scalarField& T,
304  const label patchi
305  ) const = 0;
306 
307  //- Sensible enthalpy [J/kg]
308  virtual tmp<volScalarField> hs() const = 0;
309 
310  //- Sensible enthalpy
311  // for given pressure and temperature [J/kg]
312  virtual tmp<volScalarField> hs
313  (
314  const volScalarField& p,
315  const volScalarField& T
316  ) const = 0;
317 
318  //- Sensible enthalpy for cell-set [J/kg]
319  virtual tmp<scalarField> hs
320  (
321  const scalarField& T,
322  const labelList& cells
323  ) const = 0;
324 
325  //- Sensible enthalpy for patch [J/kg]
326  virtual tmp<scalarField> hs
327  (
328  const scalarField& T,
329  const label patchi
330  ) const = 0;
331 
332  //- Absolute enthalpy [J/kg]
333  virtual tmp<volScalarField> ha() const = 0;
334 
335  //- Absolute enthalpy
336  // for given pressure and temperature [J/kg]
337  virtual tmp<volScalarField> ha
338  (
339  const volScalarField& p,
340  const volScalarField& T
341  ) const = 0;
342 
343  //- Absolute enthalpy for cell-set [J/kg]
344  virtual tmp<scalarField> ha
345  (
346  const scalarField& T,
347  const labelList& cells
348  ) const = 0;
349 
350  //- Absolute enthalpy for patch [J/kg]
351  virtual tmp<scalarField> ha
352  (
353  const scalarField& T,
354  const label patchi
355  ) const = 0;
356 
357  //- Enthalpy of formation [J/kg]
358  virtual tmp<volScalarField> hc() const = 0;
359 
360  //- Temperature from enthalpy/internal energy for cell-set
361  virtual tmp<scalarField> THE
362  (
363  const scalarField& h,
364  const scalarField& T0, // starting temperature
365  const labelList& cells
366  ) const = 0;
367 
368  //- Temperature from enthalpy/internal energy for patch
369  virtual tmp<scalarField> THE
370  (
371  const scalarField& h,
372  const scalarField& T0, // starting temperature
373  const label patchi
374  ) const = 0;
375 
376 
377  // Fields derived from thermodynamic state variables
378 
379  //- Temperature [K]
380  virtual const volScalarField& T() const;
381 
382  //- Temperature [K]
383  // Non-const access allowed for transport equations
384  virtual volScalarField& T();
385 
386  //- Heat capacity at constant pressure [J/kg/K]
387  virtual tmp<volScalarField> Cp() const = 0;
388 
389  //- Heat capacity at constant pressure for patch [J/kg/K]
390  virtual tmp<scalarField> Cp
391  (
392  const scalarField& T,
393  const label patchi
394  ) const = 0;
395 
396  //- Heat capacity at constant volume [J/kg/K]
397  virtual tmp<volScalarField> Cv() const = 0;
398 
399  //- Heat capacity at constant volume for patch [J/kg/K]
400  virtual tmp<scalarField> Cv
401  (
402  const scalarField& T,
403  const label patchi
404  ) const = 0;
405 
406  //- Heat capacity at constant pressure/volume [J/kg/K]
407  virtual tmp<volScalarField> Cpv() const = 0;
408 
409  //- Heat capacity at constant pressure/volume for patch [J/kg/K]
410  virtual tmp<scalarField> Cpv
411  (
412  const scalarField& T,
413  const label patchi
414  ) const = 0;
415 
416  //- Heat capacity ratio []
417  virtual tmp<volScalarField> CpByCpv() const = 0;
418 
419  //- Heat capacity ratio for patch []
420  virtual tmp<scalarField> CpByCpv
421  (
422  const scalarField& T,
423  const label patchi
424  ) const = 0;
425 
426 
427  // Access to transport state variables
428 
429  //- Thermal diffusivity for enthalpy of mixture [kg/m/s]
430  virtual const volScalarField& alpha() const;
431 
432  //- Thermal diffusivity for enthalpy of mixture for patch [kg/m/s]
433  virtual const scalarField& alpha
434  (
435  const label patchi
436  ) const;
437 
438 
439  // Fields derived from transport state variables
440 
441  //- Thermal diffusivity for temperature of mixture [W/m/K]
442  virtual tmp<volScalarField> kappa() const = 0;
443 
444  //- Thermal diffusivity for temperature of mixture
445  // for patch [W/m/K]
446  virtual tmp<scalarField> kappa
447  (
448  const label patchi
449  ) const = 0;
450 
451  //- Thermal diffusivity for energy of mixture [kg/m/s]
452  virtual tmp<volScalarField> alphahe() const = 0;
453 
454  //- Thermal diffusivity for energy of mixture for patch [kg/m/s]
455  virtual tmp<scalarField> alphahe(const label patchi) const = 0;
456 
457 
458  //- Read thermophysical properties dictionary
459  virtual bool read();
460 };
461 
462 
463 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
464 
465 } // End namespace Foam
466 
467 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
468 
469 #ifdef NoRepository
470  #include "basicThermoTemplates.C"
471 #endif
472 
473 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
474 
475 #endif
476 
477 // ************************************************************************* //
virtual ~basicThermo()
Destructor.
Definition: basicThermo.C:284
TypeName("basicThermo")
Runtime type information.
Switch dpdt() const
Should the dpdt term be included in the enthalpy equation.
Definition: basicThermo.H:263
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual tmp< volScalarField > kappa() const =0
Thermal diffusivity for temperature of mixture [W/m/K].
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:52
static word phasePropertyName(const word &name, const word &phaseName)
Definition: basicThermo.H:188
virtual tmp< volScalarField > rho() const =0
Density [kg/m^3].
Switch dpdt_
Should the dpdt term be included in the enthalpy equation.
Definition: basicThermo.H:75
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual tmp< volScalarField > Cv() const =0
Heat capacity at constant volume [J/kg/K].
virtual word thermoName() const =0
Return the name of the thermo physics.
virtual tmp< volScalarField > alphahe() const =0
Thermal diffusivity for energy of mixture [kg/m/s].
volScalarField T_
Temperature [K].
Definition: basicThermo.H:68
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
virtual const volScalarField & alpha() const
Thermal diffusivity for enthalpy of mixture [kg/m/s].
Definition: basicThermo.C:494
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual const volScalarField & T() const
Temperature [K].
Definition: basicThermo.C:482
static autoPtr< Thermo > New(const fvMesh &, const word &phaseName=word::null)
Generic New for each of the related thermodynamics packages.
virtual tmp< volScalarField > Cpv() const =0
Heat capacity at constant pressure/volume [J/kg/K].
declareRunTimeSelectionTable(autoPtr, basicThermo, fvMesh,(const fvMesh &mesh, const word &phaseName),(mesh, phaseName))
Declare run-time constructor selection table.
virtual volScalarField & he()=0
Enthalpy/Internal energy [J/kg].
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:123
const word & phaseName_
Phase-name.
Definition: basicThermo.H:62
dynamicFvMesh & mesh
wordList heBoundaryBaseTypes()
Return the enthalpy/internal energy field boundary base types.
Definition: basicThermo.C:52
const cellShapeList & cells
static wordList splitThermoName(const word &thermoName, const int nCmpt)
Split name of thermo package into a list of the components names.
Definition: basicThermo.C:421
A class for handling words, derived from string.
Definition: word.H:59
static word groupName(Name name, const word &group)
wordList heBoundaryTypes()
Return the enthalpy/internal energy field boundary types.
Definition: basicThermo.C:84
static const word null
An empty word.
Definition: word.H:77
virtual tmp< volScalarField > hc() const =0
Enthalpy of formation [J/kg].
const word & name() const
Name function is needed to disambiguate those inherited.
volScalarField & lookupOrConstruct(const fvMesh &mesh, const char *name) const
Definition: basicThermo.C:137
static Table::iterator lookupThermo(const dictionary &thermoTypeDict, Table *tablePtr, const int nCmpt, const char *cmptNames[], const word &thermoTypeName)
Generic lookup for thermodynamics package thermoTypeName.
virtual tmp< volScalarField > Cp() const =0
Heat capacity at constant pressure [J/kg/K].
volScalarField alpha_
Laminar thermal diffusivity [kg/m/s].
Definition: basicThermo.H:71
label patchi
basicThermo(const basicThermo &)
Construct as copy (not implemented)
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual bool read()
Read thermophysical properties dictionary.
Definition: basicThermo.C:506
const dimensionedScalar & h
Planck constant.
virtual tmp< volScalarField > hs() const =0
Sensible enthalpy [J/kg].
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
virtual bool isochoric() const =0
Return true if the equation of state is isochoric.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void correct()=0
Update properties.
virtual tmp< scalarField > THE(const scalarField &h, const scalarField &T0, const labelList &cells) const =0
Temperature from enthalpy/internal energy for cell-set.
void validate(const string &app, const word &) const
Check that the thermodynamics package is consistent.
Definition: basicThermo.C:327
virtual tmp< volScalarField > ha() const =0
Absolute enthalpy [J/kg].
virtual bool incompressible() const =0
Return true if the equation of state is incompressible.
virtual tmp< volScalarField > CpByCpv() const =0
Heat capacity ratio [].
Namespace for OpenFOAM.
scalar T0
Definition: createFields.H:22