basicSpecieMixture.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) 2014-2021 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::basicSpecieMixture
26 
27 Description
28  Specialisation of basicMixture for a mixture consisting of a number for
29  molecular species.
30 
31 SourceFiles
32  basicSpecieMixture.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef basicSpecieMixture_H
37 #define basicSpecieMixture_H
38 
39 #include "volFields.H"
40 #include "PtrList.H"
41 #include "basicMixture.H"
42 #include "speciesTable.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class basicSpecieMixture Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 :
55  public basicMixture
56 {
57 
58 protected:
59 
60  // Protected data
61 
62  //- Phase-name
63  const word& phaseName_;
64 
65  //- Table of specie names
67 
68  //- The name of the default specie
69  // The mass fraction of which is derived from the other species
70  // rather than solved.
71  // Also used as the carrier specie in multicomponent diffusion
73 
74  //- The index of the default specie
76 
77  //- List of specie active flags
78  mutable List<bool> active_;
79 
80  //- Species mass fractions
82 
83 
84  // Protected Member Functions
85 
86  //- Scale the mass fractions to sum to 1
87  void correctMassFractions();
88 
89 
90 public:
91 
92  //- Run time type information
93  TypeName("basicSpecieMixture");
94 
95  //- The base class of the mixture
97 
98 
99  // Constructors
100 
101  //- Construct from dictionary, species names, mesh and phase name
103  (
104  const dictionary&,
105  const wordList& specieNames,
106  const fvMesh&,
107  const word&
108  );
109 
110 
111  //- Destructor
112  virtual ~basicSpecieMixture()
113  {}
114 
115 
116  // Member Functions
117 
118  //- Return the table of species
119  inline const speciesTable& species() const;
120 
121  //- Does the mixture include this specie?
122  inline bool contains(const word& specieName) const;
123 
124  //- Return the index of the default specie
125  inline label defaultSpecie() const;
126 
127  //- Return true for active species
128  inline bool active(label speciei) const;
129 
130  //- Return the bool list of active species
131  inline const List<bool>& active() const;
132 
133  //- Set speciei active
134  inline void setActive(label speciei) const;
135 
136  //- Set speciei inactive
137  inline void setInactive(label speciei) const;
138 
139  //- Return true if the specie should be solved for
140  // i.e. active and not the default specie
141  inline bool solve(label speciei) const;
142 
143  //- Return the mass-fraction fields
144  inline PtrList<volScalarField>& Y();
145 
146  //- Return the const mass-fraction fields
147  inline const PtrList<volScalarField>& Y() const;
148 
149  //- Return the mass-fraction field for a specie given by index
150  inline volScalarField& Y(const label i);
151 
152  //- Return the const mass-fraction field for a specie given by index
153  inline const volScalarField& Y(const label i) const;
154 
155  //- Return the mass-fraction field for a specie given by name
156  inline volScalarField& Y(const word& specieName);
157 
158  //- Return the const mass-fraction field for a specie given by name
159  inline const volScalarField& Y(const word& specieName) const;
160 
161  //- Return the specie index of the given mass-fraction field
162  inline label index(const volScalarField& Yi) const;
163 
164  //- Normalise the mass fractions
165  // by clipping positive
166  // and deriving the default specie mass fraction from the other species
167  void normalise();
168 
169 
170  // Specie properties
171 
172  //- Molecular weight of the given specie [kg/kmol]
173  virtual scalar Wi(const label speciei) const = 0;
174 
175  //- Enthalpy of formation [J/kg]
176  virtual scalar Hf(const label speciei) const = 0;
177 
178 
179  // Specie thermo properties
180 
181  //- Density [kg/m^3]
182  virtual scalar rho
183  (
184  const label speciei,
185  const scalar p,
186  const scalar T
187  ) const = 0;
188 
189  //- Density [kg/m^3]
190  virtual tmp<volScalarField> rho
191  (
192  const label speciei,
193  const volScalarField& p,
194  const volScalarField& T
195  ) const = 0;
196 
197  //- Heat capacity at constant pressure [J/kg/K]
198  virtual scalar Cp
199  (
200  const label speciei,
201  const scalar p,
202  const scalar T
203  ) const = 0;
204 
205  //- Heat capacity at constant pressure [J/kg/K]
206  virtual tmp<volScalarField> Cp
207  (
208  const label speciei,
209  const volScalarField& p,
210  const volScalarField& T
211  ) const = 0;
212 
213  //- Enthalpy/Internal energy [J/kg]
214  virtual scalar HE
215  (
216  const label speciei,
217  const scalar p,
218  const scalar T
219  ) const = 0;
220 
221  //- Enthalpy/Internal energy [J/kg]
222  virtual tmp<scalarField> HE
223  (
224  const label speciei,
225  const scalarField& p,
226  const scalarField& T
227  ) const = 0;
228 
229  //- Enthalpy/Internal energy [J/kg]
230  virtual tmp<volScalarField> HE
231  (
232  const label speciei,
233  const volScalarField& p,
234  const volScalarField& T
235  ) const = 0;
236 
237  //- Sensible enthalpy [J/kg]
238  virtual scalar Hs
239  (
240  const label speciei,
241  const scalar p,
242  const scalar T
243  ) const = 0;
244 
245  //- Sensible enthalpy [J/kg]
246  virtual tmp<scalarField> Hs
247  (
248  const label speciei,
249  const scalarField& p,
250  const scalarField& T
251  ) const = 0;
252 
253  //- Sensible enthalpy [J/kg]
254  virtual tmp<volScalarField> Hs
255  (
256  const label speciei,
257  const volScalarField& p,
258  const volScalarField& T
259  ) const = 0;
260 
261  //- Absolute enthalpy [J/kg]
262  virtual scalar Ha
263  (
264  const label speciei,
265  const scalar p,
266  const scalar T
267  ) const = 0;
268 
269  //- Enthalpy/Internal energy [J/kg]
270  virtual tmp<scalarField> Ha
271  (
272  const label speciei,
273  const scalarField& p,
274  const scalarField& T
275  ) const = 0;
276 
277  //- Absolute enthalpy [J/kg]
278  virtual tmp<volScalarField> Ha
279  (
280  const label speciei,
281  const volScalarField& p,
282  const volScalarField& T
283  ) const = 0;
284 
285 
286  // Specie transport properties
287 
288  //- Dynamic viscosity [kg/m/s]
289  virtual scalar mu
290  (
291  const label speciei,
292  const scalar p,
293  const scalar T
294  ) const = 0;
295 
296  //- Dynamic viscosity [kg/m/s]
297  virtual tmp<volScalarField> mu
298  (
299  const label speciei,
300  const volScalarField& p,
301  const volScalarField& T
302  ) const = 0;
303 
304  //- Thermal conductivity [W/m/K]
305  virtual scalar kappa
306  (
307  const label speciei,
308  const scalar p,
309  const scalar T
310  ) const = 0;
311 
312  //- Thermal conductivity [W/m/K]
313  virtual tmp<volScalarField> kappa
314  (
315  const label speciei,
316  const volScalarField& p,
317  const volScalarField& T
318  ) const = 0;
319 };
320 
321 
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 
324 } // End namespace Foam
325 
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
327 
328 #include "basicSpecieMixtureI.H"
329 
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
331 
332 #endif
333 
334 // ************************************************************************* //
void setInactive(label speciei) const
Set speciei inactive.
bool solve(label speciei) const
Return true if the specie should be solved for.
PtrList< volScalarField > Y_
Species mass fractions.
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual scalar kappa(const label speciei, const scalar p, const scalar T) const =0
Thermal conductivity [W/m/K].
label index(const volScalarField &Yi) const
Return the specie index of the given mass-fraction field.
virtual scalar Ha(const label speciei, const scalar p, const scalar T) const =0
Absolute enthalpy [J/kg].
virtual scalar Wi(const label speciei) const =0
Molecular weight of the given specie [kg/kmol].
virtual scalar rho(const label speciei, const scalar p, const scalar T) const =0
Density [kg/m^3].
Specialisation of basicMixture for a mixture consisting of a number for molecular species...
speciesTable species_
Table of specie names.
List< bool > active_
List of specie active flags.
void normalise()
Normalise the mass fractions.
virtual scalar Cp(const label speciei, const scalar p, const scalar T) const =0
Heat capacity at constant pressure [J/kg/K].
virtual scalar mu(const label speciei, const scalar p, const scalar T) const =0
Dynamic viscosity [kg/m/s].
A class for handling words, derived from string.
Definition: word.H:59
virtual scalar HE(const label speciei, const scalar p, const scalar T) const =0
Enthalpy/Internal energy [J/kg].
bool contains(const word &specieName) const
Does the mixture include this specie?
virtual ~basicSpecieMixture()
Destructor.
Foam::basicMixture.
Definition: basicMixture.H:50
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
A wordList with hashed indices for faster lookup by name.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
TypeName("basicSpecieMixture")
Run time type information.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual scalar Hs(const label speciei, const scalar p, const scalar T) const =0
Sensible enthalpy [J/kg].
void setActive(label speciei) const
Set speciei active.
basicSpecieMixture basicMixtureType
The base class of the mixture.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
PtrList< volScalarField > & Y()
Return the mass-fraction fields.
label defaultSpecieIndex_
The index of the default specie.
virtual scalar Hf(const label speciei) const =0
Enthalpy of formation [J/kg].
void correctMassFractions()
Scale the mass fractions to sum to 1.
const List< bool > & active() const
Return the bool list of active species.
basicSpecieMixture(const dictionary &, const wordList &specieNames, const fvMesh &, const word &)
Construct from dictionary, species names, mesh and phase name.
const word & phaseName_
Phase-name.
Namespace for OpenFOAM.
const speciesTable & species() const
Return the table of species.
word defaultSpecie_
The name of the default specie.
label defaultSpecie() const
Return the index of the default specie.