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 | Copyright (C) 2011-2017 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 true if the equation of state is incompressible
255  // i.e. rho != f(p)
256  virtual bool incompressible() const = 0;
257 
258  //- Return true if the equation of state is isochoric
259  // i.e. rho = const
260  virtual bool isochoric() const = 0;
261 
262  //- Should the dpdt term be included in the enthalpy equation
263  Switch dpdt() const
264  {
265  return dpdt_;
266  }
267 
268 
269  // Access to thermodynamic state variables
270 
271  //- Pressure [Pa]
272  // Non-const access allowed for transport equations
273  virtual volScalarField& p();
274 
275  //- Pressure [Pa]
276  virtual const volScalarField& p() const;
277 
278  //- Density [kg/m^3]
279  virtual tmp<volScalarField> rho() const = 0;
280 
281  //- Density for patch [kg/m^3]
282  virtual tmp<scalarField> rho(const label patchi) const = 0;
283 
284  //- Enthalpy/Internal energy [J/kg]
285  // Non-const access allowed for transport equations
286  virtual volScalarField& he() = 0;
287 
288  //- Enthalpy/Internal energy [J/kg]
289  virtual const volScalarField& he() const = 0;
290 
291  //- Enthalpy/Internal energy
292  // for given pressure and temperature [J/kg]
293  virtual tmp<volScalarField> he
294  (
295  const volScalarField& p,
296  const volScalarField& T
297  ) const = 0;
298 
299  //- Enthalpy/Internal energy for cell-set [J/kg]
300  virtual tmp<scalarField> he
301  (
302  const scalarField& p,
303  const scalarField& T,
304  const labelList& cells
305  ) const = 0;
306 
307  //- Enthalpy/Internal energy for patch [J/kg]
308  virtual tmp<scalarField> he
309  (
310  const scalarField& p,
311  const scalarField& T,
312  const label patchi
313  ) const = 0;
314 
315  //- Chemical enthalpy [J/kg]
316  virtual tmp<volScalarField> hc() const = 0;
317 
318  //- Temperature from enthalpy/internal energy for cell-set
319  virtual tmp<scalarField> THE
320  (
321  const scalarField& h,
322  const scalarField& p,
323  const scalarField& T0, // starting temperature
324  const labelList& cells
325  ) const = 0;
326 
327  //- Temperature from enthalpy/internal energy for patch
328  virtual tmp<scalarField> THE
329  (
330  const scalarField& h,
331  const scalarField& p,
332  const scalarField& T0, // starting temperature
333  const label patchi
334  ) const = 0;
335 
336 
337  // Fields derived from thermodynamic state variables
338 
339  //- Temperature [K]
340  virtual const volScalarField& T() const;
341 
342  //- Temperature [K]
343  // Non-const access allowed for transport equations
344  virtual volScalarField& T();
345 
346  //- Heat capacity at constant pressure [J/kg/K]
347  virtual tmp<volScalarField> Cp() const = 0;
348 
349  //- Heat capacity at constant pressure for patch [J/kg/K]
350  virtual tmp<scalarField> Cp
351  (
352  const scalarField& p,
353  const scalarField& T,
354  const label patchi
355  ) const = 0;
356 
357  //- Heat capacity at constant volume [J/kg/K]
358  virtual tmp<volScalarField> Cv() const = 0;
359 
360  //- Heat capacity at constant volume for patch [J/kg/K]
361  virtual tmp<scalarField> Cv
362  (
363  const scalarField& p,
364  const scalarField& T,
365  const label patchi
366  ) const = 0;
367 
368  //- Gamma = Cp/Cv []
369  virtual tmp<volScalarField> gamma() const = 0;
370 
371  //- Gamma = Cp/Cv for patch []
372  virtual tmp<scalarField> gamma
373  (
374  const scalarField& p,
375  const scalarField& T,
376  const label patchi
377  ) const = 0;
378 
379  //- Heat capacity at constant pressure/volume [J/kg/K]
380  virtual tmp<volScalarField> Cpv() const = 0;
381 
382  //- Heat capacity at constant pressure/volume for patch [J/kg/K]
383  virtual tmp<scalarField> Cpv
384  (
385  const scalarField& p,
386  const scalarField& T,
387  const label patchi
388  ) const = 0;
389 
390  //- Heat capacity ratio []
391  virtual tmp<volScalarField> CpByCpv() const = 0;
392 
393  //- Heat capacity ratio for patch []
394  virtual tmp<scalarField> CpByCpv
395  (
396  const scalarField& p,
397  const scalarField& T,
398  const label patchi
399  ) const = 0;
400 
401 
402  // Access to transport state variables
403 
404  //- Thermal diffusivity for enthalpy of mixture [kg/m/s]
405  virtual const volScalarField& alpha() const;
406 
407  //- Thermal diffusivity for enthalpy of mixture for patch [kg/m/s]
408  virtual const scalarField& alpha
409  (
410  const label patchi
411  ) const;
412 
413 
414  // Fields derived from transport state variables
415 
416  //- Thermal diffusivity for temperature of mixture [J/m/s/K]
417  virtual tmp<volScalarField> kappa() const = 0;
418 
419  //- Thermal diffusivity for temperature
420  // of mixture for patch [J/m/s/K]
421  virtual tmp<scalarField> kappa
422  (
423  const label patchi
424  ) const = 0;
425 
426  //- Effective thermal diffusivity for temperature
427  // of mixture [J/m/s/K]
429  (
430  const volScalarField&
431  ) const = 0;
432 
433  //- Effective thermal diffusivity for temperature
434  // of mixture for patch [J/m/s/K]
435  virtual tmp<scalarField> kappaEff
436  (
437  const scalarField& alphat,
438  const label patchi
439  ) const = 0;
440 
441  //- Effective thermal diffusivity of mixture [kg/m/s]
443  (
444  const volScalarField& alphat
445  ) const = 0;
446 
447  //- Effective thermal diffusivity of mixture for patch [kg/m/s]
448  virtual tmp<scalarField> alphaEff
449  (
450  const scalarField& alphat,
451  const label patchi
452  ) const = 0;
453 
454 
455  //- Read thermophysical properties dictionary
456  virtual bool read();
457 };
458 
459 
460 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
461 
462 } // End namespace Foam
463 
464 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
465 
466 #ifdef NoRepository
467  #include "basicThermoTemplates.C"
468 #endif
469 
470 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
471 
472 #endif
473 
474 // ************************************************************************* //
virtual tmp< volScalarField > kappaEff(const volScalarField &) const =0
Effective thermal diffusivity for temperature.
virtual ~basicThermo()
Destructor.
Definition: basicThermo.C:279
TypeName("basicThermo")
Runtime type information.
Switch dpdt() const
Should the dpdt term be included in the enthalpy equation.
Definition: basicThermo.H:262
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 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].
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:501
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:489
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:477
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:416
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:513
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:322
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.