multicomponentThermo.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) 2023-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::multicomponentThermo
26 
27 Description
28  Base-class for multi-component thermodynamic properties.
29 
30 See also
31  Foam::basicThermo
32 
33 SourceFiles
34  multicomponentThermo.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef multicomponentThermo_H
39 #define multicomponentThermo_H
40 
41 #include "basicThermo.H"
42 #include "MulticomponentThermo.H"
43 #include "speciesTable.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class multicomponentThermo Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  virtual public basicThermo
59 {
60 public:
61 
62  //- Runtime type information
63  TypeName("multicomponentThermo");
64 
65 
66  // Public Classes
67 
68  //- Forward declare the implementation class
69  class implementation;
70 
71 
72  //- Destructor
73  virtual ~multicomponentThermo();
74 
75 
76  // Member Functions
77 
78  // Species set
79 
80  //- Return the table of species
81  virtual const speciesTable& species() const = 0;
82 
83  //- Does the mixture include this specie?
84  inline bool containsSpecie(const word& specieName) const;
85 
86  //- The index of the default specie
87  virtual label defaultSpecie() const = 0;
88 
89 
90  // Active/Inactive handling
91 
92  //- Access the specie active flags
93  virtual const boolList& speciesActive() const = 0;
94 
95  //- Synchronise the specie active flags
96  virtual void syncSpeciesActive() const = 0;
97 
98  //- Set specie active
99  inline void setSpecieActive(const label speciei) const;
100 
101  //- Set specie inactive
102  inline void setSpecieInactive(const label speciei) const;
103 
104  //- Should the given specie be solved for? I.e., is it active and
105  // not the default specie?
106  inline bool solveSpecie(const label speciei) const;
107 
108 
109  // Mass fractions
110 
111  //- Access the mass-fraction fields
112  virtual PtrList<volScalarField>& Y() = 0;
113 
114  //- Access the mass-fraction fields
115  virtual const PtrList<volScalarField>& Y() const = 0;
116 
117  //- Access the mass-fraction field for a specie given by index
118  inline volScalarField& Y(const label speciei);
119 
120  //- Access the mass-fraction field for a specie given by index
121  inline const volScalarField& Y(const label speciei) const;
122 
123  //- Access the mass-fraction field for a specie given by name
124  inline volScalarField& Y(const word& specieName);
125 
126  //- Access the mass-fraction field for a specie given by name
127  inline const volScalarField& Y(const word& specieName) const;
128 
129  //- Access the specie index of the given mass-fraction field
130  inline label specieIndex(const volScalarField& Yi) const;
131 
132  //- Normalise the mass fractions by clipping positive and deriving
133  // the default specie mass fraction from the other species.
134  virtual void normaliseY() = 0;
135 
136 
137  // Specie molecular properties
138 
139  //- Molecular weight [kg/kmol]
140  virtual scalar WiValue(const label speciei) const = 0;
141 
142  //- Molecular weight [kg/kmol]
143  virtual dimensionedScalar Wi(const label speciei) const = 0;
144 
145 
146  // Specie thermodynamic properties
147 
148  //- Density [kg/m^3]
149  virtual scalar rhoi
150  (
151  const label speciei,
152  const scalar p,
153  const scalar T
154  ) const = 0;
155 
156  //- Density [kg/m^3]
157  virtual tmp<volScalarField> rhoi
158  (
159  const label speciei,
160  const volScalarField& p,
161  const volScalarField& T
162  ) const = 0;
163 
164  //- Heat capacity at constant pressure [J/kg/K]
165  virtual scalar Cpi
166  (
167  const label speciei,
168  const scalar p,
169  const scalar T
170  ) const = 0;
171 
172  //- Heat capacity at constant pressure [J/kg/K]
173  virtual tmp<volScalarField> Cpi
174  (
175  const label speciei,
176  const volScalarField& p,
177  const volScalarField& T
178  ) const = 0;
179 
180  //- Enthalpy/Internal energy [J/kg]
181  virtual scalar hei
182  (
183  const label speciei,
184  const scalar p,
185  const scalar T
186  ) const = 0;
187 
188  //- Enthalpy/Internal energy [J/kg]
189  virtual tmp<scalarField> hei
190  (
191  const label speciei,
192  const scalarField& p,
193  const scalarField& T
194  ) const = 0;
195 
196  //- Enthalpy/Internal energy [J/kg]
198  (
199  const label speciei,
202  ) const = 0;
203 
204  //- Enthalpy/Internal energy [J/kg]
205  virtual tmp<volScalarField> hei
206  (
207  const label speciei,
208  const volScalarField& p,
209  const volScalarField& T
210  ) const = 0;
211 
212  //- Sensible enthalpy [J/kg]
213  virtual scalar hsi
214  (
215  const label speciei,
216  const scalar p,
217  const scalar T
218  ) const = 0;
219 
220  //- Sensible enthalpy [J/kg]
221  virtual tmp<scalarField> hsi
222  (
223  const label speciei,
224  const scalarField& p,
225  const scalarField& T
226  ) const = 0;
227 
228  //- Sensible enthalpy [J/kg]
230  (
231  const label speciei,
234  ) const = 0;
235 
236  //- Sensible enthalpy [J/kg]
237  virtual tmp<volScalarField> hsi
238  (
239  const label speciei,
240  const volScalarField& p,
241  const volScalarField& T
242  ) const = 0;
243 
244  //- Absolute enthalpy [J/kg]
245  virtual scalar hai
246  (
247  const label speciei,
248  const scalar p,
249  const scalar T
250  ) const = 0;
251 
252  //- Absolute enthalpy [J/kg]
253  virtual tmp<scalarField> hai
254  (
255  const label speciei,
256  const scalarField& p,
257  const scalarField& T
258  ) const = 0;
259 
260  //- Absolute enthalpy [J/kg]
262  (
263  const label speciei,
266  ) const = 0;
267 
268  //- Absolute enthalpy [J/kg]
269  virtual tmp<volScalarField> hai
270  (
271  const label speciei,
272  const volScalarField& p,
273  const volScalarField& T
274  ) const = 0;
275 
276  //- Enthalpy of formation [J/kg]
277  virtual scalar hfiValue(const label speciei) const = 0;
278 
279  //- Enthalpy of formation [J/kg]
280  virtual dimensionedScalar hfi(const label speciei) const = 0;
281 
282 
283  // Specie transport properties
284 
285  //- Thermal conductivity [W/m/K]
286  virtual scalar kappai
287  (
288  const label speciei,
289  const scalar p,
290  const scalar T
291  ) const = 0;
292 
293  //- Thermal conductivity [W/m/K]
295  (
296  const label speciei,
297  const volScalarField& p,
298  const volScalarField& T
299  ) const = 0;
300 };
301 
302 
303 /*---------------------------------------------------------------------------*\
304  Class multicomponentThermo::implementation Declaration
305 \*---------------------------------------------------------------------------*/
306 
308 :
309  virtual public multicomponentThermo
310 {
311 protected:
312 
313  // Protected data
314 
315  //- The name of the default specie. The mass fraction of which is
316  // derived from the other species rather than solved. Also used as the
317  // carrier specie in multicomponent diffusion.
319 
320  //- The index of the default specie
322 
323  //- Species mass fractions
325 
327 
328 
329  // Protected Member Functions
330 
331  //- Scale the mass fractions to sum to 1
333  (
334  const speciesTable& species
335  );
336 
337 
338 public:
339 
340  // Constructors
341 
342  //- Construct from dictionary, specie names, mesh and phase name
344  (
345  const dictionary&,
346  const speciesTable&,
347  const fvMesh&,
348  const word&,
349  const bool requiresDefaultSpecie = true
350  );
351 
352 
353  //- Destructor
354  virtual ~implementation();
355 
356 
357  // Member Functions
358 
359  //- The index of the default specie
360  virtual label defaultSpecie() const;
361 
362  //- Synchronise the specie active flags
363  virtual void syncSpeciesActive() const;
364 
365  //- Access the mass-fraction fields
366  virtual PtrList<volScalarField>& Y();
367 
368  //- Access the mass-fraction fields
369  virtual const PtrList<volScalarField>& Y() const;
370 
371  //- Normalise the mass fractions by clipping positive and deriving
372  // the default specie mass fraction from the other species.
373  virtual void normaliseY();
374 
375  //- Get the slicer
377 
378  //- Get the composition of an internal cell
379  inline scalarFieldListSlice cellComposition
380  (
382  const label celli
383  ) const;
384 
385  //- Get the composition of a boundary face
386  inline scalarFieldListSlice patchFaceComposition
387  (
389  const label patchi,
390  const label facei
391  ) const;
392 
393  //- Get the slicer for the given source
395  (
396  const fvSource& model,
397  const volScalarField::Internal& source
398  ) const;
399 
400  //- Get the composition of a source cell
401  inline scalarFieldListSlice sourceCellComposition
402  (
404  const label celli
405  ) const;
406 
407  //- Get the slicer for the given source
409  (
410  const fvSource& model,
411  const scalarField& source,
412  const labelUList& cells
413  ) const;
414 
415  //- Get the composition of a source cell
416  inline scalarFieldListSlice sourceCellComposition
417  (
419  const label i
420  ) const;
421 };
422 
423 
424 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
425 
426 } // End namespace Foam
427 
428 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
429 
430 #include "multicomponentThermoI.H"
431 
432 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
433 
434 #endif
435 
436 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Class to provide list slices to different parts of a geometric field.
Generic GeometricField class.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
Base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:78
virtual const volScalarField & T() const =0
Temperature [K].
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Base class for finite volume sources.
Definition: fvSource.H:53
A wordList with hashed indices for faster lookup by name.
scalarFieldListSlice patchFaceComposition(const GeometricFieldListSlicer< scalar > &Yslicer, const label patchi, const label facei) const
Get the composition of a boundary face.
virtual label defaultSpecie() const
The index of the default specie.
virtual void normaliseY()
Normalise the mass fractions by clipping positive and deriving.
virtual void syncSpeciesActive() const
Synchronise the specie active flags.
virtual PtrList< volScalarField > & Y()
Access the mass-fraction fields.
GeometricFieldListSlicer< scalar > Yslicer() const
Get the slicer.
word defaultSpecieName_
The name of the default specie. The mass fraction of which is.
void correctMassFractions(const speciesTable &species)
Scale the mass fractions to sum to 1.
implementation(const dictionary &, const speciesTable &, const fvMesh &, const word &, const bool requiresDefaultSpecie=true)
Construct from dictionary, specie names, mesh and phase name.
scalarFieldListSlice sourceCellComposition(const DimensionedFieldListAndSlicer< scalar, fvMesh > &Yslicer, const label celli) const
Get the composition of a source cell.
label defaultSpeciei_
The index of the default specie.
PtrList< volScalarField > Y_
Species mass fractions.
scalarFieldListSlice cellComposition(const GeometricFieldListSlicer< scalar > &Yslicer, const label celli) const
Get the composition of an internal cell.
Base-class for multi-component thermodynamic properties.
virtual scalar hei(const label speciei, const scalar p, const scalar T) const =0
Enthalpy/Internal energy [J/kg].
virtual scalar Cpi(const label speciei, const scalar p, const scalar T) const =0
Heat capacity at constant pressure [J/kg/K].
virtual scalar hfiValue(const label speciei) const =0
Enthalpy of formation [J/kg].
virtual const speciesTable & species() const =0
Return the table of species.
virtual dimensionedScalar hfi(const label speciei) const =0
Enthalpy of formation [J/kg].
TypeName("multicomponentThermo")
Runtime type information.
bool solveSpecie(const label speciei) const
Should the given specie be solved for? I.e., is it active and.
virtual scalar kappai(const label speciei, const scalar p, const scalar T) const =0
Thermal conductivity [W/m/K].
virtual const boolList & speciesActive() const =0
Access the specie active flags.
virtual scalar WiValue(const label speciei) const =0
Molecular weight [kg/kmol].
virtual PtrList< volScalarField > & Y()=0
Access the mass-fraction fields.
bool containsSpecie(const word &specieName) const
Does the mixture include this specie?
virtual scalar hsi(const label speciei, const scalar p, const scalar T) const =0
Sensible enthalpy [J/kg].
virtual dimensionedScalar Wi(const label speciei) const =0
Molecular weight [kg/kmol].
virtual label defaultSpecie() const =0
The index of the default specie.
virtual scalar hai(const label speciei, const scalar p, const scalar T) const =0
Absolute enthalpy [J/kg].
virtual void normaliseY()=0
Normalise the mass fractions by clipping positive and deriving.
void setSpecieInactive(const label speciei) const
Set specie inactive.
virtual scalar rhoi(const label speciei, const scalar p, const scalar T) const =0
Density [kg/m^3].
virtual void syncSpeciesActive() const =0
Synchronise the specie active flags.
void setSpecieActive(const label speciei) const
Set specie active.
label specieIndex(const volScalarField &Yi) const
Access the specie index of the given mass-fraction field.
virtual ~multicomponentThermo()
Destructor.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
label patchi
const cellShapeList & cells
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
volScalarField & p