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) 2011-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::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 "autoPtr.H"
41 #include "Polynomial.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of friend functions and operators
49 
50 template<class Specie, int PolySize>
51 class icoPolynomial;
52 
53 template<class Specie, int PolySize>
55 (
58 );
59 
60 template<class Specie, int PolySize>
62 (
65 );
66 
67 template<class Specie, int PolySize>
69 (
70  const scalar,
72 );
73 
74 template<class Specie, int PolySize>
76 (
79 );
80 
81 template<class Specie, int PolySize>
82 Ostream& operator<<
83 (
84  Ostream&,
86 );
87 
88 
89 /*---------------------------------------------------------------------------*\
90  Class icoPolynomial Declaration
91 \*---------------------------------------------------------------------------*/
92 
93 template<class Specie, int PolySize=8>
94 class icoPolynomial
95 :
96  public Specie
97 {
98  // Private data
99 
100  //- Density polynomial coefficients
101  // Note: input in [kg/m3], but internally uses [kg/m3/kmol]
103 
104 
105 public:
106 
107  // Constructors
108 
109  //- Construct from components
110  inline icoPolynomial
111  (
112  const Specie& sp,
113  const Polynomial<PolySize>& rhoPoly
114  );
115 
116  //- Construct from Istream
118 
119  //- Construct from dictionary
120  icoPolynomial(const dictionary& dict);
121 
122  //- Construct as copy
123  inline icoPolynomial(const icoPolynomial&);
124 
125  //- Construct as named copy
126  inline icoPolynomial(const word& name, const icoPolynomial&);
127 
128  //- Construct and return a clone
129  inline autoPtr<icoPolynomial> clone() const;
130 
131  // Selector from Istream
132  inline static autoPtr<icoPolynomial> New(Istream& is);
133 
134  // Selector from dictionary
135  inline static autoPtr<icoPolynomial> New(const dictionary& dict);
136 
137 
138  // Member functions
139 
140  //- Return the instantiated type name
141  static word typeName()
142  {
143  return "icoPolynomial<" + word(Specie::typeName_()) + '>';
144  }
145 
146 
147  // Fundamental properties
148 
149  //- Is the equation of state is incompressible i.e. rho != f(p)
150  static const bool incompressible = true;
151 
152  //- Is the equation of state is isochoric i.e. rho = const
153  static const bool isochoric = false;
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 icoPolynomial& operator=(const icoPolynomial&);
180  inline void operator+=(const icoPolynomial&);
181  inline void operator-=(const icoPolynomial&);
182 
183  inline void operator*=(const scalar);
184 
185 
186  // Friend operators
187 
188  friend icoPolynomial operator+ <Specie, PolySize>
189  (
190  const icoPolynomial&,
191  const icoPolynomial&
192  );
193 
194  friend icoPolynomial operator- <Specie, PolySize>
195  (
196  const icoPolynomial&,
197  const icoPolynomial&
198  );
199 
200  friend icoPolynomial operator* <Specie, PolySize>
201  (
202  const scalar s,
203  const icoPolynomial&
204  );
205 
206  friend icoPolynomial operator== <Specie, PolySize>
207  (
208  const icoPolynomial&,
209  const icoPolynomial&
210  );
211 
212 
213  // Ostream Operator
214 
215  friend Ostream& operator<< <Specie, PolySize>
216  (
217  Ostream&,
218  const icoPolynomial&
219  );
220 };
221 
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 } // End namespace Foam
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #define makeIcoPolynomial(PolySize) \
230  \
231 defineTemplateTypeNameAndDebugWithName \
232 ( \
233  icoPolynomial<Specie, PolySize>, \
234  "icoPolynomial<"#PolySize">", \
235  0 \
236 );
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 #include "icoPolynomialI.H"
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #ifdef NoRepository
245 # include "icoPolynomial.C"
246 #endif
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #endif
251 
252 // ************************************************************************* //
Foam::icoPolynomial::operator=
icoPolynomial & operator=(const icoPolynomial &)
Definition: icoPolynomialI.H:162
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::icoPolynomial::clone
autoPtr< icoPolynomial > clone() const
Construct and return a clone.
Definition: icoPolynomialI.H:69
Foam::icoPolynomial::isochoric
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: icoPolynomial.H:152
Foam::icoPolynomial::operator+=
void operator+=(const icoPolynomial &)
Definition: icoPolynomialI.H:176
Foam::icoPolynomial::rho
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: icoPolynomialI.H:104
icoPolynomial.C
icoPolynomialI.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::icoPolynomial::cpMcv
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
Definition: icoPolynomialI.H:148
Foam::icoPolynomial::s
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
Definition: icoPolynomialI.H:115
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::icoPolynomial::operator*=
void operator*=(const scalar)
Definition: icoPolynomialI.H:209
Polynomial.H
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::icoPolynomial::New
static autoPtr< icoPolynomial > New(Istream &is)
Definition: icoPolynomialI.H:80
Foam::icoPolynomial::operator-=
void operator-=(const icoPolynomial &)
Definition: icoPolynomialI.H:193
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
Foam::icoPolynomial::rhoCoeffs_
Polynomial< PolySize > rhoCoeffs_
Density polynomial coefficients.
Definition: icoPolynomial.H:101
Foam::Polynomial< PolySize >
Foam::icoPolynomial::icoPolynomial
icoPolynomial(const Specie &sp, const Polynomial< PolySize > &rhoPoly)
Construct from components.
Foam::icoPolynomial::incompressible
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: icoPolynomial.H:149
PolySize
const int PolySize
Definition: Test-Polynomial.C:37
Foam::icoPolynomial::typeName
static word typeName()
Return the instantiated type name.
Definition: icoPolynomial.H:140
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::icoPolynomial::psi
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: icoPolynomialI.H:126
Foam::icoPolynomial::Z
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: icoPolynomialI.H:137
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::icoPolynomial::write
void write(Ostream &os) const
Write to Ostream.
Definition: icoPolynomial.C:65
Foam::icoPolynomial
Incompressible, polynomial form of equation of state, using a polynomial function for density.
Definition: icoPolynomial.H:50
autoPtr.H