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,
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 // ************************************************************************* //
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:76
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::phaseProperties::LIQUID
Definition: phaseProperties.H:70
Foam::phaseProperties::phaseTypeName
word phaseTypeName() const
Return word representation of the phase type.
Definition: phaseProperties.C:254
Tuple2.H
Foam::phaseProperties::GAS
Definition: phaseProperties.H:69
Foam::phaseProperties
Helper class to manage multi-specie phase properties.
Definition: phaseProperties.H:60
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::phaseProperties::id
label id(const word &specieName) const
Return the id of a specie in the local list by name.
Definition: phaseProperties.C:306
Foam::phaseProperties::carrierIds
const labelList & carrierIds() const
Return const access to the map to the carrier ids.
Definition: phaseProperties.C:300
Foam::phaseProperties::names
const List< word > & names() const
Return the list of specie names.
Definition: phaseProperties.C:260
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
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()
Default construct, as 'UNKNOWN' state.
Definition: phaseProperties.C:182
Foam::phaseProperties::phaseType
phaseType
Phase type enumeration.
Definition: phaseProperties.H:67
Foam::List< word >
Foam::phaseProperties::UNKNOWN
Definition: phaseProperties.H:72
PtrList.H
Foam::phaseProperties::stateLabel
const word & stateLabel() const
Return const access to the phase state label.
Definition: phaseProperties.C:248
Foam::phaseProperties::phase
phaseType phase() const
Return const access to the phase type.
Definition: phaseProperties.C:242
Foam::phaseProperties::SOLID
Definition: phaseProperties.H:71
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:266
Foam::phaseProperties::Y
const scalarField & Y() const
Return const access to all specie mass fractions.
Definition: phaseProperties.C:280
Enum.H