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-2023 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 (
82  const icoPolynomial<Specie, PolySize>&,
83  const icoPolynomial<Specie, PolySize>&
84 );
85 
86 template<class Specie, int PolySize>
88 (
89  const scalar,
91 );
92 
93 template<class Specie, int PolySize>
95 (
98 );
99 
100 template<class Specie, int PolySize>
101 Ostream& operator<<
102 (
103  Ostream&,
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 name and dictionary
135  icoPolynomial(const word& name, 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 
144  // Member Functions
145 
146  //- Return the instantiated type name
147  static word typeName()
148  {
149  return "icoPolynomial<" + word(Specie::typeName_()) + '>';
150  }
151 
152 
153  // Fundamental properties
154 
155  //- Is the equation of state is incompressible i.e. rho != f(p)
156  static const bool incompressible = true;
157 
158  //- Is the equation of state is isochoric i.e. rho = const
159  static const bool isochoric = false;
160 
161  //- Return density [kg/m^3]
162  inline scalar rho(scalar p, scalar T) const;
163 
164  //- Return enthalpy contribution [J/kg]
165  inline scalar H(const scalar p, const scalar T) const;
166 
167  //- Return Cp contribution [J/(kg K]
168  inline scalar Cp(scalar p, scalar T) const;
169 
170  //- Return internal energy contribution [J/kg]
171  inline scalar E(const scalar p, const scalar T) const;
172 
173  //- Return Cv contribution [J/(kg K]
174  inline scalar Cv(scalar p, scalar T) const;
175 
176  //- Return entropy contribution to the integral of Cp/T [J/kg/K]
177  inline scalar Sp(const scalar p, const scalar T) const;
178 
179  //- Return entropy contribution to the integral of Cv/T [J/kg/K]
180  inline scalar Sv(const scalar p, const scalar T) const;
181 
182  //- Return compressibility [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  //- Return volumetric coefficient of thermal expansion [1/T]
192  inline scalar alphav(const scalar p, const 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 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Polynomial templated on size (order):
Definition: Polynomial.H:84
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Incompressible, polynomial form of equation of state, using a polynomial function for density.
scalar Cv(scalar p, scalar T) const
Return Cv contribution [J/(kg K].
scalar Sv(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cv/T [J/kg/K].
scalar E(const scalar p, const scalar T) const
Return internal energy contribution [J/kg].
scalar psi(scalar p, scalar T) const
Return compressibility [s^2/m^2].
scalar H(const scalar p, const scalar T) const
Return enthalpy contribution [J/kg].
scalar alphav(const scalar p, const scalar T) const
Return volumetric coefficient of thermal expansion [1/T].
icoPolynomial(const Specie &sp, const Polynomial< PolySize > &rhoPoly)
Construct from components.
static word typeName()
Return the instantiated type name.
void operator+=(const icoPolynomial &)
void write(Ostream &os) const
Write to Ostream.
Definition: icoPolynomial.C:52
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
autoPtr< icoPolynomial > clone() const
Construct and return a clone.
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
scalar Cp(scalar p, scalar T) const
Return Cp contribution [J/(kg K].
scalar Sp(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cp/T [J/kg/K].
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
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 [].
void operator*=(const scalar)
A class for handling words, derived from string.
Definition: word.H:62
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict
volScalarField & p