FreeFOAM The Cross-Platform CFD Toolkit
icoPolynomial.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) 2008-2010 OpenCFD Ltd.
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::icoPolynomial
26 
27 Description
28  Incompressible, polynomial form of equation of state, using a polynomial
29  function for density.
30 
31 SourceFiles
32  icoPolynomialI.H
33  icoPolynomial.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef icoPolynomial_H
38 #define icoPolynomial_H
39 
40 #include <specie/specie.H>
41 #include <OpenFOAM/autoPtr.H>
42 #include <OpenFOAM/Polynomial.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of friend functions and operators
50 
51 template<int PolySize>
52 class icoPolynomial;
53 
54 template<int PolySize>
55 icoPolynomial<PolySize> operator+
56 (
57  const icoPolynomial<PolySize>&,
58  const icoPolynomial<PolySize>&
59 );
60 
61 template<int PolySize>
62 icoPolynomial<PolySize> operator-
63 (
64  const icoPolynomial<PolySize>&,
65  const icoPolynomial<PolySize>&
66 );
67 
68 template<int PolySize>
69 icoPolynomial<PolySize> operator*
70 (
71  const scalar,
72  const icoPolynomial<PolySize>&
73 );
74 
75 template<int PolySize>
76 icoPolynomial<PolySize> operator==
77 (
78  const icoPolynomial<PolySize>&,
79  const icoPolynomial<PolySize>&
80 );
81 
82 template<int PolySize>
83 Ostream& operator<<
84 (
85  Ostream&,
86  const icoPolynomial<PolySize>&
87 );
88 
89 
90 /*---------------------------------------------------------------------------*\
91  Class icoPolynomial Declaration
92 \*---------------------------------------------------------------------------*/
93 
94 template<int PolySize>
96 :
97  public specie
98 {
99  // Private data
100 
101  //- Density
102  // Note: input in [kg/m3], but internally uses [kg/m3/kmol]
103  Polynomial<PolySize> rhoPolynomial_;
104 
105 
106 public:
107 
108  // Constructors
109 
110  //- Construct from components
111  inline icoPolynomial
112  (
113  const specie& sp,
114  const Polynomial<PolySize>& rhoPoly
115  );
116 
117  //- Construct from Istream
119 
120  //- Construct as copy
121  inline icoPolynomial(const icoPolynomial&);
122 
123  //- Construct as named copy
124  inline icoPolynomial(const word& name, const icoPolynomial&);
125 
126  //- Construct and return a clone
127  inline autoPtr<icoPolynomial> clone() const;
128 
129  // Selector from Istream
130  inline static autoPtr<icoPolynomial> New(Istream& is);
131 
132 
133  // Member functions
134 
135  //- Return density [kg/m^3]
136  inline scalar rho(scalar p, scalar T) const;
137 
138  //- Return compressibility rho/p [s^2/m^2]
139  inline scalar psi(scalar p, scalar T) const;
140 
141  //- Return compression factor []
142  inline scalar Z(scalar p, scalar T) const;
143 
144 
145  // Member operators
146 
147  inline icoPolynomial& operator=(const icoPolynomial&);
148  inline void operator+=(const icoPolynomial&);
149  inline void operator-=(const icoPolynomial&);
150 
151  inline void operator*=(const scalar);
152 
153 
154  // Friend operators
155 
156  friend icoPolynomial operator+ <PolySize>
157  (
158  const icoPolynomial&,
159  const icoPolynomial&
160  );
161 
162  friend icoPolynomial operator- <PolySize>
163  (
164  const icoPolynomial&,
165  const icoPolynomial&
166  );
167 
168  friend icoPolynomial operator* <PolySize>
169  (
170  const scalar s,
171  const icoPolynomial&
172  );
173 
174  friend icoPolynomial operator== <PolySize>
175  (
176  const icoPolynomial&,
177  const icoPolynomial&
178  );
179 
180 
181  // Ostream Operator
182 
183  friend Ostream& operator<< <PolySize>(Ostream&, const icoPolynomial&);
184 };
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace Foam
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #define makeIcoPolynomial(PolySize) \
194  \
195 defineTemplateTypeNameAndDebugWithName \
196 ( \
197  icoPolynomial<PolySize>, \
198  "icoPolynomial<"#PolySize">", \
199  0 \
200 );
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #include "icoPolynomialI.H"
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #ifdef NoRepository
209 # include "icoPolynomial.C"
210 #endif
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 #endif
215 
216 // ************************ vim: set sw=4 sts=4 et: ************************ //