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