perfectGas.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-2016 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::perfectGas
26 
27 Description
28  Perfect gas equation of state.
29 
30 SourceFiles
31  perfectGasI.H
32  perfectGas.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef perfectGas_H
37 #define perfectGas_H
38 
39 #include "autoPtr.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of friend functions and operators
47 
48 template<class Specie> class perfectGas;
49 
50 template<class Specie>
51 inline perfectGas<Specie> operator+
52 (
53  const perfectGas<Specie>&,
54  const perfectGas<Specie>&
55 );
56 
57 template<class Specie>
58 inline perfectGas<Specie> operator-
59 (
60  const perfectGas<Specie>&,
61  const perfectGas<Specie>&
62 );
63 
64 template<class Specie>
65 inline perfectGas<Specie> operator*
66 (
67  const scalar,
68  const perfectGas<Specie>&
69 );
70 
71 template<class Specie>
72 inline perfectGas<Specie> operator==
73 (
74  const perfectGas<Specie>&,
75  const perfectGas<Specie>&
76 );
77 
78 template<class Specie>
79 Ostream& operator<<
80 (
81  Ostream&,
82  const perfectGas<Specie>&
83 );
84 
85 
86 /*---------------------------------------------------------------------------*\
87  Class perfectGas Declaration
88 \*---------------------------------------------------------------------------*/
89 
90 template<class Specie>
91 class perfectGas
92 :
93  public Specie
94 {
95 
96 public:
97 
98  // Constructors
99 
100  //- Construct from components
101  inline perfectGas(const Specie& sp);
102 
103  //- Construct from Istream
105 
106  //- Construct from dictionary
107  perfectGas(const dictionary& dict);
108 
109  //- Construct as named copy
110  inline perfectGas(const word& name, const perfectGas&);
111 
112  //- Construct and return a clone
113  inline autoPtr<perfectGas> clone() const;
114 
115  // Selector from Istream
116  inline static autoPtr<perfectGas> New(Istream& is);
117 
118  // Selector from dictionary
119  inline static autoPtr<perfectGas> New(const dictionary& dict);
120 
121 
122  // Member functions
123 
124  //- Return the instantiated type name
125  static word typeName()
126  {
127  return "perfectGas<" + word(Specie::typeName_()) + '>';
128  }
129 
130 
131  // Fundamental properties
132 
133  //- Is the equation of state is incompressible i.e. rho != f(p)
134  static const bool incompressible = false;
135 
136  //- Is the equation of state is isochoric i.e. rho = const
137  static const bool isochoric = false;
138 
139  //- Return density [kg/m^3]
140  inline scalar rho(scalar p, scalar T) const;
141 
142  //- Return enthalpy departure [J/kmol]
143  inline scalar h(const scalar p, const scalar T) const;
144 
145  //- Return cp departure [J/(kmol K]
146  inline scalar cp(scalar p, scalar T) const;
147 
148  //- Return entropy [J/(kmol K)]
149  inline scalar s(const scalar p, const scalar T) const;
150 
151  //- Return compressibility rho/p [s^2/m^2]
152  inline scalar psi(scalar p, scalar T) const;
153 
154  //- Return compression factor []
155  inline scalar Z(scalar p, scalar T) const;
156 
157  //- Return (cp - cv) [J/(kmol K]
158  inline scalar cpMcv(scalar p, scalar T) const;
159 
160 
161  // IO
162 
163  //- Write to Ostream
164  void write(Ostream& os) const;
165 
166 
167  // Member operators
168 
169  inline void operator+=(const perfectGas&);
170  inline void operator-=(const perfectGas&);
171 
172  inline void operator*=(const scalar);
173 
174 
175  // Friend operators
176 
177  friend perfectGas operator+ <Specie>
178  (
179  const perfectGas&,
180  const perfectGas&
181  );
182 
183  friend perfectGas operator- <Specie>
184  (
185  const perfectGas&,
186  const perfectGas&
187  );
188 
189  friend perfectGas operator* <Specie>
190  (
191  const scalar s,
192  const perfectGas&
193  );
194 
195  friend perfectGas operator== <Specie>
196  (
197  const perfectGas&,
198  const perfectGas&
199  );
200 
201 
202  // Ostream Operator
203 
204  friend Ostream& operator<< <Specie>
205  (
206  Ostream&,
207  const perfectGas&
208  );
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #include "perfectGasI.H"
219 
220 #ifdef NoRepository
221  #include "perfectGas.C"
222 #endif
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
void operator*=(const scalar)
Definition: perfectGasI.H:144
static autoPtr< perfectGas > New(Istream &is)
Definition: perfectGasI.H:60
static word typeName()
Return the instantiated type name.
Definition: perfectGas.H:124
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void write(Ostream &os) const
Write to Ostream.
Definition: perfectGas.C:50
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: perfectGasI.H:79
void operator+=(const perfectGas &)
Definition: perfectGasI.H:130
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: perfectGas.H:133
A class for handling words, derived from string.
Definition: word.H:59
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
Definition: perfectGasI.H:100
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
void operator-=(const perfectGas &)
Definition: perfectGasI.H:137
Perfect gas equation of state.
Definition: perfectGas.H:47
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
autoPtr< perfectGas > clone() const
Construct and return a clone.
Definition: perfectGasI.H:52
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
scalar h(const scalar p, const scalar T) const
Return enthalpy departure [J/kmol].
Definition: perfectGasI.H:86
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: perfectGasI.H:107
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
Definition: perfectGasI.H:121
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: perfectGas.H:136
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: perfectGasI.H:114
perfectGas(const Specie &sp)
Construct from components.
Definition: perfectGasI.H:31
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
volScalarField & p
scalar cp(scalar p, scalar T) const
Return cp departure [J/(kmol K].
Definition: perfectGasI.H:93
Namespace for OpenFOAM.