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-2018 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  //- Pressure [Pa]
70 
71  //- Temperature [K]
73 
74  //- Laminar thermal diffusuvity [kg/m/s]
76 
77  //- Should the dpdt term be included in the enthalpy equation
78  Switch dpdt_;
79 
80 
81  // Protected Member Functions
82 
83  //- Construct as copy (not implemented)
84  basicThermo(const basicThermo&);
85 
87  (
88  const fvMesh& mesh,
89  const char* name
90  ) const;
91 
92  //- Return the enthalpy/internal energy field boundary types
93  // by interrogating the temperature field boundary types
95 
96  //- Return the enthalpy/internal energy field boundary base types
97  // by interrogating the temperature field boundary types
99 
100 
101 public:
102 
103  //- Runtime type information
104  TypeName("basicThermo");
105 
106 
107  //- Declare run-time constructor selection table
109  (
110  autoPtr,
111  basicThermo,
112  fvMesh,
113  (const fvMesh& mesh, const word& phaseName),
114  (mesh, phaseName)
115  );
116 
117 
118  // Constructors
119 
120  //- Construct from mesh and phase name
122  (
123  const fvMesh&,
124  const word& phaseName
125  );
126 
127  //- Construct from mesh, dictionary and phase name
129  (
130  const fvMesh&,
131  const dictionary&,
132  const word& phaseName
133  );
134 
135 
136  // Selectors
137 
138  //- Generic lookup for thermodynamics package thermoTypeName
139  template<class Thermo, class Table>
140  static typename Table::iterator lookupThermo
141  (
142  const dictionary& thermoTypeDict,
143  Table* tablePtr,
144  const int nCmpt,
145  const char* cmptNames[],
146  const word& thermoTypeName
147  );
148 
149  //- Generic lookup for each of the related thermodynamics packages
150  template<class Thermo, class Table>
151  static typename Table::iterator lookupThermo
152  (
153  const dictionary& thermoDict,
154  Table* tablePtr
155  );
156 
157  //- Generic New for each of the related thermodynamics packages
158  template<class Thermo>
159  static autoPtr<Thermo> New
160  (
161  const fvMesh&,
162  const word& phaseName=word::null
163  );
164 
165  //- Generic New for each of the related thermodynamics packages
166  template<class Thermo>
167  static autoPtr<Thermo> New
168  (
169  const fvMesh&,
170  const dictionary&,
171  const word& phaseName=word::null
172  );
173 
174  //- Specialisation of the Generic New for basicThermo
176  (
177  const fvMesh&,
178  const word& phaseName=word::null
179  );
180 
181 
182  //- Destructor
183  virtual ~basicThermo();
184 
185 
186  // Member functions
188  static const word dictName;
189 
191  (
192  const word& name,
193  const word& phaseName
194  )
195  {
196  return IOobject::groupName(name, phaseName);
197  }
199  word phasePropertyName(const word& name) const
200  {
201  return basicThermo::phasePropertyName(name, phaseName_);
202  }
203 
204  static const basicThermo& lookupThermo(const fvPatchScalarField& pf);
205 
206  //- Check that the thermodynamics package is consistent
207  // with energy forms supported by the application
208  void validate
209  (
210  const string& app,
211  const word&
212  ) const;
213 
214  //- Check that the thermodynamics package is consistent
215  // with energy forms supported by the application
216  void validate
217  (
218  const string& app,
219  const word&,
220  const word&
221  ) const;
222 
223  //- Check that the thermodynamics package is consistent
224  // with energy forms supported by the application
225  void validate
226  (
227  const string& app,
228  const word&,
229  const word&,
230  const word&
231  ) const;
232 
233  //- Check that the thermodynamics package is consistent
234  // with energy forms supported by the application
235  void validate
236  (
237  const string& app,
238  const word&,
239  const word&,
240  const word&,
241  const word&
242  ) const;
243 
244  //- Split name of thermo package into a list of the components names
246  (
247  const word& thermoName,
248  const int nCmpt
249  );
250 
251  //- Update properties
252  virtual void correct() = 0;
253 
254  //- Return the name of the thermo physics
255  virtual word thermoName() const = 0;
256 
257  //- Return true if the equation of state is incompressible
258  // i.e. rho != f(p)
259  virtual bool incompressible() const = 0;
260 
261  //- Return true if the equation of state is isochoric
262  // i.e. rho = const
263  virtual bool isochoric() const = 0;
264 
265  //- Should the dpdt term be included in the enthalpy equation
266  Switch dpdt() const
267  {
268  return dpdt_;
269  }
270 
271 
272  // Access to thermodynamic state variables
273 
274  //- Pressure [Pa]
275  // Non-const access allowed for transport equations
276  virtual volScalarField& p();
277 
278  //- Pressure [Pa]
279  virtual const volScalarField& p() const;
280 
281  //- Density [kg/m^3]
282  virtual tmp<volScalarField> rho() const = 0;
283 
284  //- Density for patch [kg/m^3]
285  virtual tmp<scalarField> rho(const label patchi) const = 0;
286 
287  //- Enthalpy/Internal energy [J/kg]
288  // Non-const access allowed for transport equations
289  virtual volScalarField& he() = 0;
290 
291  //- Enthalpy/Internal energy [J/kg]
292  virtual const volScalarField& he() const = 0;
293 
294  //- Enthalpy/Internal energy
295  // for given pressure and temperature [J/kg]
296  virtual tmp<volScalarField> he
297  (
298  const volScalarField& p,
299  const volScalarField& T
300  ) const = 0;
301 
302  //- Enthalpy/Internal energy for cell-set [J/kg]
303  virtual tmp<scalarField> he
304  (
305  const scalarField& p,
306  const scalarField& T,
307  const labelList& cells
308  ) const = 0;
309 
310  //- Enthalpy/Internal energy for patch [J/kg]
311  virtual tmp<scalarField> he
312  (
313  const scalarField& p,
314  const scalarField& T,
315  const label patchi
316  ) const = 0;
317 
318  //- Chemical enthalpy [J/kg]
319  virtual tmp<volScalarField> hc() const = 0;
320 
321  //- Temperature from enthalpy/internal energy for cell-set
322  virtual tmp<scalarField> THE
323  (
324  const scalarField& h,
325  const scalarField& p,
326  const scalarField& T0, // starting temperature
327  const labelList& cells
328  ) const = 0;
329 
330  //- Temperature from enthalpy/internal energy for patch
331  virtual tmp<scalarField> THE
332  (
333  const scalarField& h,
334  const scalarField& p,
335  const scalarField& T0, // starting temperature
336  const label patchi
337  ) const = 0;
338 
339 
340  // Fields derived from thermodynamic state variables
341 
342  //- Temperature [K]
343  virtual const volScalarField& T() const;
344 
345  //- Temperature [K]
346  // Non-const access allowed for transport equations
347  virtual volScalarField& T();
348 
349  //- Heat capacity at constant pressure [J/kg/K]
350  virtual tmp<volScalarField> Cp() const = 0;
351 
352  //- Heat capacity at constant pressure for patch [J/kg/K]
353  virtual tmp<scalarField> Cp
354  (
355  const scalarField& p,
356  const scalarField& T,
357  const label patchi
358  ) const = 0;
359 
360  //- Heat capacity at constant volume [J/kg/K]
361  virtual tmp<volScalarField> Cv() const = 0;
362 
363  //- Heat capacity at constant volume for patch [J/kg/K]
364  virtual tmp<scalarField> Cv
365  (
366  const scalarField& p,
367  const scalarField& T,
368  const label patchi
369  ) const = 0;
370 
371  //- Gamma = Cp/Cv []
372  virtual tmp<volScalarField> gamma() const = 0;
373 
374  //- Gamma = Cp/Cv for patch []
375  virtual tmp<scalarField> gamma
376  (
377  const scalarField& p,
378  const scalarField& T,
379  const label patchi
380  ) const = 0;
381 
382  //- Heat capacity at constant pressure/volume [J/kg/K]
383  virtual tmp<volScalarField> Cpv() const = 0;
384 
385  //- Heat capacity at constant pressure/volume for patch [J/kg/K]
386  virtual tmp<scalarField> Cpv
387  (
388  const scalarField& p,
389  const scalarField& T,
390  const label patchi
391  ) const = 0;
392 
393  //- Heat capacity ratio []
394  virtual tmp<volScalarField> CpByCpv() const = 0;
395 
396  //- Heat capacity ratio for patch []
397  virtual tmp<scalarField> CpByCpv
398  (
399  const scalarField& p,
400  const scalarField& T,
401  const label patchi
402  ) const = 0;
403 
404  //- Molecular weight [kg/kmol]
405  virtual tmp<volScalarField> W() const = 0;
406 
407 
408  // Access to transport state variables
409 
410  //- Thermal diffusivity for enthalpy of mixture [kg/m/s]
411  virtual const volScalarField& alpha() const;
412 
413  //- Thermal diffusivity for enthalpy of mixture for patch [kg/m/s]
414  virtual const scalarField& alpha
415  (
416  const label patchi
417  ) const;
418 
419 
420  // Fields derived from transport state variables
421 
422  //- Thermal diffusivity for temperature of mixture [J/m/s/K]
423  virtual tmp<volScalarField> kappa() const = 0;
424 
425  //- Thermal diffusivity for temperature of mixture
426  // for patch [J/m/s/K]
427  virtual tmp<scalarField> kappa
428  (
429  const label patchi
430  ) const = 0;
431 
432  //- Thermal diffusivity for energy of mixture [kg/m/s]
433  virtual tmp<volScalarField> alphahe() const = 0;
434 
435  //- Thermal diffusivity for energy of mixture for patch [kg/m/s]
436  virtual tmp<scalarField> alphahe(const label patchi) const = 0;
437 
438  //- Effective thermal turbulent diffusivity for temperature
439  // of mixture [J/m/s/K]
441  (
442  const volScalarField&
443  ) const = 0;
444 
445  //- Effective thermal turbulent diffusivity for temperature
446  // of mixture for patch [J/m/s/K]
447  virtual tmp<scalarField> kappaEff
448  (
449  const scalarField& alphat,
450  const label patchi
451  ) const = 0;
452 
453  //- Effective thermal turbulent diffusivity of mixture [kg/m/s]
455  (
456  const volScalarField& alphat
457  ) const = 0;
458 
459  //- Effective thermal turbulent diffusivity of mixture
460  // for patch [kg/m/s]
461  virtual tmp<scalarField> alphaEff
462  (
463  const scalarField& alphat,
464  const label patchi
465  ) const = 0;
466 
467 
468  //- Read thermophysical properties dictionary
469  virtual bool read();
470 };
471 
472 
473 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
474 
475 } // End namespace Foam
476 
477 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
478 
479 #ifdef NoRepository
480  #include "basicThermoTemplates.C"
481 #endif
482 
483 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
484 
485 #endif
486 
487 // ************************************************************************* //
virtual tmp< volScalarField > kappaEff(const volScalarField &) const =0
Effective thermal turbulent diffusivity for temperature.
virtual ~basicThermo()
Destructor.
Definition: basicThermo.C:289
TypeName("basicThermo")
Runtime type information.
Switch dpdt() const
Should the dpdt term be included in the enthalpy equation.
Definition: basicThermo.H:265
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 [J/m/s/K].
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.
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:190
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:77
virtual tmp< volScalarField > alphaEff(const volScalarField &alphat) const =0
Effective thermal turbulent diffusivity of mixture [kg/m/s].
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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:71
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.
Definition: Switch.H:60
virtual const volScalarField & alpha() const
Thermal diffusivity for enthalpy of mixture [kg/m/s].
Definition: basicThermo.C:511
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:499
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:115
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:487
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:50
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:426
volScalarField & p_
Pressure [Pa].
Definition: basicThermo.H:68
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:82
static const word null
An empty word.
Definition: word.H:77
virtual tmp< volScalarField > hc() const =0
Chemical enthalpy [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:128
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 diffusuvity [kg/m/s].
Definition: basicThermo.H:74
label patchi
volScalarField & h
Planck constant.
basicThermo(const basicThermo &)
Construct as copy (not implemented)
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual tmp< volScalarField > gamma() const =0
Gamma = Cp/Cv [].
virtual bool read()
Read thermophysical properties dictionary.
Definition: basicThermo.C:523
virtual tmp< volScalarField > W() const =0
Molecular weight [kg/kmol].
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.
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void correct()=0
Update properties.
void validate(const string &app, const word &) const
Check that the thermodynamics package is consistent.
Definition: basicThermo.C:332
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.