phaseProperties.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 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  //- Construct as copy
127 
128 
129  //- Destructor
131 
132 
133  // Public Member Functions
134 
135  //- Reorder species to be consistent with the corresponding
136  // phase specie name list
137  void reorder
138  (
139  const wordList& gasNames,
140  const wordList& liquidNames,
141  const wordList& solidNames
142  );
143 
144 
145  // Access
146 
147  //- Return const access to the phase type
148  phaseType phase() const;
149 
150  //- Return const access to the phase state label
151  const word& stateLabel() const;
152 
153  //- Return word representation of the phase type
154  word phaseTypeName() const;
155 
156  //- Return the list of specie names
157  const List<word>& names() const;
158 
159  //- Return const access to a specie name
160  const word& name(const label speciei) const;
161 
162  //- Return const access to all specie mass fractions
163  const scalarField& Y() const;
164 
165  //- Return non-const access to a specie mass fraction
166  scalar& Y(const label speciei);
167 
168  //- Return const access to the map to the carrier ids
169  const labelList& carrierIds() const;
170 
171  //- Return the id of a specie in the local list by name
172  // Returns -1 if not found
173  label id(const word& specieName) const;
174 
175 
176  // IOstream Operators
177 
179  friend Ostream& operator<<(Ostream&, const phaseProperties&);
180 };
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #endif
190 
191 // ************************************************************************* //
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
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
~phaseProperties()
Destructor.
friend Ostream & operator<<(Ostream &, const phaseProperties &)
word phaseTypeName() const
Return word representation of the phase type.
static const NamedEnum< phaseType, 4 > phaseTypeNames
Corresponding word representations for phase type enumerations.
const labelList & carrierIds() const
Return const access to the map to the carrier ids.
label id(const word &specieName) const
Return the id of a specie in the local list by name.
const word & stateLabel() const
Return const access to the phase state label.
A class for handling words, derived from string.
Definition: word.H:59
phaseType
Phase type enumeration.
Istream & operator>>(Istream &, directionInfo &)
const scalarField & Y() const
Return const access to all specie mass fractions.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const word & name(const label speciei) const
Return const access to a specie name.
Ostream & operator<<(Ostream &, const ensightPart &)
phaseProperties()
Null constructor.
const List< word > & names() const
Return the list of specie names.
friend Istream & operator>>(Istream &, phaseProperties &)
Namespace for OpenFOAM.
phaseType phase() const
Return const access to the phase type.