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