linear.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) 2013-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::linear
26 
27 Description
28  Linear equation of state with constant compressibility:
29 
30  \verbatim
31  rho = rho0 + psi*p
32  \endverbatim
33 
34  Coefficient mixing is very inaccurate and not supported,
35  so this equation of state is not applicable to mixtures.
36 
37 Usage
38  \table
39  Property | Description
40  rho0 | Reference density
41  psi | Constant compressibility
42  \endtable
43 
44  Example specification of the linear equation of state:
45  \verbatim
46  equationOfState
47  {
48  rho0 1000;
49  psi 1e-5;
50  }
51  \endverbatim
52 
53 SourceFiles
54  linearI.H
55  linear.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef linear_H
60 #define linear_H
61 
62 #include "autoPtr.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 
69 // Forward declaration of friend functions and operators
70 
71 template<class Specie> class linear;
72 
73 template<class Specie>
74 inline linear<Specie> operator+
75 (
76  const linear<Specie>&,
77  const linear<Specie>&
78 );
79 
80 template<class Specie>
81 inline linear<Specie> operator*
82 (
83  const scalar,
84  const linear<Specie>&
85 );
86 
87 template<class Specie>
88 inline linear<Specie> operator==
89 (
90  const linear<Specie>&,
91  const linear<Specie>&
92 );
93 
94 template<class Specie>
95 Ostream& operator<<
96 (
97  Ostream&,
98  const linear<Specie>&
99 );
100 
101 
102 /*---------------------------------------------------------------------------*\
103  Class linear Declaration
104 \*---------------------------------------------------------------------------*/
105 
106 template<class Specie>
107 class linear
108 :
109  public Specie
110 {
111  // Private Data
112 
113  //- Compressibility
114  scalar psi_;
115 
116  //- The reference density
117  scalar rho0_;
118 
119 
120 public:
121 
122  // Constructors
123 
124  //- Construct from components
125  inline linear
126  (
127  const Specie& sp,
128  const scalar psi,
129  const scalar rho0
130  );
131 
132  //- Construct from dictionary
133  linear(const dictionary& dict);
134 
135  //- Construct as named copy
136  inline linear(const word& name, const linear&);
137 
138  //- Construct and return a clone
139  inline autoPtr<linear> clone() const;
140 
141  // Selector from dictionary
142  inline static autoPtr<linear> New(const dictionary& dict);
143 
144 
145  // Member Functions
146 
147  //- Return the instantiated type name
148  static word typeName()
149  {
150  return "linear<" + word(Specie::typeName_()) + '>';
151  }
152 
153 
154  // Fundamental properties
155 
156  //- Is the equation of state is incompressible i.e. rho != f(p)
157  static const bool incompressible = false;
158 
159  //- Is the equation of state is isochoric i.e. rho = const
160  static const bool isochoric = false;
161 
162  //- Return density [kg/m^3]
163  inline scalar rho(scalar p, scalar T) const;
164 
165  //- Return enthalpy contribution [J/kg]
166  inline scalar H(const scalar p, const scalar T) const;
167 
168  //- Return Cp contribution [J/(kg K]
169  inline scalar Cp(scalar p, scalar T) const;
170 
171  //- Return internal energy contribution [J/kg]
172  inline scalar E(const scalar p, const scalar T) const;
173 
174  //- Return Cv contribution [J/(kg K]
175  inline scalar Cv(scalar p, scalar T) const;
176 
177  //- Return entropy contribution to the integral of Cp/T [J/kg/K]
178  inline scalar Sp(const scalar p, const scalar T) const;
179 
180  //- Return entropy contribution to the integral of Cv/T [J/kg/K]
181  inline scalar Sv(const scalar p, const scalar T) const;
182 
183  //- Return compressibility [s^2/m^2]
184  inline scalar psi(scalar p, scalar T) const;
185 
186  //- Return compression factor []
187  inline scalar Z(scalar p, scalar T) const;
188 
189  //- Return (Cp - Cv) [J/(kg K]
190  inline scalar CpMCv(scalar p, scalar T) const;
191 
192  //- Return volumetric coefficient of thermal expansion [1/T]
193  inline scalar alphav(const scalar p, const scalar T) const;
194 
195 
196  // IO
197 
198  //- Write to Ostream
199  void write(Ostream& os) const;
200 
201 
202  // Member Operators
203 
204  inline void operator+=(const linear&);
205  inline void operator*=(const scalar);
206 
207 
208  // Friend operators
209 
210  friend linear operator+ <Specie>
211  (
212  const linear&,
213  const linear&
214  );
215 
216  friend linear operator* <Specie>
217  (
218  const scalar s,
219  const linear&
220  );
221 
222  friend linear operator== <Specie>
223  (
224  const linear&,
225  const linear&
226  );
227 
228 
229  // Ostream Operator
230 
231  friend Ostream& operator<< <Specie>
232  (
233  Ostream&,
234  const linear&
235  );
236 };
237 
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #include "linearI.H"
246 
247 #ifdef NoRepository
248  #include "linear.C"
249 #endif
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #endif
254 
255 // ************************************************************************* //
void operator+=(const linear &)
Definition: linearI.H:164
scalar H(const scalar p, const scalar T) const
Return enthalpy contribution [J/kg].
Definition: linearI.H:88
scalar Sv(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cv/T [J/kg/K].
Definition: linearI.H:125
dictionary dict
static autoPtr< linear > New(const dictionary &dict)
Definition: linearI.H:70
Centred interpolation interpolation scheme class.
Definition: linear.H:50
scalar psi(scalar p, scalar T) const
Return compressibility [s^2/m^2].
Definition: linearI.H:133
scalar rho0
scalar alphav(const scalar p, const scalar T) const
Return volumetric coefficient of thermal expansion [1/T].
Definition: linearI.H:154
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: linear.H:165
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))
scalar Cv(scalar p, scalar T) const
Return Cv contribution [J/(kg K].
Definition: linearI.H:111
void operator*=(const scalar)
Definition: linearI.H:173
linear(const fvMesh &mesh)
Construct from mesh.
Definition: linear.H:64
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
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: linearI.H:81
static word typeName()
Return the instantiated type name.
Definition: linear.H:156
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: linear.H:168
void write(Ostream &os) const
Write to Ostream.
Definition: linear.C:43
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
Definition: linearI.H:147
autoPtr< linear > clone() const
Construct and return a clone.
Definition: linearI.H:61
volScalarField & p
scalar Cp(scalar p, scalar T) const
Return Cp contribution [J/(kg K].
Definition: linearI.H:95
scalar E(const scalar p, const scalar T) const
Return internal energy contribution [J/kg].
Definition: linearI.H:102
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: linearI.H:140
scalar Sp(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cp/T [J/kg/K].
Definition: linearI.H:118
Namespace for OpenFOAM.