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-2026 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  Thermo implementation and storage of energy and heat capacities. Provides
29  overloads of the functions defined in the basic thermo type that depend on
30  the primitive thermo model.
31 
32 SourceFiles
33  BasicThermo.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef BasicThermo_H
38 #define BasicThermo_H
39 
40 #include "volFields.H"
41 #include "physicalProperties.H"
42 #include "uniformGeometricFields.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class BasicThermoName Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 
55 
56 /*---------------------------------------------------------------------------*\
57  Class BasicThermo Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class MixtureType, class BasicThermoType>
61 class BasicThermo
62 :
63  public BasicThermoName,
64  public physicalProperties,
65  public MixtureType,
66  public BasicThermoType
67 {
68 protected:
69 
70  // Protected data
71 
72  //- Energy field
74 
75  //- Heat capacity at constant pressure field [J/kg/K]
77 
78  // Heat capacity at constant volume field [J/kg/K]
80 
81 
82  // Protected Member Functions
83 
84  //- Return a volScalarField of the given property
85  template<class Mixture, class Method, class ... Args>
87  (
88  const word& psiName,
89  const dimensionSet& psiDim,
90  Mixture mixture,
91  Method psiMethod,
92  const Args& ... args
93  ) const;
94 
95  //- Return a volScalarField of the given property of the mixture
96  template<class Method, class ... Args>
98  (
99  const word& psiName,
100  const dimensionSet& psiDim,
101  Method mixtureMethod,
102  const Args& ... args
103  ) const;
104 
105  //- Return a volScalarField::Internal of the given property
106  template<class Mixture, class Method, class ... Args>
108  (
109  const word& psiName,
110  const dimensionSet& psiDim,
111  Mixture mixture,
112  Method psiMethod,
113  const Args& ... args
114  ) const;
115 
116  //- Return a scalarField of the given property on a cell set
117  template<class Mixture, class Method, class ... Args>
119  (
120  Mixture mixture,
121  Method psiMethod,
122  const labelList& cells,
123  const Args& ... args
124  ) const;
125 
126  //- Return a scalarField of the given property on a patch
127  template<class Mixture, class Method, class ... Args>
129  (
130  Mixture mixture,
131  Method psiMethod,
132  const label patchi,
133  const Args& ... args
134  ) const;
135 
136  //- Return a scalarField of the given property for a source
137  template<class Mixture, class Method, class ... Args>
139  (
140  const word& psiName,
141  const dimensionSet& psiDim,
142  Mixture mixture,
143  Method psiMethod,
144  const fvSource& model,
145  const volScalarField::Internal& source,
146  const Args& ... args
147  ) const;
148 
149  //- Return a scalarField of the given property for a source
150  template<class Mixture, class Method, class ... Args>
152  (
153  Mixture mixture,
154  Method psiMethod,
155  const fvSource& model,
156  const scalarField& source,
157  const labelUList& cells,
158  const Args& ... args
159  ) const;
160 
161  //- Return an indirect list of a field for the given set of cells
163  (
164  const volScalarField& psi,
165  const labelUList& cells
166  );
167 
168  //- Return an indirect list of a field for the given set of cells
170  (
171  const uniformGeometricScalarField& psi,
172  const labelUList&
173  );
174 
175  //- Correct the enthalpy/internal energy field boundaries
177 
178 
179 public:
180 
181  // Typedefs
182 
183  //- Mixture type
184  typedef MixtureType mixtureType;
185 
186  //- Basic thermo
187  typedef BasicThermoType basicThermoType;
188 
189 
190  //- Disambiguate debug switch used by derivations
191  using BasicThermoName::debug;
192 
193 
194  // Constructors
195 
196  //- Construct from mesh and phase name
197  BasicThermo(const fvMesh&, const word& phaseName);
198 
199  //- Disallow default bitwise copy construction
201 
202 
203  //- Destructor
204  virtual ~BasicThermo();
205 
206 
207  // Member Functions
208 
209  //- Return the properties dictionary
210  virtual IOdictionary& properties()
211  {
212  return *this;
213  }
214 
215  //- Return the properties dictionary
216  virtual const IOdictionary& properties() const
217  {
218  return *this;
219  }
220 
221  //- Return the name of the mixture
222  virtual word mixtureName() const
223  {
224  return mixtureType::typeName();
225  }
226 
227  //- Return the name of the thermo physics
228  virtual word thermoName() const
229  {
231  }
232 
233  //- Return true if the equation of state is incompressible
234  // i.e. rho != f(p)
235  virtual bool incompressible() const
236  {
237  return MixtureType::thermoType::incompressible;
238  }
239 
240  //- Return true if the equation of state is isochoric
241  // i.e. rho = const
242  virtual bool isochoric() const
243  {
244  return MixtureType::thermoType::isochoric;
245  }
246 
247 
248  // Molecular properties
249 
250  //- Molecular weight [kg/kmol]
251  virtual tmp<volScalarField> W() const;
252 
253  //- Molecular weight for patch [kg/kmol]
254  virtual tmp<scalarField> W(const label patchi) const;
255 
256 
257  // Thermodynamic state
258 
259  //- Enthalpy/Internal energy [J/kg]
260  virtual const volScalarField& he() const
261  {
262  return he_;
263  }
264 
265  //- Enthalpy/Internal energy [J/kg]
266  // Non-const access allowed for transport equations
267  virtual volScalarField& he()
268  {
269  return he_;
270  }
271 
272  //- Heat capacity at constant pressure [J/kg/K]
273  virtual const volScalarField& Cp() const
274  {
275  return Cp_;
276  }
277 
278  //- Heat capacity at constant volume [J/kg/K]
279  virtual const volScalarField& Cv() const
280  {
281  return Cv_;
282  }
283 
284  //- Heat capacity at constant pressure/volume [J/kg/K]
285  virtual const volScalarField& Cpv() const;
286 
287 
288  // Derived Thermodynamic Properties
289 
290  //- Enthalpy/Internal energy
291  // for given pressure and temperature [J/kg]
292  virtual tmp<volScalarField> he
293  (
294  const volScalarField& p,
295  const volScalarField& T
296  ) const;
297 
298  //- Enthalpy/Internal energy
299  // for given pressure and temperature [J/kg]
301  (
304  ) const;
305 
306  //- Enthalpy/Internal energy for cell-set [J/kg]
307  virtual tmp<scalarField> he
308  (
309  const scalarField& T,
310  const labelList& cells
311  ) const;
312 
313  //- Enthalpy/Internal energy for patch [J/kg]
314  virtual tmp<scalarField> he
315  (
316  const scalarField& T,
317  const label patchi
318  ) const;
319 
320  //- Enthalpy/Internal energy for source [J/kg]
322  (
324  const fvSource& model,
325  const volScalarField::Internal& source
326  ) const;
327 
328  //- Enthalpy/Internal energy for source [J/kg]
329  virtual tmp<scalarField> he
330  (
331  const scalarField& T,
332  const fvSource& model,
333  const scalarField& source,
334  const labelUList& cells
335  ) const;
336 
337  //- Sensible enthalpy [J/kg/K]
338  virtual tmp<volScalarField> hs() const;
339 
340  //- Sensible enthalpy
341  // for given pressure and temperature [J/kg]
342  virtual tmp<volScalarField> hs
343  (
344  const volScalarField& p,
345  const volScalarField& T
346  ) const;
347 
348  //- Sensible enthalpy
349  // for given pressure and temperature [J/kg]
351  (
354  ) const;
355 
356  //- Sensible enthalpy for patch [J/kg/K]
357  virtual tmp<scalarField> hs
358  (
359  const scalarField& T,
360  const label patchi
361  ) const;
362 
363  //- Sensible enthalpy for cell-set [J/kg]
364  virtual tmp<scalarField> hs
365  (
366  const scalarField& T,
367  const labelList& cells
368  ) const;
369 
370  //- Absolute enthalpy [J/kg/K]
371  virtual tmp<volScalarField> ha() const;
372 
373  //- Absolute enthalpy
374  // for given pressure and temperature [J/kg]
375  virtual tmp<volScalarField> ha
376  (
377  const volScalarField& p,
378  const volScalarField& T
379  ) const;
380 
381  //- Absolute enthalpy
382  // for given pressure and temperature [J/kg]
384  (
387  ) const;
388 
389  //- Absolute enthalpy for patch [J/kg/K]
390  virtual tmp<scalarField> ha
391  (
392  const scalarField& T,
393  const label patchi
394  ) const;
395 
396  //- Absolute enthalpy for cell-set [J/kg]
397  virtual tmp<scalarField> ha
398  (
399  const scalarField& T,
400  const labelList& cells
401  ) const;
402 
403  //- Heat capacity at constant pressure for patch [J/kg/K]
404  virtual tmp<scalarField> Cp
405  (
406  const scalarField& T,
407  const label patchi
408  ) const;
409 
410  //- Heat capacity at constant volume for patch [J/kg/K]
411  virtual tmp<scalarField> Cv
412  (
413  const scalarField& T,
414  const label patchi
415  ) const;
416 
417  //- Heat capacity at constant pressure/volume for patch [J/kg/K]
418  virtual tmp<scalarField> Cpv
419  (
420  const scalarField& T,
421  const label patchi
422  ) const;
423 
424 
425  // Temperature-energy inversion functions
426 
427  //- Temperature from enthalpy/internal energy
428  virtual tmp<volScalarField> The
429  (
430  const volScalarField& h,
431  const volScalarField& p,
432  const volScalarField& T0 // starting temperature
433  ) const;
434 
435  //- Temperature from enthalpy/internal energy for cell-set
436  virtual tmp<scalarField> The
437  (
438  const scalarField& he,
439  const scalarField& T0, // starting temperature
440  const labelList& cells
441  ) const;
442 
443  //- Temperature from enthalpy/internal energy for patch
444  virtual tmp<scalarField> The
445  (
446  const scalarField& he,
447  const scalarField& T0, // starting temperature
448  const label patchi
449  ) const;
450 
451 
452  //- Read thermophysical properties dictionary
453  using BasicThermoType::read;
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 "BasicThermo.C"
468 #endif
469 
470 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
471 
472 #endif
473 
474 // ************************************************************************* //
Thermo implementation and storage of energy and heat capacities. Provides overloads of the functions ...
Definition: BasicThermo.H:66
BasicThermo(const fvMesh &, const word &phaseName)
Construct from mesh and phase name.
Definition: BasicThermo.C:360
virtual const volScalarField & Cv() const
Heat capacity at constant volume [J/kg/K].
Definition: BasicThermo.H:278
virtual tmp< volScalarField > W() const
Molecular weight [kg/kmol].
Definition: BasicThermo.C:443
virtual const volScalarField & Cp() const
Heat capacity at constant pressure [J/kg/K].
Definition: BasicThermo.H:272
tmp< volScalarField > volScalarFieldProperty(const word &psiName, const dimensionSet &psiDim, Mixture mixture, Method psiMethod, const Args &... args) const
Return a volScalarField of the given property.
volScalarField Cv_
Definition: BasicThermo.H:78
virtual word thermoName() const
Return the name of the thermo physics.
Definition: BasicThermo.H:227
tmp< scalarField > cellSetProperty(Mixture mixture, Method psiMethod, const labelList &cells, const Args &... args) const
Return a scalarField of the given property on a cell set.
virtual bool incompressible() const
Return true if the equation of state is incompressible.
Definition: BasicThermo.H:234
tmp< volScalarField > volScalarFieldMixtureProperty(const word &psiName, const dimensionSet &psiDim, Method mixtureMethod, const Args &... args) const
Return a volScalarField of the given property of the mixture.
static UIndirectList< scalar > cellSetScalarList(const volScalarField &psi, const labelUList &cells)
Return an indirect list of a field for the given set of cells.
Definition: BasicThermo.C:311
virtual tmp< volScalarField > ha() const
Absolute enthalpy [J/kg/K].
Definition: BasicThermo.C:706
virtual const volScalarField & he() const
Enthalpy/Internal energy [J/kg].
Definition: BasicThermo.H:259
volScalarField Cp_
Heat capacity at constant pressure field [J/kg/K].
Definition: BasicThermo.H:75
MixtureType mixtureType
Mixture type.
Definition: BasicThermo.H:183
virtual word mixtureName() const
Return the name of the mixture.
Definition: BasicThermo.H:221
volScalarField he_
Energy field.
Definition: BasicThermo.H:72
BasicThermoType basicThermoType
Basic thermo.
Definition: BasicThermo.H:186
tmp< scalarField > patchFieldProperty(Mixture mixture, Method psiMethod, const label patchi, const Args &... args) const
Return a scalarField of the given property on a patch.
tmp< volScalarField::Internal > fieldSourceProperty(const word &psiName, const dimensionSet &psiDim, Mixture mixture, Method psiMethod, const fvSource &model, const volScalarField::Internal &source, const Args &... args) const
Return a scalarField of the given property for a source.
void heBoundaryCorrection(volScalarField &he)
Correct the enthalpy/internal energy field boundaries.
Definition: BasicThermo.C:334
virtual const volScalarField & Cpv() const
Heat capacity at constant pressure/volume [J/kg/K].
Definition: BasicThermo.C:473
virtual ~BasicThermo()
Destructor.
Definition: BasicThermo.C:435
virtual tmp< volScalarField > hs() const
Sensible enthalpy [J/kg/K].
Definition: BasicThermo.C:612
virtual tmp< volScalarField > The(const volScalarField &h, const volScalarField &p, const volScalarField &T0) const
Temperature from enthalpy/internal energy.
Definition: BasicThermo.C:858
tmp< volScalarField::Internal > volInternalScalarFieldProperty(const word &psiName, const dimensionSet &psiDim, Mixture mixture, Method psiMethod, const Args &... args) const
Return a volScalarField::Internal of the given property.
virtual bool read()
Read thermophysical properties dictionary.
Definition: BasicThermo.C:920
virtual IOdictionary & properties()
Return the properties dictionary.
Definition: BasicThermo.H:209
virtual bool isochoric() const
Return true if the equation of state is isochoric.
Definition: BasicThermo.H:241
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
A class representing the concept of a uniform field which stores only the single value and providing ...
Definition: UniformField.H:48
Dimension set for the base types.
Definition: dimensionSet.H:125
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Base class for finite volume sources.
Definition: fvSource.H:53
A base class for physical properties.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
const scalar T0
label patchi
const cellShapeList & cells
const volScalarField & psi
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
const dimensionedScalar h
Planck constant.
Namespace for OpenFOAM.
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
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
TemplateName(FvFaceCellWave)
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
Foam::argList args(argc, argv)
volScalarField & p
Typedefs for UniformGeometricField.