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-2025 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  //- 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 List<bool>& 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 Declaration
305 \*---------------------------------------------------------------------------*/
306 
308 :
309  virtual public multicomponentThermo
310 {
311 protected:
312 
313  // Protected data
314 
315  //- Table of specie names
317 
318  //- The name of the default specie. The mass fraction of which is
319  // derived from the other species rather than solved. Also used as the
320  // carrier specie in multicomponent diffusion.
322 
323  //- The index of the default specie
325 
326  //- List of specie active flags
328 
329  //- Species mass fractions
331 
333 
334 
335  // Protected Member Functions
336 
337  //- Scale the mass fractions to sum to 1
338  void correctMassFractions();
339 
340 
341 public:
342 
343  // Constructors
344 
345  //- Construct from dictionary, specie names, mesh and phase name
347  (
348  const dictionary&,
349  const wordList&,
350  const fvMesh&,
351  const word&
352  );
353 
354 
355  //- Destructor
356  virtual ~implementation();
357 
358 
359  // Member Functions
360 
361  //- The table of species
362  virtual const speciesTable& species() const;
363 
364  //- The index of the default specie
365  virtual label defaultSpecie() const;
366 
367  //- Access the specie active flags
368  virtual const List<bool>& speciesActive() const;
369 
370  //- Synchronise the specie active flags
371  virtual void syncSpeciesActive() const;
372 
373  //- Access the mass-fraction fields
374  virtual PtrList<volScalarField>& Y();
375 
376  //- Access the mass-fraction fields
377  virtual const PtrList<volScalarField>& Y() const;
378 
379  //- Normalise the mass fractions by clipping positive and deriving
380  // the default specie mass fraction from the other species.
381  virtual void normaliseY();
382 
383  //- Get the slicer
384  inline volScalarFieldListSlicer Yslicer() const;
385 
386  //- Get the composition of an internal cell
387  inline scalarFieldListSlice cellComposition
388  (
389  const volScalarFieldListSlicer& Yslicer,
390  const label celli
391  ) const;
392 
393  //- Get the composition of a boundary face
394  inline scalarFieldListSlice patchFaceComposition
395  (
396  const volScalarFieldListSlicer& Yslicer,
397  const label patchi,
398  const label facei
399  ) const;
400 
401  //- Get the slicer for the given source
403  (
404  const fvSource& model,
405  const volScalarField::Internal& source
406  ) const;
407 
408  //- Get the composition of a source cell
409  inline scalarFieldListSlice sourceCellComposition
410  (
412  const label i
413  ) const;
414 
415  //- Get the slicer for the given source
417  (
418  const fvSource& model,
419  const scalarField& source,
420  const labelUList& cells
421  ) const;
422 
423  //- Get the composition of a source cell
424  inline scalarFieldListSlice sourceCellComposition
425  (
427  const label i
428  ) const;
429 };
430 
431 
432 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
433 
434 } // End namespace Foam
435 
436 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
437 
438 #include "multicomponentThermoI.H"
439 
440 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
441 
442 #endif
443 
444 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
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:96
Base class for finite volume sources.
Definition: fvSource.H:52
A wordList with hashed indices for faster lookup by name.
scalarFieldListSlice cellComposition(const volScalarFieldListSlicer &Yslicer, const label celli) const
Get the composition of an internal cell.
void correctMassFractions()
Scale the mass fractions to sum to 1.
List< bool > active_
List of specie active flags.
virtual const speciesTable & species() const
The table of species.
implementation(const dictionary &, const wordList &, const fvMesh &, const word &)
Construct from dictionary, specie names, mesh and phase name.
volScalarFieldListSlicer Yslicer() const
Get the slicer.
scalarFieldListSlice patchFaceComposition(const volScalarFieldListSlicer &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 const List< bool > & speciesActive() const
Access the specie active flags.
scalarFieldListSlice sourceCellComposition(const DimensionedFieldListAndSlicer< scalar, volMesh > &Yslicer, const label i) const
Get the composition of a source cell.
speciesTable species_
Table of specie names.
virtual void syncSpeciesActive() const
Synchronise the specie active flags.
virtual PtrList< volScalarField > & Y()
Access the mass-fraction fields.
word defaultSpecieName_
The name of the default specie. The mass fraction of which is.
label defaultSpeciei_
The index of the default specie.
PtrList< volScalarField > Y_
Species mass fractions.
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
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 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.
virtual const List< bool > & speciesActive() const =0
Access the specie active flags.
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
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