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