heThermo.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-2022 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::heThermo
26 
27 Description
28  Enthalpy/Internal energy for a mixture
29 
30 SourceFiles
31  heThermo.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef heThermo_H
36 #define heThermo_H
37 
38 #include "basicMixture.H"
39 #include "volFields.H"
40 #include "uniformGeometricFields.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class heThermo Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 template<class BasicThermo, class MixtureType>
52 class heThermo
53 :
54  public BasicThermo,
55  public MixtureType
56 {
57 protected:
58 
59  // Protected data
60 
61  //- Energy field
63 
64  //- Heat capacity at constant pressure field [J/kg/K]
66 
67  // Heat capacity at constant volume field [J/kg/K]
69 
70 
71  // Protected Member Functions
72 
73  //- Return a volScalarField of the given property
74  template
75  <
76  class CellMixture,
77  class PatchFaceMixture,
78  class Method,
79  class ... Args
80  >
82  (
83  const word& psiName,
84  const dimensionSet& psiDim,
85  CellMixture cellMixture,
86  PatchFaceMixture patchFaceMixture,
87  Method psiMethod,
88  const Args& ... args
89  ) const;
90 
91  //- Return a scalarField of the given property on a cell set
92  template<class CellMixture, class Method, class ... Args>
94  (
95  CellMixture cellMixture,
96  Method psiMethod,
97  const labelList& cells,
98  const Args& ... args
99  ) const;
100 
101  //- Return a scalarField of the given property on a patch
102  template<class PatchFaceMixture, class Method, class ... Args>
104  (
105  PatchFaceMixture patchFaceMixture,
106  Method psiMethod,
107  const label patchi,
108  const Args& ... args
109  ) const;
110 
111  //- Return an indirect list of a field for the given set of cells
113  (
114  const volScalarField& psi,
115  const labelList& cells
116  );
117 
118  //- Return an indirect list of a field for the given set of cells
120  (
122  const labelList&
123  );
124 
125  //- Correct the enthalpy/internal energy field boundaries
127 
128 
129 public:
130 
131  // Constructors
132 
133  //- Construct from mesh
134  heThermo
135  (
136  const fvMesh&,
137  const word& phaseName
138  );
139 
140  //- Disallow default bitwise copy construction
142 
143 
144  //- Destructor
145  virtual ~heThermo();
146 
147 
148  // Member Functions
149 
150  //- Return the composition of the mixture
151  virtual typename MixtureType::basicMixtureType&
152  composition()
153  {
154  return *this;
155  }
156 
157  //- Return the composition of the mixture
158  virtual const typename MixtureType::basicMixtureType&
159  composition() const
160  {
161  return *this;
162  }
163 
164  //- Return the name of the thermo physics
165  virtual word thermoName() const
166  {
167  return MixtureType::thermoType::typeName();
168  }
169 
170  //- Return true if the equation of state is incompressible
171  // i.e. rho != f(p)
172  virtual bool incompressible() const
173  {
174  return MixtureType::thermoType::incompressible;
175  }
176 
177  //- Return true if the equation of state is isochoric
178  // i.e. rho = const
179  virtual bool isochoric() const
180  {
181  return MixtureType::thermoType::isochoric;
182  }
183 
184 
185  // Access to thermodynamic state variables
186 
187  //- Enthalpy/Internal energy [J/kg]
188  // Non-const access allowed for transport equations
189  virtual volScalarField& he()
190  {
191  return he_;
192  }
193 
194  //- Enthalpy/Internal energy [J/kg]
195  virtual const volScalarField& he() const
196  {
197  return he_;
198  }
199 
200  //- Heat capacity at constant pressure [J/kg/K]
201  virtual const volScalarField& Cp() const
202  {
203  return Cp_;
204  }
205 
206  //- Heat capacity at constant volume [J/kg/K]
207  virtual const volScalarField& Cv() const
208  {
209  return Cv_;
210  }
211 
212  //- Heat capacity at constant pressure/volume [J/kg/K]
213  virtual const volScalarField& Cpv() const;
214 
215 
216  // Fields derived from thermodynamic state variables
217 
218  //- Enthalpy/Internal energy
219  // for given pressure and temperature [J/kg]
220  virtual tmp<volScalarField> he
221  (
222  const volScalarField& p,
223  const volScalarField& T
224  ) const;
225 
226  //- Enthalpy/Internal energy for cell-set [J/kg]
227  virtual tmp<scalarField> he
228  (
229  const scalarField& T,
230  const labelList& cells
231  ) const;
232 
233  //- Enthalpy/Internal energy for patch [J/kg]
234  virtual tmp<scalarField> he
235  (
236  const scalarField& T,
237  const label patchi
238  ) const;
239 
240  //- Sensible enthalpy [J/kg/K]
241  virtual tmp<volScalarField> hs() const;
242 
243  //- Sensible enthalpy
244  // for given pressure and temperature [J/kg]
245  virtual tmp<volScalarField> hs
246  (
247  const volScalarField& p,
248  const volScalarField& T
249  ) const;
250 
251  //- Sensible enthalpy for patch [J/kg/K]
252  virtual tmp<scalarField> hs
253  (
254  const scalarField& T,
255  const label patchi
256  ) const;
257 
258  //- Sensible enthalpy for cell-set [J/kg]
259  virtual tmp<scalarField> hs
260  (
261  const scalarField& T,
262  const labelList& cells
263  ) const;
264 
265  //- Absolute enthalpy [J/kg/K]
266  virtual tmp<volScalarField> ha() const;
267 
268  //- Absolute enthalpy
269  // for given pressure and temperature [J/kg]
270  virtual tmp<volScalarField> ha
271  (
272  const volScalarField& p,
273  const volScalarField& T
274  ) const;
275 
276  //- Absolute enthalpy for patch [J/kg/K]
277  virtual tmp<scalarField> ha
278  (
279  const scalarField& T,
280  const label patchi
281  ) const;
282 
283  //- Absolute enthalpy for cell-set [J/kg]
284  virtual tmp<scalarField> ha
285  (
286  const scalarField& T,
287  const labelList& cells
288  ) const;
289 
290  //- Enthalpy of formation [J/kg]
291  virtual tmp<volScalarField> hc() const;
292 
293  //- Temperature from enthalpy/internal energy
294  virtual tmp<volScalarField> THE
295  (
296  const volScalarField& h,
297  const volScalarField& p,
298  const volScalarField& T0 // starting temperature
299  ) const;
300 
301  //- Temperature from enthalpy/internal energy for cell-set
302  virtual tmp<scalarField> THE
303  (
304  const scalarField& he,
305  const scalarField& T0, // starting temperature
306  const labelList& cells
307  ) const;
308 
309  //- Temperature from enthalpy/internal energy for patch
310  virtual tmp<scalarField> THE
311  (
312  const scalarField& he,
313  const scalarField& T0, // starting temperature
314  const label patchi
315  ) const;
316 
317  //- Heat capacity at constant pressure for patch [J/kg/K]
318  virtual tmp<scalarField> Cp
319  (
320  const scalarField& T,
321  const label patchi
322  ) const;
323 
324  //- Heat capacity at constant volume for patch [J/kg/K]
325  virtual tmp<scalarField> Cv
326  (
327  const scalarField& T,
328  const label patchi
329  ) const;
330 
331  //- Gamma = Cp/Cv []
332  virtual tmp<volScalarField> gamma() const;
333 
334  //- Gamma = Cp/Cv for patch []
335  virtual tmp<scalarField> gamma
336  (
337  const scalarField& T,
338  const label patchi
339  ) const;
340 
341  //- Heat capacity at constant pressure/volume for patch [J/kg/K]
342  virtual tmp<scalarField> Cpv
343  (
344  const scalarField& T,
345  const label patchi
346  ) const;
347 
348  //- Molecular weight [kg/kmol]
349  virtual tmp<volScalarField> W() const;
350 
351  //- Molecular weight for patch [kg/kmol]
352  virtual tmp<scalarField> W(const label patchi) const;
353 
354 
355  //- Read thermophysical properties dictionary
356  virtual bool read();
357 };
358 
359 
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 
362 } // End namespace Foam
363 
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
365 
366 #ifdef NoRepository
367  #include "heThermo.C"
368 #endif
369 
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
371 
372 #endif
373 
374 // ************************************************************************* //
Generic GeometricField class.
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:122
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Enthalpy/Internal energy for a mixture.
Definition: heThermo.H:55
heThermo(const fvMesh &, const word &phaseName)
Construct from mesh.
Definition: heThermo.C:195
virtual const volScalarField & Cv() const
Heat capacity at constant volume [J/kg/K].
Definition: heThermo.H:206
virtual tmp< volScalarField > W() const
Molecular weight [kg/kmol].
Definition: heThermo.C:645
virtual const volScalarField & Cp() const
Heat capacity at constant pressure [J/kg/K].
Definition: heThermo.H:200
volScalarField Cv_
Definition: heThermo.H:67
virtual word thermoName() const
Return the name of the thermo physics.
Definition: heThermo.H:164
virtual bool incompressible() const
Return true if the equation of state is incompressible.
Definition: heThermo.H:171
virtual tmp< volScalarField > ha() const
Absolute enthalpy [J/kg/K].
Definition: heThermo.C:414
volScalarField Cp_
Heat capacity at constant pressure field [J/kg/K].
Definition: heThermo.H:64
static UIndirectList< scalar > cellSetScalarList(const volScalarField &psi, const labelList &cells)
Return an indirect list of a field for the given set of cells.
Definition: heThermo.C:148
tmp< scalarField > cellSetProperty(CellMixture cellMixture, Method psiMethod, const labelList &cells, const Args &... args) const
Return a scalarField of the given property on a cell set.
volScalarField he_
Energy field.
Definition: heThermo.H:61
virtual ~heThermo()
Destructor.
Definition: heThermo.C:262
virtual tmp< volScalarField > hc() const
Enthalpy of formation [J/kg].
Definition: heThermo.C:487
void heBoundaryCorrection(volScalarField &he)
Correct the enthalpy/internal energy field boundaries.
Definition: heThermo.C:171
virtual MixtureType::basicMixtureType & composition()
Return the composition of the mixture.
Definition: heThermo.H:151
tmp< scalarField > patchFieldProperty(PatchFaceMixture patchFaceMixture, Method psiMethod, const label patchi, const Args &... args) const
Return a scalarField of the given property on a patch.
virtual tmp< volScalarField > gamma() const
Gamma = Cp/Cv [].
Definition: heThermo.C:557
virtual const volScalarField & Cpv() const
Heat capacity at constant pressure/volume [J/kg/K].
Definition: heThermo.C:270
virtual tmp< volScalarField > hs() const
Sensible enthalpy [J/kg/K].
Definition: heThermo.C:341
virtual volScalarField & he()
Enthalpy/Internal energy [J/kg].
Definition: heThermo.H:188
virtual tmp< volScalarField > THE(const volScalarField &h, const volScalarField &p, const volScalarField &T0) const
Temperature from enthalpy/internal energy.
Definition: heThermo.C:583
tmp< volScalarField > volScalarFieldProperty(const word &psiName, const dimensionSet &psiDim, CellMixture cellMixture, PatchFaceMixture patchFaceMixture, Method psiMethod, const Args &... args) const
Return a volScalarField of the given property.
virtual bool read()
Read thermophysical properties dictionary.
Definition: heThermo.C:674
virtual bool isochoric() const
Return true if the equation of state is isochoric.
Definition: heThermo.H:178
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
label patchi
const cellShapeList & cells
const volScalarField & psi
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
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Foam::argList args(argc, argv)
volScalarField & p
scalar T0
Definition: createFields.H:22