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-2015 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 /*---------------------------------------------------------------------------*\
50  Class phaseProperties Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class phaseProperties
54 {
55 public:
56 
57  // Public data
58 
59  //- Phase type enumeration
60  enum phaseType
61  {
62  GAS,
65  UNKNOWN
66  };
67 
68  //- Corresponding word representations for phase type enumerations
70 
71 
72 private:
73 
74  // Private data
75 
76  //- Phase type
77  phaseType phase_;
78 
79  //- State label (s), (l), (g) etc.
80  word stateLabel_;
81 
82  //- List of specie names
83  List<word> names_;
84 
85  //- List of specie mass fractions
86  scalarField Y_;
87 
88  //- Map to carrier id
89  labelList carrierIds_;
90 
91 
92  // Private Member Functions
93 
94  //- Reorder species to be consistent with the given specie name list
95  void reorder(const wordList& specieNames);
96 
97  //- Set carrier ids
98  void setCarrierIds(const wordList& carrierNames);
99 
100  //- Check the total mass fraction
101  void checkTotalMassFraction() const;
102 
103  //- Set the state label
104  word phaseToStateLabel(const phaseType pt) const;
105 
106 
107 public:
108 
109  // Constructors
110 
111  //- Null constructor
112  phaseProperties();
113 
114  //- Construct from Istream
116 
117  //- Construct as copy
119 
120 
121  //- Destructor
123 
124 
125  // Public Member Functions
126 
127  //- Reorder species to be consistent with the corresponding
128  // phase specie name list
129  void reorder
130  (
131  const wordList& gasNames,
132  const wordList& liquidNames,
133  const wordList& solidNames
134  );
135 
136 
137  // Access
138 
139  //- Return const access to the phase type
140  phaseType phase() const;
141 
142  //- Return const access to the phase state label
143  const word& stateLabel() const;
144 
145  //- Return word representation of the phase type
146  word phaseTypeName() const;
147 
148  //- Return the list of specie names
149  const List<word>& names() const;
150 
151  //- Return const access to a specie name
152  const word& name(const label speciei) const;
153 
154  //- Return const access to all specie mass fractions
155  const scalarField& Y() const;
156 
157  //- Return non-const access to a specie mass fraction
158  scalar& Y(const label speciei);
159 
160  //- Return const access to the map to the carrier ids
161  const labelList& carrierIds() const;
162 
163  //- Return the id of a specie in the local list by name
164  // Returns -1 if not found
165  label id(const word& specieName) const;
166 
167 
168  // IOstream Operators
169 
171  friend Ostream& operator<<(Ostream&, const phaseProperties&);
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace Foam
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
const word & name(const label speciei) const
Return const access to a specie name.
friend Ostream & operator<<(Ostream &, const phaseProperties &)
phaseProperties()
Null constructor.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A class for handling words, derived from string.
Definition: word.H:59
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
~phaseProperties()
Destructor.
Namespace for OpenFOAM.
phaseType phase() const
Return const access to the phase type.
const word & stateLabel() const
Return const access to the phase state label.
const scalarField & Y() const
Return const access to all specie mass fractions.
Helper class to manage multi-specie phase properties.
const List< word > & names() const
Return the list of specie names.
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.
friend Istream & operator>>(Istream &, phaseProperties &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const NamedEnum< phaseType, 4 > phaseTypeNames
Corresponding word representations for phase type enumerations.
word phaseTypeName() const
Return word representation of the phase type.
phaseType
Phase type enumeration.