FreeFOAM The Cross-Platform CFD Toolkit
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) 2008-2010 OpenCFD Ltd.
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-component 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 <OpenFOAM/NamedEnum.H>
40 #include <OpenFOAM/Tuple2.H>
41 #include <OpenFOAM/PtrList.H>
42 #include <finiteVolume/volFields.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class phaseProperties Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 {
55 public:
56 
57  // Public data
58 
59  //- Phase type enumeration
60  enum phaseType
61  {
62  GAS,
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 component names
83  List<word> names_;
84 
85  //- List of component mass fractions
86  scalarField Y_;
87 
88  //- Global ids
89  labelList globalIds_;
90 
91  //- Map to carrier global id
92  labelList globalCarrierIds_;
93 
94 
95  // Private member functions
96 
97  //- Set global ids
98  void setGlobalIds(const wordList& globalNames);
99 
100  //- Set global carrier ids - attempts to map component names to global
101  // carrier species
102  void setGlobalCarrierIds(const wordList& carrierNames);
103 
104  //- Check the total mass fraction
105  void checkTotalMassFraction() const;
106 
107  //- Set the state label
108  word phaseToStateLabel(const phaseType pt) const;
109 
110 
111 public:
112 
113  // Constructors
114 
115  //- Null constructor
116  phaseProperties();
117 
118  //- Construct from Istream
120 
121  //- Construct as copy
123 
124 
125  //- Destructor
127 
128 
129  // Public member functions
130 
131  //- Initialise the global ids
133  (
134  const wordList& gasNames,
135  const wordList& liquidNames,
136  const wordList& solidNames
137  );
138 
139 
140  // Access
141 
142  //- Return const access to the phase type
143  phaseType phase() const;
144 
145  //- Return const access to the phase state label
146  const word& stateLabel() const;
147 
148  //- Return word representation of the phase type
149  word phaseTypeName() const;
150 
151  //- Return the list of component names
152  const List<word>& names() const;
153 
154  //- Return const access to a component name
155  const word& name(const label cmptI) const;
156 
157  //- Return const access to all component mass fractions
158  const scalarField& Y() const;
159 
160  //- Return non-const access to a component mass fraction
161  scalar& Y(const label cmptI);
162 
163  //- Return const access to the global ids
164  const labelList& globalIds() const;
165 
166  //- Return const access to the map to the carrier global ids
167  const labelList& globalCarrierIds() const;
168 
169  //- Return the global id of a component in the local list by name
170  // Returns -1 if not found
171  label globalId(const word& cmptName) const;
172 
173  //- Return the id of a component in the local list by name
174  // Returns -1 if not found
175  label id(const word& cmptName) const;
176 
177 
178  // IOstream Operators
179 
181  friend Ostream& operator<<(Ostream&, const phaseProperties&);
182 };
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************ vim: set sw=4 sts=4 et: ************************ //