icoPolynomial.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::icoPolynomial
29
30Group
31 grpSpecieEquationOfState
32
33Description
34 Incompressible, polynomial form of equation of state, using a polynomial
35 function for density.
36
37Usage
38 \table
39 Property | Description
40 rhoCoeffs<8> | Density polynomial coefficients
41 \endtable
42
43 Example of the specification of the equation of state:
44 \verbatim
45 equationOfState
46 {
47 rhoCoeffs<8> ( 1000 -0.05 0.003 0 0 0 0 0 );
48 }
49 \endverbatim
50
51 The polynomial expression is evaluated as so:
52
53 \f[
54 \rho = 1000 - 0.05 T + 0.003 T^2
55 \f]
56
57Note
58 Input in [kg/m3], but internally uses [kg/m3/kmol].
59
60SourceFiles
61 icoPolynomialI.H
62 icoPolynomial.C
63
64See also
65 Foam::Polynomial
66
67\*---------------------------------------------------------------------------*/
68
69#ifndef icoPolynomial_H
70#define icoPolynomial_H
71
72#include "autoPtr.H"
73#include "Polynomial.H"
74
75// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76
77namespace Foam
78{
79
80// Forward Declarations
81
82template<class Specie, int PolySize>
83class icoPolynomial;
84
85template<class Specie, int PolySize>
86icoPolynomial<Specie, PolySize> operator+
87(
88 const icoPolynomial<Specie, PolySize>&,
89 const icoPolynomial<Specie, PolySize>&
90);
92template<class Specie, int PolySize>
94(
95 const scalar,
97);
99template<class Specie, int PolySize>
101(
104);
106template<class Specie, int PolySize>
107Ostream& operator<<
108(
109 Ostream&,
111);
112
113
114/*---------------------------------------------------------------------------*\
115 Class icoPolynomial Declaration
116\*---------------------------------------------------------------------------*/
117
118template<class Specie, int PolySize=8>
119class icoPolynomial
120:
121 public Specie
122{
123 // Private Data
125 //- Density polynomial coefficients
126 Polynomial<PolySize> rhoCoeffs_;
127
128
129 // Private Member Functions
130
131 //- Coeffs name. Eg, "rhoCoeffs<10>"
132 inline static word coeffsName(const char* name)
133 {
134 return word(name + ("Coeffs<" + std::to_string(PolySize) + '>'));
135 }
136
137
138public:
139
140 // Generated Methods: copy construct, copy assignment
141
142 // Constructors
143
144 //- Construct from components
145 inline icoPolynomial
146 (
147 const Specie& sp,
148 const Polynomial<PolySize>& rhoPoly
149 );
150
151 //- Construct from dictionary
152 explicit icoPolynomial(const dictionary& dict);
153
154 //- Construct as named copy
155 inline icoPolynomial(const word& name, const icoPolynomial&);
156
157 //- Construct and return a clone
158 inline autoPtr<icoPolynomial> clone() const;
159
160 // Selector from dictionary
161 inline static autoPtr<icoPolynomial> New(const dictionary& dict);
162
163
164 // Member Functions
165
166 //- Return the instantiated type name
167 static word typeName()
168 {
169 return "icoPolynomial<" + word(Specie::typeName_()) + '>';
170 }
171
173 // Fundamental properties
174
175 //- Is the equation of state is incompressible i.e. rho != f(p)
176 static const bool incompressible = true;
177
178 //- Is the equation of state is isochoric i.e. rho = const
179 static const bool isochoric = false;
180
181 //- Return density [kg/m^3]
182 inline scalar rho(scalar p, scalar T) const;
183
184 //- Return enthalpy departure [J/kg]
185 inline scalar H(const scalar p, const scalar T) const;
186
187 //- Return Cp departure [J/(kg K]
188 inline scalar Cp(scalar p, scalar T) const;
189
190 //- Return internal energy departure [J/kg]
191 inline scalar E(const scalar p, const scalar T) const;
192
193 //- Return Cv departure [J/(kg K]
194 inline scalar Cv(scalar p, scalar T) const;
195
196 //- Return entropy [J/(kg K)]
197 inline scalar S(const scalar p, const scalar T) const;
198
199 //- Return compressibility rho/p [s^2/m^2]
200 inline scalar psi(scalar p, scalar T) const;
201
202 //- Return compression factor []
203 inline scalar Z(scalar p, scalar T) const;
204
205 //- Return (Cp - Cv) [J/(kg K]
206 inline scalar CpMCv(scalar p, scalar T) const;
207
208
209 // IO
210
211 //- Write to Ostream
212 void write(Ostream& os) const;
213
214
215 // Member Operators
216
217 inline void operator+=(const icoPolynomial&);
218 inline void operator*=(const scalar);
219
220
221 // Friend Operators
222
223 friend icoPolynomial operator+ <Specie, PolySize>
224 (
225 const icoPolynomial&,
226 const icoPolynomial&
227 );
229 friend icoPolynomial operator* <Specie, PolySize>
230 (
231 const scalar s,
232 const icoPolynomial&
233 );
235 friend icoPolynomial operator== <Specie, PolySize>
236 (
237 const icoPolynomial&,
238 const icoPolynomial&
239 );
241
242 // IOstream Operators
243
244 friend Ostream& operator<< <Specie, PolySize>
245 (
246 Ostream&,
247 const icoPolynomial&
248 );
250
251
252// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253
254} // End namespace Foam
255
256// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257
258#define makeIcoPolynomial(PolySize) \
259 \
260defineTemplateTypeNameAndDebugWithName \
261( \
262 icoPolynomial<Specie, PolySize>, \
263 "icoPolynomial<"#PolySize">", \
264 0 \
265);
266
267// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268
269#include "icoPolynomialI.H"
270
271// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272
273#ifdef NoRepository
274 #include "icoPolynomial.C"
275#endif
276
277// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278
279#endif
280
281// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Polynomial templated on size (order):
Definition: Polynomial.H:78
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Incompressible, polynomial form of equation of state, using a polynomial function for density.
static autoPtr< icoPolynomial > New(const dictionary &dict)
scalar E(const scalar p, const scalar T) const
Return internal energy departure [J/kg].
scalar H(const scalar p, const scalar T) const
Return enthalpy departure [J/kg].
static word typeName()
Return the instantiated type name.
void operator+=(const icoPolynomial &)
autoPtr< icoPolynomial > clone() const
Construct and return a clone.
scalar S(const scalar p, const scalar T) const
Return entropy [J/(kg K)].
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
icoPolynomial(const word &name, const icoPolynomial &)
Construct as named copy.
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 Foam::string.
Definition: word.H:68
volScalarField & p
const volScalarField & psi
const volScalarField & T
const volScalarField & Cv
Definition: EEqn.H:8
const volScalarField & Cp
Definition: EEqn.H:7
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
runTime write()
dictionary dict