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-2015 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 entropy [J/(kmol K)]
143  inline scalar s(const scalar p, const scalar T) const;
144 
145  //- Return compressibility rho/p [s^2/m^2]
146  inline scalar psi(scalar p, scalar T) const;
147 
148  //- Return compression factor []
149  inline scalar Z(scalar p, scalar T) const;
150 
151  //- Return (cp - cv) [J/(kmol K]
152  inline scalar cpMcv(scalar p, scalar T) const;
153 
154 
155  // IO
156 
157  //- Write to Ostream
158  void write(Ostream& os) const;
159 
160 
161  // Member operators
162 
163  inline void operator+=(const perfectGas&);
164  inline void operator-=(const perfectGas&);
165 
166  inline void operator*=(const scalar);
167 
168 
169  // Friend operators
170 
171  friend perfectGas operator+ <Specie>
172  (
173  const perfectGas&,
174  const perfectGas&
175  );
176 
177  friend perfectGas operator- <Specie>
178  (
179  const perfectGas&,
180  const perfectGas&
181  );
182 
183  friend perfectGas operator* <Specie>
184  (
185  const scalar s,
186  const perfectGas&
187  );
188 
189  friend perfectGas operator== <Specie>
190  (
191  const perfectGas&,
192  const perfectGas&
193  );
194 
195 
196  // Ostream Operator
197 
198  friend Ostream& operator<< <Specie>
199  (
200  Ostream&,
201  const perfectGas&
202  );
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #include "perfectGasI.H"
213 
214 #ifdef NoRepository
215 # include "perfectGas.C"
216 #endif
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #endif
221 
222 // ************************************************************************* //
perfectGasI.H
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::perfectGas::isochoric
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: perfectGas.H:136
Foam::perfectGas::Z
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: perfectGasI.H:100
Foam::perfectGas::write
void write(Ostream &os) const
Write to Ostream.
Definition: perfectGas.C:50
Foam::perfectGas::perfectGas
perfectGas(const Specie &sp)
Construct from components.
Definition: perfectGasI.H:31
Foam::perfectGas::New
static autoPtr< perfectGas > New(Istream &is)
Definition: perfectGasI.H:60
Foam::perfectGas::incompressible
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: perfectGas.H:133
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::perfectGas::s
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
Definition: perfectGasI.H:86
Foam::perfectGas
Perfect gas equation of state.
Definition: perfectGas.H:47
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::perfectGas::clone
autoPtr< perfectGas > clone() const
Construct and return a clone.
Definition: perfectGasI.H:52
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::perfectGas::operator-=
void operator-=(const perfectGas &)
Definition: perfectGasI.H:123
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::perfectGas::operator+=
void operator+=(const perfectGas &)
Definition: perfectGasI.H:116
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::perfectGas::cpMcv
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
Definition: perfectGasI.H:107
Foam::perfectGas::psi
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: perfectGasI.H:93
Foam::perfectGas::rho
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: perfectGasI.H:79
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::perfectGas::typeName
static word typeName()
Return the instantiated type name.
Definition: perfectGas.H:124
perfectGas.C
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::perfectGas::operator*=
void operator*=(const scalar)
Definition: perfectGasI.H:130
autoPtr.H