icoPolynomial.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 Usage
32  \table
33  Property | Description
34  rhoCoeffs<8> | Density polynomial coefficients
35  \endtable
36 
37  Example of the specification of the equation of state:
38  \verbatim
39  equationOfState
40  {
41  rhoCoeffs<8> ( 1000 -0.05 0.003 0 0 0 0 0 );
42  }
43  \endverbatim
44 
45  The polynomial expression is evaluated as so:
46 
47  \f[
48  \rho = 1000 - 0.05 T + 0.003 T^2
49  \f]
50 
51 Note
52  Input in [kg/m3], but internally uses [kg/m3/kmol].
53 
54 SourceFiles
55  icoPolynomialI.H
56  icoPolynomial.C
57 
58 See also
59  Foam::Polynomial
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef icoPolynomial_H
64 #define icoPolynomial_H
65 
66 #include "autoPtr.H"
67 #include "Polynomial.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 
74 // Forward declaration of friend functions and operators
75 
76 template<class Specie, int PolySize>
77 class icoPolynomial;
78 
79 template<class Specie, int PolySize>
80 icoPolynomial<Specie, PolySize> operator+
81 (
84 );
85 
86 template<class Specie, int PolySize>
88 (
89  const scalar,
91 );
92 
93 template<class Specie, int PolySize>
95 (
96  const icoPolynomial<Specie, PolySize>&,
97  const icoPolynomial<Specie, PolySize>&
98 );
99 
100 template<class Specie, int PolySize>
101 Ostream& operator<<
102 (
103  Ostream&,
104  const icoPolynomial<Specie, PolySize>&
105 );
106 
107 
108 /*---------------------------------------------------------------------------*\
109  Class icoPolynomial Declaration
110 \*---------------------------------------------------------------------------*/
111 
112 template<class Specie, int PolySize=8>
113 class icoPolynomial
114 :
115  public Specie
116 {
117  // Private data
118 
119  //- Density polynomial coefficients
120  Polynomial<PolySize> rhoCoeffs_;
121 
122 
123 public:
124 
125  // Constructors
126 
127  //- Construct from components
128  inline icoPolynomial
129  (
130  const Specie& sp,
131  const Polynomial<PolySize>& rhoPoly
132  );
133 
134  //- Construct from dictionary
135  icoPolynomial(const dictionary& dict);
136 
137  //- Construct as named copy
138  inline icoPolynomial(const word& name, const icoPolynomial&);
139 
140  //- Construct and return a clone
141  inline autoPtr<icoPolynomial> clone() const;
142 
143  // Selector from dictionary
144  inline static autoPtr<icoPolynomial> New(const dictionary& dict);
145 
146 
147  // Member functions
148 
149  //- Return the instantiated type name
150  static word typeName()
151  {
152  return "icoPolynomial<" + word(Specie::typeName_()) + '>';
153  }
154 
156  // Fundamental properties
157 
158  //- Is the equation of state is incompressible i.e. rho != f(p)
159  static const bool incompressible = true;
160 
161  //- Is the equation of state is isochoric i.e. rho = const
162  static const bool isochoric = false;
163 
164  //- Return density [kg/m^3]
165  inline scalar rho(scalar p, scalar T) const;
166 
167  //- Return enthalpy departure [J/kg]
168  inline scalar H(const scalar p, const scalar T) const;
169 
170  //- Return Cp departure [J/(kg K]
171  inline scalar Cp(scalar p, scalar T) const;
172 
173  //- Return entropy [J/(kg K)]
174  inline scalar S(const scalar p, const scalar T) const;
175 
176  //- Return compressibility rho/p [s^2/m^2]
177  inline scalar psi(scalar p, scalar T) const;
178 
179  //- Return compression factor []
180  inline scalar Z(scalar p, scalar T) const;
181 
182  //- Return (Cp - Cv) [J/(kg K]
183  inline scalar CpMCv(scalar p, scalar T) const;
184 
185 
186  // IO
187 
188  //- Write to Ostream
189  void write(Ostream& os) const;
190 
191 
192  // Member operators
193 
194  inline void operator=(const icoPolynomial&);
195  inline void operator+=(const icoPolynomial&);
196  inline void operator*=(const scalar);
197 
198 
199  // Friend operators
200 
201  friend icoPolynomial operator+ <Specie, PolySize>
202  (
203  const icoPolynomial&,
204  const icoPolynomial&
205  );
206 
207  friend icoPolynomial operator* <Specie, PolySize>
208  (
209  const scalar s,
210  const icoPolynomial&
211  );
212 
213  friend icoPolynomial operator== <Specie, PolySize>
214  (
215  const icoPolynomial&,
216  const icoPolynomial&
217  );
218 
219 
220  // Ostream Operator
221 
222  friend Ostream& operator<< <Specie, PolySize>
223  (
224  Ostream&,
225  const icoPolynomial&
226  );
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace Foam
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #define makeIcoPolynomial(PolySize) \
237  \
238 defineTemplateTypeNameAndDebugWithName \
239 ( \
240  icoPolynomial<Specie, PolySize>, \
241  "icoPolynomial<"#PolySize">", \
242  0 \
243 );
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #include "icoPolynomialI.H"
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #ifdef NoRepository
252  #include "icoPolynomial.C"
253 #endif
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #endif
258 
259 // ************************************************************************* //
scalar H(const scalar p, const scalar T) const
Return enthalpy departure [J/kg].
dictionary dict
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
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:82
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
scalar Z(scalar p, scalar T) const
Return compression factor [].
scalar Cp(scalar p, scalar T) const
Return Cp departure [J/(kg K].
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
static autoPtr< icoPolynomial > New(const dictionary &dict)
void operator*=(const scalar)
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
icoPolynomial(const Specie &sp, const Polynomial< PolySize > &rhoPoly)
Construct from components.
void write(Ostream &os) const
Write to Ostream.
Definition: icoPolynomial.C:53
A class for handling words, derived from string.
Definition: word.H:59
scalar S(const scalar p, const scalar T) const
Return entropy [J/(kg K)].
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
Polynomial templated on size (order):
Definition: Polynomial.H:65
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:52
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
volScalarField & p
static word typeName()
Return the instantiated type name.
Namespace for OpenFOAM.