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-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::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 entropy [J/(kmol K)]
160  inline scalar s(const scalar p, const scalar T) const;
161 
162  //- Return compressibility rho/p [s^2/m^2]
163  inline scalar psi(scalar p, scalar T) const;
164 
165  //- Return compression factor []
166  inline scalar Z(scalar p, scalar T) const;
167 
168  //- Return (cp - cv) [J/(kmol K]
169  inline scalar cpMcv(scalar p, scalar T) const;
170 
171 
172  // IO
173 
174  //- Write to Ostream
175  void write(Ostream& os) const;
176 
177 
178  // Member operators
179 
180  inline void operator+=(const linear&);
181  inline void operator-=(const linear&);
182 
183  inline void operator*=(const scalar);
184 
185 
186  // Friend operators
187 
188  friend linear operator+ <Specie>
189  (
190  const linear&,
191  const linear&
192  );
193 
194  friend linear operator- <Specie>
195  (
196  const linear&,
197  const linear&
198  );
199 
200  friend linear operator* <Specie>
201  (
202  const scalar s,
203  const linear&
204  );
205 
206  friend linear operator== <Specie>
207  (
208  const linear&,
209  const linear&
210  );
211 
212 
213  // Ostream Operator
214 
215  friend Ostream& operator<< <Specie>
216  (
217  Ostream&,
218  const linear&
219  );
220 };
221 
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 } // End namespace Foam
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #include "linearI.H"
230 
231 #ifdef NoRepository
232 # include "linear.C"
233 #endif
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
Foam::linear::psi_
scalar psi_
Compressibility.
Definition: linear.H:101
Foam::linear::Z
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: linearI.H:110
Foam::linear::rho
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: linearI.H:89
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::linear::write
void write(Ostream &os) const
Write to Ostream.
Definition: linear.C:54
Foam::linear::psi
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: linearI.H:103
Foam::linear::incompressible
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: linear.H:150
Foam::linear::operator*=
void operator*=(const scalar)
Definition: linearI.H:162
Foam::linear::s
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
Definition: linearI.H:96
Foam::linear::isochoric
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: linear.H:153
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
linearI.H
Foam::linear::operator-=
void operator-=(const linear &)
Definition: linearI.H:145
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::linear::clone
autoPtr< linear > clone() const
Construct and return a clone.
Definition: linearI.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::linear::cpMcv
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
Definition: linearI.H:117
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::linear::New
static autoPtr< linear > New(Istream &is)
Definition: linearI.H:69
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::linear::rho0_
scalar rho0_
The reference density.
Definition: linear.H:104
Foam::linear::linear
linear(const fvMesh &mesh)
Construct from mesh.
Definition: linear.H:69
Foam::linear::operator+=
void operator+=(const linear &)
Definition: linearI.H:127
Foam::linear
Central-differencing interpolation scheme class.
Definition: linear.H:50
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::linear::typeName
static word typeName()
Return the instantiated type name.
Definition: linear.H:141
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
autoPtr.H