phaseProperties.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-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::phaseProperties
26 
27 Description
28  Helper class to manage multi-specie phase properties
29 
30 SourceFiles
31  phaseProperties.C
32  phasePropertiesIO.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef phaseProperties_H
37 #define phaseProperties_H
38 
39 #include "NamedEnum.H"
40 #include "Tuple2.H"
41 #include "PtrList.H"
42 #include "volFields.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of friend functions and operators
50 
51 class phaseProperties;
52 
53 Istream& operator>>(Istream&, phaseProperties&);
54 Ostream& operator<<(Ostream&, const phaseProperties&);
55 
56 
57 /*---------------------------------------------------------------------------*\
58  Class phaseProperties Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class phaseProperties
62 {
63 public:
64 
65  // Public data
66 
67  //- Phase type enumeration
68  enum phaseType
69  {
70  GAS,
73  UNKNOWN
74  };
75 
76  //- Corresponding word representations for phase type enumerations
78 
79 
80 private:
81 
82  // Private Data
83 
84  //- Phase type
85  phaseType phase_;
86 
87  //- State label (s), (l), (g) etc.
88  word stateLabel_;
89 
90  //- List of specie names
91  List<word> names_;
92 
93  //- List of specie mass fractions
94  scalarField Y_;
95 
96  //- Map to carrier id
97  labelList carrierIds_;
98 
99 
100  // Private Member Functions
101 
102  //- Reorder species to be consistent with the given specie name list
103  void reorder(const wordList& specieNames);
104 
105  //- Set carrier ids
106  void setCarrierIds(const wordList& carrierNames);
107 
108  //- Check the total mass fraction
109  void checkTotalMassFraction() const;
110 
111  //- Set the state label
112  word phaseToStateLabel(const phaseType pt) const;
113 
114 
115 public:
116 
117  // Constructors
118 
119  //- Null constructor
120  phaseProperties();
121 
122  //- Construct from Istream
124 
125 
126  //- Destructor
128 
129 
130  // Public Member Functions
131 
132  //- Reorder species to be consistent with the corresponding
133  // phase specie name list
134  void reorder
135  (
136  const wordList& gasNames,
137  const wordList& liquidNames,
138  const wordList& solidNames
139  );
140 
141 
142  // Access
143 
144  //- Return const access to the phase type
145  phaseType phase() const;
146 
147  //- Return const access to the phase state label
148  const word& stateLabel() const;
149 
150  //- Return word representation of the phase type
151  word phaseTypeName() const;
152 
153  //- Return the list of specie names
154  const List<word>& names() const;
155 
156  //- Return const access to a specie name
157  const word& name(const label speciei) const;
158 
159  //- Return const access to all specie mass fractions
160  const scalarField& Y() const;
161 
162  //- Return non-const access to a specie mass fraction
163  scalar& Y(const label speciei);
164 
165  //- Return the carrier id for a given specie
166  label carrierId(const label speciei) const;
167 
168  //- Return the id of a specie in the local list by name
169  // Returns -1 if not found
170  label id(const word& specieName) const;
171 
172 
173  // IOstream Operators
174 
176  friend Ostream& operator<<(Ostream&, const phaseProperties&);
177 };
178 
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace Foam
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 #endif
187 
188 // ************************************************************************* //
const word & stateLabel() const
Return const access to the phase state label.
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
label id(const word &specieName) const
Return the id of a specie in the local list by name.
Helper class to manage multi-specie phase properties.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const scalarField & Y() const
Return const access to all specie mass fractions.
const wordList solidNames(rp.found("solid") ? rp["solid"] :wordList(0))
~phaseProperties()
Destructor.
friend Ostream & operator<<(Ostream &, const phaseProperties &)
static const NamedEnum< phaseType, 4 > phaseTypeNames
Corresponding word representations for phase type enumerations.
A class for handling words, derived from string.
Definition: word.H:59
label carrierId(const label speciei) const
Return the carrier id for a given specie.
phaseType
Phase type enumeration.
Istream & operator>>(Istream &, directionInfo &)
const List< word > & names() const
Return the list of specie names.
phaseType phase() const
Return const access to the phase type.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
const word & name(const label speciei) const
Return const access to a specie name.
Ostream & operator<<(Ostream &, const ensightPart &)
phaseProperties()
Null constructor.
friend Istream & operator>>(Istream &, phaseProperties &)
word phaseTypeName() const
Return word representation of the phase type.
Namespace for OpenFOAM.