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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::phaseProperties
28 
29 Description
30  Helper class to manage multi-specie phase properties
31 
32 SourceFiles
33  phaseProperties.C
34  phasePropertiesIO.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef phaseProperties_H
39 #define phaseProperties_H
40 
41 #include "Enum.H"
42 #include "Tuple2.H"
43 #include "PtrList.H"
44 #include "volFields.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of friend functions and operators
52 
53 class phaseProperties;
54 
55 Istream& operator>>(Istream&, phaseProperties&);
56 Ostream& operator<<(Ostream&, const phaseProperties&);
57 
58 
59 /*---------------------------------------------------------------------------*\
60  Class phaseProperties Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class phaseProperties
64 {
65 public:
66 
67  // Public data
68 
69  //- Phase type enumeration
70  enum phaseType
71  {
72  GAS,
75  UNKNOWN
76  };
77 
78  //- Corresponding word representations for phase type enumerations
79  static const Enum<phaseType> phaseTypeNames;
80 
81 
82 private:
83 
84  // Private data
85 
86  //- Phase type
87  phaseType phase_;
88 
89  //- State label (s), (l), (g) etc.
90  word stateLabel_;
91 
92  //- List of specie names
93  List<word> names_;
94 
95  //- List of specie mass fractions
96  scalarField Y_;
97 
98  //- Map to carrier id
99  labelList carrierIds_;
100 
101 
102  // Private Member Functions
103 
104  //- Reorder species to be consistent with the given specie name list
105  void reorder(const wordList& specieNames);
106 
107  //- Set carrier ids
108  void setCarrierIds(const wordList& carrierNames);
109 
110  //- Check the total mass fraction
111  void checkTotalMassFraction() const;
112 
113  //- Set the state label
114  word phaseToStateLabel(const phaseType pt) const;
115 
116 
117 public:
118 
119  // Constructors
120 
121  //- Null constructor
122  phaseProperties();
123 
124  //- Construct from Istream
126 
127  //- Construct as copy
128  phaseProperties(const phaseProperties& pp);
129 
130 
131  //- Destructor
132  ~phaseProperties() = default;
133 
134 
135  // Public Member Functions
136 
137  //- Reorder species to be consistent with the corresponding
138  // phase specie name list
139  void reorder
140  (
141  const wordList& gasNames,
142  const wordList& liquidNames,
143  const wordList& solidNames
144  );
145 
146 
147  // Access
148 
149  //- Return const access to the phase type
150  phaseType phase() const;
151 
152  //- Return const access to the phase state label
153  const word& stateLabel() const;
154 
155  //- Return word representation of the phase type
156  word phaseTypeName() const;
157 
158  //- Return the list of specie names
159  const List<word>& names() const;
160 
161  //- Return const access to a specie name
162  const word& name(const label speciei) const;
163 
164  //- Return const access to all specie mass fractions
165  const scalarField& Y() const;
166 
167  //- Return non-const access to a specie mass fraction
168  scalar& Y(const label speciei);
169 
170  //- Return const access to the map to the carrier ids
171  const labelList& carrierIds() const;
172 
173  //- Return the id of a specie in the local list by name
174  // Returns -1 if not found
175  label id(const word& specieName) 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 // ************************************************************************* //
volFields.H
Foam::Enum< phaseType >
Foam::phaseProperties::operator>>
friend Istream & operator>>(Istream &, phaseProperties &)
Foam::phaseProperties::phaseTypeNames
static const Enum< phaseType > phaseTypeNames
Corresponding word representations for phase type enumerations.
Definition: phaseProperties.H:78
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::phaseProperties::LIQUID
Definition: phaseProperties.H:72
Foam::phaseProperties::phaseTypeName
word phaseTypeName() const
Return word representation of the phase type.
Definition: phaseProperties.C:263
Tuple2.H
Foam::phaseProperties::GAS
Definition: phaseProperties.H:71
Foam::phaseProperties
Helper class to manage multi-specie phase properties.
Definition: phaseProperties.H:62
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:228
Foam::phaseProperties::id
label id(const word &specieName) const
Return the id of a specie in the local list by name.
Definition: phaseProperties.C:315
Foam::phaseProperties::~phaseProperties
~phaseProperties()=default
Destructor.
Foam::phaseProperties::carrierIds
const labelList & carrierIds() const
Return const access to the map to the carrier ids.
Definition: phaseProperties.C:309
Foam::phaseProperties::names
const List< word > & names() const
Return the list of specie names.
Definition: phaseProperties.C:269
Foam::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:62
Foam::Field< scalar >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::phaseProperties::operator<<
friend Ostream & operator<<(Ostream &, const phaseProperties &)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::phaseProperties::phaseProperties
phaseProperties()
Null constructor.
Definition: phaseProperties.C:181
Foam::phaseProperties::phaseType
phaseType
Phase type enumeration.
Definition: phaseProperties.H:69
Foam::List< word >
Foam::phaseProperties::UNKNOWN
Definition: phaseProperties.H:74
PtrList.H
Foam::phaseProperties::stateLabel
const word & stateLabel() const
Return const access to the phase state label.
Definition: phaseProperties.C:257
Foam::phaseProperties::phase
phaseType phase() const
Return const access to the phase type.
Definition: phaseProperties.C:251
Foam::phaseProperties::SOLID
Definition: phaseProperties.H:73
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
solidNames
const wordList solidNames(rp["solid"])
Foam::phaseProperties::name
const word & name(const label speciei) const
Return const access to a specie name.
Definition: phaseProperties.C:275
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102
Foam::phaseProperties::Y
const scalarField & Y() const
Return const access to all specie mass fractions.
Definition: phaseProperties.C:289
Enum.H