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