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-2020 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  Coefficient mixing is very inaccurate and not supported,
32  so this equation of state is not applicable to mixtures.
33 
34 Usage
35  \table
36  Property | Description
37  rhoCoeffs<8> | Density polynomial coefficients
38  \endtable
39 
40  Example of the specification of the equation of state:
41  \verbatim
42  equationOfState
43  {
44  rhoCoeffs<8> ( 1000 -0.05 0.003 0 0 0 0 0 );
45  }
46  \endverbatim
47 
48  The polynomial expression is evaluated as so:
49 
50  \f[
51  \rho = 1000 - 0.05 T + 0.003 T^2
52  \f]
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 [kg/m^3/K^i]
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 contribution [J/kg]
168  inline scalar H(const scalar p, const scalar T) const;
169 
170  //- Return Cp contribution [J/(kg K]
171  inline scalar Cp(scalar p, scalar T) const;
172 
173  //- Return internal energy contribution [J/kg]
174  inline scalar E(const scalar p, const scalar T) const;
175 
176  //- Return Cv contribution [J/(kg K]
177  inline scalar Cv(scalar p, scalar T) const;
178 
179  //- Return entropy contribution to the integral of Cp/T [J/kg/K]
180  inline scalar Sp(const scalar p, const scalar T) const;
181 
182  //- Return entropy contribution to the integral of Cv/T [J/kg/K]
183  inline scalar Sv(const scalar p, const scalar T) const;
184 
185  //- Return compressibility [s^2/m^2]
186  inline scalar psi(scalar p, scalar T) const;
187 
188  //- Return compression factor []
189  inline scalar Z(scalar p, scalar T) const;
190 
191  //- Return (Cp - Cv) [J/(kg K]
192  inline scalar CpMCv(scalar p, scalar T) const;
193 
194 
195  // IO
196 
197  //- Write to Ostream
198  void write(Ostream& os) const;
199 
200 
201  // Member Operators
202 
203  inline void operator+=(const icoPolynomial&);
204  inline void operator*=(const scalar);
205 
206 
207  // Friend operators
208 
209  friend icoPolynomial operator+ <Specie, PolySize>
210  (
211  const icoPolynomial&,
212  const icoPolynomial&
213  );
214 
215  friend icoPolynomial operator* <Specie, PolySize>
216  (
217  const scalar s,
218  const icoPolynomial&
219  );
220 
221  friend icoPolynomial operator== <Specie, PolySize>
222  (
223  const icoPolynomial&,
224  const icoPolynomial&
225  );
226 
227 
228  // Ostream Operator
229 
230  friend Ostream& operator<< <Specie, PolySize>
231  (
232  Ostream&,
233  const icoPolynomial&
234  );
235 };
236 
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace Foam
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #include "icoPolynomialI.H"
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 #ifdef NoRepository
249  #include "icoPolynomial.C"
250 #endif
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 #endif
255 
256 // ************************************************************************* //
scalar H(const scalar p, const scalar T) const
Return enthalpy contribution [J/kg].
dictionary dict
scalar psi(scalar p, scalar T) const
Return compressibility [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 Sp(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cp/T [J/kg/K].
scalar E(const scalar p, const scalar T) const
Return internal energy contribution [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 contribution [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 Cv(scalar p, scalar T) const
Return Cv contribution [J/(kg K].
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void operator+=(const icoPolynomial &)
scalar Sv(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cv/T [J/kg/K].
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.