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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::phaseProperties
29 
30 Description
31  Helper class to manage multi-specie phase properties
32 
33 SourceFiles
34  phaseProperties.C
35  phasePropertiesIO.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef phaseProperties_H
40 #define phaseProperties_H
41 
42 #include "Enum.H"
43 #include "Tuple2.H"
44 #include "PtrList.H"
45 #include "volFields.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 class phaseProperties;
54 Istream& operator>>(Istream&, phaseProperties&);
55 Ostream& operator<<(Ostream&, const phaseProperties&);
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,
71  LIQUID,
72  SOLID,
73  UNKNOWN
74  };
75 
76  //- Corresponding word representations for phase type enumerations
77  static const Enum<phaseType> phaseTypeNames;
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  //- Default construct, as 'UNKNOWN' state
120  phaseProperties();
121 
122  //- Construct from Istream
123  explicit phaseProperties(Istream& is);
124 
125 
126  // Member Functions
127 
128  //- Reorder species to be consistent with the corresponding
129  // phase specie name list
130  void reorder
131  (
132  const wordList& gasNames,
133  const wordList& liquidNames,
134  const wordList& solidNames
135  );
136 
137 
138  // Access
139 
140  //- Return const access to the phase type
141  phaseType phase() const;
142 
143  //- Return const access to the phase state label
144  const word& stateLabel() const;
145 
146  //- Return word representation of the phase type
147  word phaseTypeName() const;
148 
149  //- Return the list of specie names
150  const List<word>& names() const;
151 
152  //- Return const access to a specie name
153  const word& name(const label speciei) const;
154 
155  //- Return const access to all specie mass fractions
156  const scalarField& Y() const;
157 
158  //- Return non-const access to a specie mass fraction
159  scalar& Y(const label speciei);
160 
161  //- Return const access to the map to the carrier ids
162  const labelList& carrierIds() const;
163 
164  //- Return the id of a specie in the local list by name
165  // Returns -1 if not found
166  label id(const word& specieName) const;
167 
168 
169  // IOstream Operators
170 
172  friend Ostream& operator<<(Ostream&, const phaseProperties&);
173 };
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #endif
183 
184 // ************************************************************************* //
const word & stateLabel() const
Return const access to the phase state label.
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["solid"])
static const Enum< phaseType > phaseTypeNames
Corresponding word representations for phase type enumerations.
friend Ostream & operator<<(Ostream &, const phaseProperties &)
A class for handling words, derived from Foam::string.
Definition: word.H:63
phaseType
Phase type enumeration.
Istream & operator>>(Istream &, directionInfo &)
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.
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:56
const word & name(const label speciei) const
Return const access to a specie name.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
phaseProperties()
Default construct, as &#39;UNKNOWN&#39; state.
friend Istream & operator>>(Istream &, phaseProperties &)
word phaseTypeName() const
Return word representation of the phase type.
Namespace for OpenFOAM.