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-2015 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 each of the related thermodynamics packages
139  template<class Thermo, class Table>
140  static typename Table::iterator lookupThermo
141  (
142  const dictionary& thermoDict,
143  Table* tablePtr
144  );
145 
146  //- Generic New for each of the related thermodynamics packages
147  template<class Thermo>
148  static autoPtr<Thermo> New
149  (
150  const fvMesh&,
151  const word& phaseName=word::null
152  );
153 
154  //- Generic New for each of the related thermodynamics packages
155  template<class Thermo>
156  static autoPtr<Thermo> New
157  (
158  const fvMesh&,
159  const dictionary&,
160  const word& phaseName=word::null
161  );
162 
163  //- Specialisation of the Generic New for basicThermo
165  (
166  const fvMesh&,
167  const word& phaseName=word::null
168  );
169 
170 
171  //- Destructor
172  virtual ~basicThermo();
173 
174 
175  // Member functions
177  static const word dictName;
178 
180  (
181  const word& name,
182  const word& phaseName
183  )
184  {
185  return IOobject::groupName(name, phaseName);
186  }
188  word phasePropertyName(const word& name) const
189  {
190  return basicThermo::phasePropertyName(name, phaseName_);
191  }
192 
193  static const basicThermo& lookupThermo(const fvPatchScalarField& pf);
194 
195  //- Check that the thermodynamics package is consistent
196  // with energy forms supported by the application
197  void validate
198  (
199  const string& app,
200  const word&
201  ) const;
202 
203  //- Check that the thermodynamics package is consistent
204  // with energy forms supported by the application
205  void validate
206  (
207  const string& app,
208  const word&,
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 word&
220  ) const;
221 
222  //- Check that the thermodynamics package is consistent
223  // with energy forms supported by the application
224  void validate
225  (
226  const string& app,
227  const word&,
228  const word&,
229  const word&,
230  const word&
231  ) const;
232 
233  //- Split name of thermo package into a list of the components names
235  (
236  const word& thermoName,
237  const int nCmpt
238  );
239 
240  //- Update properties
241  virtual void correct() = 0;
242 
243  //- Return true if the equation of state is incompressible
244  // i.e. rho != f(p)
245  virtual bool incompressible() const = 0;
246 
247  //- Return true if the equation of state is isochoric
248  // i.e. rho = const
249  virtual bool isochoric() const = 0;
250 
251  //- Should the dpdt term be included in the enthalpy equation
252  Switch dpdt() const
253  {
254  return dpdt_;
255  }
256 
257 
258  // Access to thermodynamic state variables
259 
260  //- Pressure [Pa]
261  // Non-const access allowed for transport equations
262  virtual volScalarField& p();
263 
264  //- Pressure [Pa]
265  virtual const volScalarField& p() const;
266 
267  //- Density [kg/m^3]
268  virtual tmp<volScalarField> rho() const = 0;
269 
270  //- Density for patch [kg/m^3]
271  virtual tmp<scalarField> rho(const label patchi) const = 0;
272 
273  //- Enthalpy/Internal energy [J/kg]
274  // Non-const access allowed for transport equations
275  virtual volScalarField& he() = 0;
276 
277  //- Enthalpy/Internal energy [J/kg]
278  virtual const volScalarField& he() const = 0;
279 
280  //- Enthalpy/Internal energy
281  // for given pressure and temperature [J/kg]
282  virtual tmp<volScalarField> he
283  (
284  const volScalarField& p,
285  const volScalarField& T
286  ) const = 0;
287 
288  //- Enthalpy/Internal energy for cell-set [J/kg]
289  virtual tmp<scalarField> he
290  (
291  const scalarField& p,
292  const scalarField& T,
293  const labelList& cells
294  ) const = 0;
295 
296  //- Enthalpy/Internal energy for patch [J/kg]
297  virtual tmp<scalarField> he
298  (
299  const scalarField& p,
300  const scalarField& T,
301  const label patchi
302  ) const = 0;
303 
304  //- Chemical enthalpy [J/kg]
305  virtual tmp<volScalarField> hc() const = 0;
306 
307  //- Temperature from enthalpy/internal energy for cell-set
308  virtual tmp<scalarField> THE
309  (
310  const scalarField& h,
311  const scalarField& p,
312  const scalarField& T0, // starting temperature
313  const labelList& cells
314  ) const = 0;
315 
316  //- Temperature from enthalpy/internal energy for patch
317  virtual tmp<scalarField> THE
318  (
319  const scalarField& h,
320  const scalarField& p,
321  const scalarField& T0, // starting temperature
322  const label patchi
323  ) const = 0;
324 
325 
326  // Fields derived from thermodynamic state variables
327 
328  //- Temperature [K]
329  virtual const volScalarField& T() const;
330 
331  //- Temperature [K]
332  // Non-const access allowed for transport equations
333  virtual volScalarField& T();
334 
335  //- Heat capacity at constant pressure [J/kg/K]
336  virtual tmp<volScalarField> Cp() const = 0;
337 
338  //- Heat capacity at constant pressure for patch [J/kg/K]
339  virtual tmp<scalarField> Cp
340  (
341  const scalarField& p,
342  const scalarField& T,
343  const label patchi
344  ) const = 0;
345 
346  //- Heat capacity at constant volume [J/kg/K]
347  virtual tmp<volScalarField> Cv() const = 0;
348 
349  //- Heat capacity at constant volume for patch [J/kg/K]
350  virtual tmp<scalarField> Cv
351  (
352  const scalarField& p,
353  const scalarField& T,
354  const label patchi
355  ) const = 0;
356 
357  //- Gamma = Cp/Cv []
358  virtual tmp<volScalarField> gamma() const = 0;
359 
360  //- Gamma = Cp/Cv for patch []
361  virtual tmp<scalarField> gamma
362  (
363  const scalarField& p,
364  const scalarField& T,
365  const label patchi
366  ) const = 0;
367 
368  //- Heat capacity at constant pressure/volume [J/kg/K]
369  virtual tmp<volScalarField> Cpv() const = 0;
370 
371  //- Heat capacity at constant pressure/volume for patch [J/kg/K]
372  virtual tmp<scalarField> Cpv
373  (
374  const scalarField& p,
375  const scalarField& T,
376  const label patchi
377  ) const = 0;
378 
379  //- Heat capacity ratio []
380  virtual tmp<volScalarField> CpByCpv() const = 0;
381 
382  //- Heat capacity ratio for patch []
383  virtual tmp<scalarField> CpByCpv
384  (
385  const scalarField& p,
386  const scalarField& T,
387  const label patchi
388  ) const = 0;
389 
390 
391  // Access to transport state variables
392 
393  //- Thermal diffusivity for enthalpy of mixture [kg/m/s]
394  virtual const volScalarField& alpha() const;
395 
396  //- Thermal diffusivity for enthalpy of mixture for patch [kg/m/s]
397  virtual const scalarField& alpha
398  (
399  const label patchi
400  ) const;
401 
402 
403  // Fields derived from transport state variables
404 
405  //- Thermal diffusivity for temperature of mixture [J/m/s/K]
406  virtual tmp<volScalarField> kappa() const = 0;
407 
408  //- Thermal diffusivity for temperature
409  // of mixture for patch [J/m/s/K]
410  virtual tmp<scalarField> kappa
411  (
412  const label patchi
413  ) const = 0;
414 
415  //- Effective thermal diffusivity for temperature
416  // of mixture [J/m/s/K]
418  (
419  const volScalarField&
420  ) const = 0;
421 
422  //- Effective thermal diffusivity for temperature
423  // of mixture for patch [J/m/s/K]
424  virtual tmp<scalarField> kappaEff
425  (
426  const scalarField& alphat,
427  const label patchi
428  ) const = 0;
429 
430  //- Effective thermal diffusivity of mixture [kg/m/s]
432  (
433  const volScalarField& alphat
434  ) const = 0;
435 
436  //- Effective thermal diffusivity of mixture for patch [kg/m/s]
437  virtual tmp<scalarField> alphaEff
438  (
439  const scalarField& alphat,
440  const label patchi
441  ) const = 0;
442 
443 
444  //- Read thermophysical properties dictionary
445  virtual bool read();
446 };
447 
448 
449 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
450 
451 } // End namespace Foam
452 
453 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
454 
455 #ifdef NoRepository
456 # include "basicThermoTemplates.C"
457 #endif
458 
459 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
460 
461 #endif
462 
463 // ************************************************************************* //
static autoPtr< Thermo > New(const fvMesh &, const word &phaseName=word::null)
Generic New for each of the related thermodynamics packages.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual const volScalarField & T() const
Temperature [K].
Definition: basicThermo.C:478
declareRunTimeSelectionTable(autoPtr, basicThermo, fvMesh,(const fvMesh &mesh, const word &phaseName),(mesh, phaseName))
Declare run-time constructor selection table.
virtual tmp< volScalarField > rho() const =0
Density [kg/m^3].
volScalarField & lookupOrConstruct(const fvMesh &mesh, const char *name) const
Definition: basicThermo.C:128
basicThermo(const basicThermo &)
Construct as copy (not implemented)
virtual void correct()=0
Update properties.
virtual tmp< volScalarField > kappa() const =0
Thermal diffusivity for temperature of mixture [J/m/s/K].
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:52
static Table::iterator lookupThermo(const dictionary &thermoDict, Table *tablePtr)
Generic lookup for each of the related thermodynamics packages.
A class for handling words, derived from string.
Definition: word.H:59
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 > Cpv() const =0
Heat capacity at constant pressure/volume [J/kg/K].
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:466
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
dynamicFvMesh & mesh
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const word & name() const
Name function is needed to disambiguate those inherited.
Definition: IOdictionary.C:183
Templated table container data entry. Items are stored in a list of Tuple2&#39;s. First column is always ...
Definition: Table.H:56
virtual tmp< volScalarField > Cp() const =0
Heat capacity at constant pressure [J/kg/K].
Namespace for OpenFOAM.
virtual ~basicThermo()
Destructor.
Definition: basicThermo.C:282
void validate(const string &app, const word &) const
Check that the thermodynamics package is consistent.
Definition: basicThermo.C:325
static word groupName(Name name, const word &group)
virtual tmp< volScalarField > Cv() const =0
Heat capacity at constant volume [J/kg/K].
virtual bool read()
Read thermophysical properties dictionary.
Definition: basicThermo.C:502
virtual tmp< volScalarField > hc() const =0
Chemical enthalpy [J/kg].
volScalarField & p_
Pressure [Pa].
Definition: basicThermo.H:68
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
label patchi
volScalarField T_
Temperature [K].
Definition: basicThermo.H:71
static wordList splitThermoName(const word &thermoName, const int nCmpt)
Split name of thermo package into a list of the components names.
Definition: basicThermo.C:419
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
virtual tmp< volScalarField > kappaEff(const volScalarField &) const =0
Effective thermal diffusivity for temperature.
const cellShapeList & cells
wordList heBoundaryTypes()
Return the enthalpy/internal energy field boundary types.
Definition: basicThermo.C:82
virtual bool isochoric() const =0
Return true if the equation of state is isochoric.
virtual tmp< volScalarField > CpByCpv() const =0
Heat capacity ratio [].
TypeName("basicThermo")
Runtime type information.
virtual const volScalarField & alpha() const
Thermal diffusivity for enthalpy of mixture [kg/m/s].
Definition: basicThermo.C:490
virtual bool incompressible() const =0
Return true if the equation of state is incompressible.
virtual tmp< volScalarField > gamma() const =0
Gamma = Cp/Cv [].
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
static word phasePropertyName(const word &name, const word &phaseName)
Definition: basicThermo.H:179
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.
virtual tmp< volScalarField > alphaEff(const volScalarField &alphat) const =0
Effective thermal diffusivity of mixture [kg/m/s].
volScalarField alpha_
Laminar thermal diffusuvity [kg/m/s].
Definition: basicThermo.H:74
Switch dpdt() const
Should the dpdt term be included in the enthalpy equation.
Definition: basicThermo.H:251
wordList heBoundaryBaseTypes()
Return the enthalpy/internal energy field boundary base types.
Definition: basicThermo.C:50
const word & phaseName_
Phase-name.
Definition: basicThermo.H:62
Switch dpdt_
Should the dpdt term be included in the enthalpy equation.
Definition: basicThermo.H:77
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
A class for managing temporary objects.
Definition: PtrList.H:118
static const word null
An empty word.
Definition: word.H:77
const dimensionedScalar h
Planck constant.
Definition: createFields.H:6
virtual volScalarField & he()=0
Enthalpy/Internal energy [J/kg].