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