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-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::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 name and dictionary
133  linear(const word& name, 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 
142  // Member Functions
143 
144  //- Return the instantiated type name
145  static word typeName()
146  {
147  return "linear<" + word(Specie::typeName_()) + '>';
148  }
149 
150 
151  // Fundamental properties
152 
153  //- Is the equation of state is incompressible i.e. rho != f(p)
154  static const bool incompressible = false;
155 
156  //- Is the equation of state is isochoric i.e. rho = const
157  static const bool isochoric = false;
158 
159  //- Return density [kg/m^3]
160  inline scalar rho(scalar p, scalar T) const;
161 
162  //- Return enthalpy contribution [J/kg]
163  inline scalar H(const scalar p, const scalar T) const;
164 
165  //- Return Cp contribution [J/(kg K]
166  inline scalar Cp(scalar p, scalar T) const;
167 
168  //- Return internal energy contribution [J/kg]
169  inline scalar E(const scalar p, const scalar T) const;
170 
171  //- Return Cv contribution [J/(kg K]
172  inline scalar Cv(scalar p, scalar T) const;
173 
174  //- Return entropy contribution to the integral of Cp/T [J/kg/K]
175  inline scalar Sp(const scalar p, const scalar T) const;
176 
177  //- Return entropy contribution to the integral of Cv/T [J/kg/K]
178  inline scalar Sv(const scalar p, const scalar T) const;
179 
180  //- Return compressibility [s^2/m^2]
181  inline scalar psi(scalar p, scalar T) const;
182 
183  //- Return compression factor []
184  inline scalar Z(scalar p, scalar T) const;
185 
186  //- Return (Cp - Cv) [J/(kg K]
187  inline scalar CpMCv(scalar p, scalar T) const;
188 
189  //- Return volumetric coefficient of thermal expansion [1/T]
190  inline scalar alphav(const scalar p, const scalar T) const;
191 
192 
193  // IO
194 
195  //- Write to Ostream
196  void write(Ostream& os) const;
197 
198 
199  // Member Operators
200 
201  inline void operator+=(const linear&);
202  inline void operator*=(const scalar);
203 
204 
205  // Friend operators
206 
207  friend linear operator+ <Specie>
208  (
209  const linear&,
210  const linear&
211  );
212 
213  friend linear operator* <Specie>
214  (
215  const scalar s,
216  const linear&
217  );
218 
219  friend linear operator== <Specie>
220  (
221  const linear&,
222  const linear&
223  );
224 
225 
226  // Ostream Operator
227 
228  friend Ostream& operator<< <Specie>
229  (
230  Ostream&,
231  const linear&
232  );
233 };
234 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 } // End namespace Foam
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #include "linearI.H"
243 
244 #ifdef NoRepository
245  #include "linear.C"
246 #endif
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #endif
251 
252 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
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
Centred interpolation interpolation scheme class.
Definition: linear.H:53
scalar Cv(scalar p, scalar T) const
Return Cv contribution [J/(kg K].
Definition: linearI.H:98
void operator+=(const linear &)
Definition: linearI.H:151
scalar Sv(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cv/T [J/kg/K].
Definition: linearI.H:112
scalar E(const scalar p, const scalar T) const
Return internal energy contribution [J/kg].
Definition: linearI.H:89
scalar psi(scalar p, scalar T) const
Return compressibility [s^2/m^2].
Definition: linearI.H:120
scalar H(const scalar p, const scalar T) const
Return enthalpy contribution [J/kg].
Definition: linearI.H:75
scalar alphav(const scalar p, const scalar T) const
Return volumetric coefficient of thermal expansion [1/T].
Definition: linearI.H:141
static word typeName()
Return the instantiated type name.
Definition: linear.H:153
void write(Ostream &os) const
Write to Ostream.
Definition: linear.C:43
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: linearI.H:68
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
Definition: linearI.H:134
linear(const fvMesh &mesh)
Construct from mesh.
Definition: linear.H:64
scalar Cp(scalar p, scalar T) const
Return Cp contribution [J/(kg K].
Definition: linearI.H:82
scalar Sp(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cp/T [J/kg/K].
Definition: linearI.H:105
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: linear.H:165
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: linear.H:162
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: linearI.H:127
autoPtr< linear > clone() const
Construct and return a clone.
Definition: linearI.H:59
void operator*=(const scalar)
Definition: linearI.H:160
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)
scalar rho0
dictionary dict
volScalarField & p