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 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"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class multicomponentThermo Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 :
57  virtual public basicThermo
58 {
59 public:
60 
61  // Public Classes
62 
63  //- Forward declare the implementation class
64  class implementation;
65 
66 
67  //- Destructor
68  virtual ~multicomponentThermo();
69 
70 
71  // Member Functions
72 
73  // Species set
74 
75  //- The table of species
76  virtual const speciesTable& species() const = 0;
77 
78  //- Does the mixture include this specie?
79  inline bool containsSpecie(const word& specieName) const;
80 
81  //- The index of the default specie
82  virtual label defaultSpecie() const = 0;
83 
84 
85  // Active/Inactive handling
86 
87  //- Access the specie active flags
88  virtual const List<bool>& speciesActive() const = 0;
89 
90  //- Synchronise the specie active flags
91  void syncSpeciesActive() const;
92 
93  //- Set specie active
94  inline void setSpecieActive(const label speciei) const;
95 
96  //- Set specie inactive
97  inline void setSpecieInactive(const label speciei) const;
98 
99  //- Should the given specie be solved for? I.e., is it active and
100  // not the default specie?
101  inline bool solveSpecie(const label speciei) const;
102 
103 
104  // Mass fractions
105 
106  //- Access the mass-fraction fields
107  virtual PtrList<volScalarField>& Y() = 0;
108 
109  //- Access the mass-fraction fields
110  virtual const PtrList<volScalarField>& Y() const = 0;
111 
112  //- Access the mass-fraction field for a specie given by index
113  inline volScalarField& Y(const label speciei);
114 
115  //- Access the mass-fraction field for a specie given by index
116  inline const volScalarField& Y(const label speciei) const;
117 
118  //- Access the mass-fraction field for a specie given by name
119  inline volScalarField& Y(const word& specieName);
120 
121  //- Access the mass-fraction field for a specie given by name
122  inline const volScalarField& Y(const word& specieName) const;
123 
124  //- Access the specie index of the given mass-fraction field
125  inline label specieIndex(const volScalarField& Yi) const;
126 
127  //- Normalise the mass fractions by clipping positive and deriving
128  // the default specie mass fraction from the other species.
129  void normaliseY();
130 
131 
132  // Specie molecular properties
133 
134  //- Molecular weight [kg/kmol]
135  virtual scalar WiValue(const label speciei) const = 0;
136 
137  //- Molecular weight [kg/kmol]
138  virtual dimensionedScalar Wi(const label speciei) const = 0;
139 
140 
141  // Specie thermodynamic properties
142 
143  //- Density [kg/m^3]
144  virtual scalar rhoi
145  (
146  const label speciei,
147  const scalar p,
148  const scalar T
149  ) const = 0;
150 
151  //- Density [kg/m^3]
152  virtual tmp<volScalarField> rhoi
153  (
154  const label speciei,
155  const volScalarField& p,
156  const volScalarField& T
157  ) const = 0;
158 
159  //- Heat capacity at constant pressure [J/kg/K]
160  virtual scalar Cpi
161  (
162  const label speciei,
163  const scalar p,
164  const scalar T
165  ) const = 0;
166 
167  //- Heat capacity at constant pressure [J/kg/K]
168  virtual tmp<volScalarField> Cpi
169  (
170  const label speciei,
171  const volScalarField& p,
172  const volScalarField& T
173  ) const = 0;
174 
175  //- Enthalpy/Internal energy [J/kg]
176  virtual scalar hei
177  (
178  const label speciei,
179  const scalar p,
180  const scalar T
181  ) const = 0;
182 
183  //- Enthalpy/Internal energy [J/kg]
184  virtual tmp<scalarField> hei
185  (
186  const label speciei,
187  const scalarField& p,
188  const scalarField& T
189  ) const = 0;
190 
191  //- Enthalpy/Internal energy [J/kg]
192  virtual tmp<volScalarField> hei
193  (
194  const label speciei,
195  const volScalarField& p,
196  const volScalarField& T
197  ) const = 0;
198 
199  //- Sensible enthalpy [J/kg]
200  virtual scalar hsi
201  (
202  const label speciei,
203  const scalar p,
204  const scalar T
205  ) const = 0;
206 
207  //- Sensible enthalpy [J/kg]
208  virtual tmp<scalarField> hsi
209  (
210  const label speciei,
211  const scalarField& p,
212  const scalarField& T
213  ) const = 0;
214 
215  //- Sensible enthalpy [J/kg]
216  virtual tmp<volScalarField> hsi
217  (
218  const label speciei,
219  const volScalarField& p,
220  const volScalarField& T
221  ) const = 0;
222 
223  //- Absolute enthalpy [J/kg]
224  virtual scalar hai
225  (
226  const label speciei,
227  const scalar p,
228  const scalar T
229  ) const = 0;
230 
231  //- Absolute enthalpy [J/kg]
232  virtual tmp<scalarField> hai
233  (
234  const label speciei,
235  const scalarField& p,
236  const scalarField& T
237  ) const = 0;
238 
239  //- Absolute enthalpy [J/kg]
240  virtual tmp<volScalarField> hai
241  (
242  const label speciei,
243  const volScalarField& p,
244  const volScalarField& T
245  ) const = 0;
246 
247  //- Enthalpy of formation [J/kg]
248  virtual scalar hfiValue(const label speciei) const = 0;
249 
250  //- Enthalpy of formation [J/kg]
251  virtual dimensionedScalar hfi(const label speciei) const = 0;
252 
253 
254  // Specie transport properties
255 
256  //- Thermal conductivity [W/m/K]
257  virtual scalar kappai
258  (
259  const label speciei,
260  const scalar p,
261  const scalar T
262  ) const = 0;
263 
264  //- Thermal conductivity [W/m/K]
266  (
267  const label speciei,
268  const volScalarField& p,
269  const volScalarField& T
270  ) const = 0;
271 };
272 
273 
274 /*---------------------------------------------------------------------------*\
275  Class multicomponentThermo Declaration
276 \*---------------------------------------------------------------------------*/
277 
279 :
280  virtual public multicomponentThermo
281 {
282 protected:
283 
284  // Protected data
285 
286  //- Table of specie names
288 
289  //- The name of the default specie. The mass fraction of which is
290  // derived from the other species rather than solved. Also used as the
291  // carrier specie in multicomponent diffusion.
293 
294  //- The index of the default specie
296 
297  //- List of specie active flags
299 
300  //- Species mass fractions
302 
303 
304  // Protected Member Functions
305 
306  //- Scale the mass fractions to sum to 1
307  void correctMassFractions();
308 
309 
310 public:
311 
312  // Constructors
313 
314  //- Construct from dictionary, specie names, mesh and phase name
316  (
317  const dictionary&,
318  const wordList&,
319  const fvMesh&,
320  const word&
321  );
322 
323 
324  //- Destructor
325  virtual ~implementation();
326 
327 
328  // Member Functions
329 
330  //- The table of species
331  virtual const speciesTable& species() const;
332 
333  //- The index of the default specie
334  virtual label defaultSpecie() const;
335 
336  //- Access the specie active flags
337  virtual const List<bool>& speciesActive() const;
338 
339  //- Access the mass-fraction fields
340  virtual PtrList<volScalarField>& Y();
341 
342  //- Access the mass-fraction fields
343  virtual const PtrList<volScalarField>& Y() const;
344 
345  //- Get the slicer
346  inline volScalarFieldListSlicer Yslicer() const;
347 
348  //- Get the composition of an internal cell
349  inline scalarFieldListSlice cellComposition
350  (
351  const volScalarFieldListSlicer& Yslicer,
352  const label celli
353  ) const;
354 
355  //- Get the composition of a boundary face
356  inline scalarFieldListSlice patchFaceComposition
357  (
358  const volScalarFieldListSlicer& Yslicer,
359  const label patchi,
360  const label facei
361  ) const;
362 
363  //- Get the slicer for the given source
364  inline PtrList<scalarField> Yslicer(const fvSource& source) const;
365 
366  //- Get the composition of a source cell
367  inline scalarFieldListSlice sourceCellComposition
368  (
370  const label i
371  ) const;
372 };
373 
374 
375 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376 
377 } // End namespace Foam
378 
379 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380 
381 #include "multicomponentThermoI.H"
382 
383 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
384 
385 #endif
386 
387 // ************************************************************************* //
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
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 const List< bool > & speciesActive() const
Access the specie active flags.
speciesTable species_
Table of specie names.
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.
scalarFieldListSlice sourceCellComposition(const PtrList< scalarField > &Yslicer, const label i) const
Get the composition of a source cell.
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].
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].
void normaliseY()
Normalise the mass fractions by clipping positive and deriving.
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?
void syncSpeciesActive() const
Synchronise the specie active flags.
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].
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].
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
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