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-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::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 (
57  const icoPolynomial<Specie, PolySize>&
58 );
59 
60 template<class Specie, int PolySize>
61 icoPolynomial<Specie, PolySize> operator-
62 (
63  const icoPolynomial<Specie, PolySize>&,
64  const icoPolynomial<Specie, PolySize>&
65 );
66 
67 template<class Specie, int PolySize>
68 icoPolynomial<Specie, PolySize> operator*
69 (
70  const scalar,
71  const icoPolynomial<Specie, PolySize>&
72 );
73 
74 template<class Specie, int PolySize>
75 icoPolynomial<Specie, PolySize> operator==
76 (
77  const icoPolynomial<Specie, PolySize>&,
78  const icoPolynomial<Specie, PolySize>&
79 );
80 
81 template<class Specie, int PolySize>
82 Ostream& operator<<
83 (
84  Ostream&,
85  const icoPolynomial<Specie, PolySize>&
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]
102  Polynomial<PolySize> rhoCoeffs_;
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 enthalpy departure [J/kmol]
159  inline scalar h(const scalar p, const scalar T) const;
160 
161  //- Return cp departure [J/(kmol K]
162  inline scalar cp(scalar p, scalar T) const;
163 
164  //- Return entropy [J/(kmol K)]
165  inline scalar s(const scalar p, const scalar T) const;
166 
167  //- Return compressibility rho/p [s^2/m^2]
168  inline scalar psi(scalar p, scalar T) const;
169 
170  //- Return compression factor []
171  inline scalar Z(scalar p, scalar T) const;
172 
173  //- Return (cp - cv) [J/(kmol K]
174  inline scalar cpMcv(scalar p, scalar T) const;
175 
176 
177  // IO
178 
179  //- Write to Ostream
180  void write(Ostream& os) const;
181 
182 
183  // Member operators
184 
185  inline void operator=(const icoPolynomial&);
186  inline void operator+=(const icoPolynomial&);
187  inline void operator-=(const icoPolynomial&);
188 
189  inline void operator*=(const scalar);
190 
191 
192  // Friend operators
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 icoPolynomial&,
203  const icoPolynomial&
204  );
205 
206  friend icoPolynomial operator* <Specie, PolySize>
207  (
208  const scalar s,
209  const icoPolynomial&
210  );
211 
212  friend icoPolynomial operator== <Specie, PolySize>
213  (
214  const icoPolynomial&,
215  const icoPolynomial&
216  );
217 
218 
219  // Ostream Operator
220 
221  friend Ostream& operator<< <Specie, PolySize>
222  (
223  Ostream&,
224  const icoPolynomial&
225  );
226 };
227 
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 } // End namespace Foam
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 #define makeIcoPolynomial(PolySize) \
236  \
237 defineTemplateTypeNameAndDebugWithName \
238 ( \
239  icoPolynomial<Specie, PolySize>, \
240  "icoPolynomial<"#PolySize">", \
241  0 \
242 );
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 #include "icoPolynomialI.H"
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #ifdef NoRepository
251  #include "icoPolynomial.C"
252 #endif
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
dictionary dict
autoPtr< icoPolynomial > clone() const
Construct and return a clone.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Incompressible, polynomial form of equation of state, using a polynomial function for density...
Definition: icoPolynomial.H:50
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
scalar Z(scalar p, scalar T) const
Return compression factor [].
void operator*=(const scalar)
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
scalar cp(scalar p, scalar T) const
Return cp departure [J/(kmol K].
icoPolynomial(const Specie &sp, const Polynomial< PolySize > &rhoPoly)
Construct from components.
void write(Ostream &os) const
Write to Ostream.
Definition: icoPolynomial.C:65
A class for handling words, derived from string.
Definition: word.H:59
static autoPtr< icoPolynomial > New(Istream &is)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
void operator+=(const icoPolynomial &)
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
void operator-=(const icoPolynomial &)
scalar h(const scalar p, const scalar T) const
Return enthalpy departure [J/kmol].
Polynomial templated on size (order):
Definition: Polynomial.H:63
void operator=(const icoPolynomial &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
volScalarField & p
static word typeName()
Return the instantiated type name.
Namespace for OpenFOAM.