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-2021 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, so this equation of
32  state is not applicable to mixtures.
33 
34  The polynomial expression is evaluated from:
35 
36  \verbatim
37  rho = 1000 - 0.05*T + 0.003*sqr(T)
38  \endverbatim
39 
40 Usage
41  \table
42  Property | Description
43  rhoCoeffs<8> | Density polynomial coefficients
44  \endtable
45 
46  Example specification of the icoPolynomial equation of state:
47  \verbatim
48  equationOfState
49  {
50  rhoCoeffs<8> ( 1000 -0.05 0.003 0 0 0 0 0 );
51  }
52  \endverbatim
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  //- Return volumetric coefficient of thermal expansion [1/T]
195  inline scalar alphav(const scalar p, const scalar T) const;
196 
197 
198  // IO
199 
200  //- Write to Ostream
201  void write(Ostream& os) const;
202 
203 
204  // Member Operators
205 
206  inline void operator+=(const icoPolynomial&);
207  inline void operator*=(const scalar);
208 
209 
210  // Friend operators
211 
212  friend icoPolynomial operator+ <Specie, PolySize>
213  (
214  const icoPolynomial&,
215  const icoPolynomial&
216  );
217 
218  friend icoPolynomial operator* <Specie, PolySize>
219  (
220  const scalar s,
221  const icoPolynomial&
222  );
223 
224  friend icoPolynomial operator== <Specie, PolySize>
225  (
226  const icoPolynomial&,
227  const icoPolynomial&
228  );
229 
230 
231  // Ostream Operator
232 
233  friend Ostream& operator<< <Specie, PolySize>
234  (
235  Ostream&,
236  const icoPolynomial&
237  );
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
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 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:156
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:48
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
scalar alphav(const scalar p, const scalar T) const
Return volumetric coefficient of thermal expansion [1/T].
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.