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-2019 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/m^3], 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 internal energy departure [J/kg]
174  inline scalar E(const scalar p, const scalar T) const;
175 
176  //- Return Cv departure [J/(kg K]
177  inline scalar Cv(scalar p, scalar T) const;
178 
179  //- Return entropy [J/kg/K]
180  inline scalar S(const scalar p, const scalar T) const;
181 
182  //- Return compressibility rho/p [s^2/m^2]
183  inline scalar psi(scalar p, scalar T) const;
184 
185  //- Return compression factor []
186  inline scalar Z(scalar p, scalar T) const;
187 
188  //- Return (Cp - Cv) [J/(kg K]
189  inline scalar CpMCv(scalar p, scalar T) const;
190 
191 
192  // IO
193 
194  //- Write to Ostream
195  void write(Ostream& os) const;
196 
197 
198  // Member Operators
199 
200  inline void operator+=(const icoPolynomial&);
201  inline void operator*=(const scalar);
202 
203 
204  // Friend operators
205 
206  friend icoPolynomial operator+ <Specie, PolySize>
207  (
208  const icoPolynomial&,
209  const icoPolynomial&
210  );
211 
212  friend icoPolynomial operator* <Specie, PolySize>
213  (
214  const scalar s,
215  const icoPolynomial&
216  );
217 
218  friend icoPolynomial operator== <Specie, PolySize>
219  (
220  const icoPolynomial&,
221  const icoPolynomial&
222  );
223 
224 
225  // Ostream Operator
226 
227  friend Ostream& operator<< <Specie, PolySize>
228  (
229  Ostream&,
230  const icoPolynomial&
231  );
232 };
233 
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 } // End namespace Foam
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #define makeIcoPolynomial(PolySize) \
242  \
243 defineTemplateTypeNameAndDebugWithName \
244 ( \
245  icoPolynomial<Specie, PolySize>, \
246  "icoPolynomial<"#PolySize">", \
247  0 \
248 );
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 #include "icoPolynomialI.H"
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #ifdef NoRepository
257  #include "icoPolynomial.C"
258 #endif
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
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:158
scalar E(const scalar p, const scalar T) const
Return internal energy departure [J/kg].
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].
scalar Cv(scalar p, scalar T) const
Return Cv departure [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
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.