rhoConst.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) 2012-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::rhoConst
26 
27 Description
28  Constant density equations of state
29 
30 Usage
31  \table
32  Property | Description
33  rho | Constant density
34  \endtable
35 
36  Example specification of the rhoConst equation of state:
37  \verbatim
38  equationOfState
39  {
40  rho 1000;
41  }
42  \endverbatim
43 
44 
45 SourceFiles
46  rhoConstI.H
47  rhoConst.C
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef rhoConst_H
52 #define rhoConst_H
53 
54 #include "autoPtr.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 // Forward declaration of friend functions and operators
62 
63 template<class Specie> class rhoConst;
64 
65 template<class Specie>
66 inline rhoConst<Specie> operator+
67 (
69  const rhoConst<Specie>&
70 );
71 
72 template<class Specie>
73 inline rhoConst<Specie> operator*
74 (
75  const scalar,
76  const rhoConst<Specie>&
77 );
78 
79 template<class Specie>
80 inline rhoConst<Specie> operator==
81 (
82  const rhoConst<Specie>&,
83  const rhoConst<Specie>&
84 );
85 
86 template<class Specie>
87 Ostream& operator<<
88 (
89  Ostream&,
90  const rhoConst<Specie>&
91 );
92 
93 
94 /*---------------------------------------------------------------------------*\
95  Class rhoConst Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 template<class Specie>
99 class rhoConst
100 :
101  public Specie
102 {
103  // Private Data
104 
105  //- Density
106  scalar rho_;
107 
108 
109 public:
110 
111  // Constructors
112 
113  //- Construct from components
114  inline rhoConst(const Specie& sp, const scalar rho);
115 
116  //- Construct from dictionary
117  rhoConst(const dictionary& dict);
118 
119  //- Construct as named copy
120  inline rhoConst(const word& name, const rhoConst&);
121 
122  //- Construct and return a clone
123  inline autoPtr<rhoConst> clone() const;
124 
125 
126  // Member Functions
127 
128  //- Return the instantiated type name
129  static word typeName()
130  {
131  return "rhoConst<" + word(Specie::typeName_()) + '>';
132  }
133 
135  // Fundamental properties
136 
137  //- Is the equation of state is incompressible i.e. rho != f(p)
138  static const bool incompressible = true;
139 
140  //- Is the equation of state is isochoric i.e. rho = const
141  static const bool isochoric = true;
142 
143  //- Return density [kg/m^3]
144  inline scalar rho(scalar p, scalar T) const;
145 
146  //- Return enthalpy contribution [J/kg]
147  inline scalar H(const scalar p, const scalar T) const;
148 
149  //- Return Cp contribution [J/(kg K]
150  inline scalar Cp(scalar p, scalar T) const;
151 
152  //- Return internal energy contribution [J/kg]
153  inline scalar E(const scalar p, const scalar T) const;
154 
155  //- Return Cv contribution [J/(kg K]
156  inline scalar Cv(scalar p, scalar T) const;
157 
158  //- Return entropy contribution to the integral of Cp/T [J/kg/K]
159  inline scalar Sp(const scalar p, const scalar T) const;
160 
161  //- Return entropy contribution to the integral of Cv/T [J/kg/K]
162  inline scalar Sv(const scalar p, const scalar T) const;
163 
164  //- Return compressibility [s^2/m^2]
165  inline scalar psi(scalar p, scalar T) const;
166 
167  //- Return compression factor []
168  inline scalar Z(scalar p, scalar T) const;
169 
170  //- Return (Cp - Cv) [J/(kg K]
171  inline scalar CpMCv(scalar p, scalar T) const;
172 
173  //- Return volumetric coefficient of thermal expansion [1/T]
174  inline scalar alphav(const scalar p, const 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 rhoConst&);
186  inline void operator*=(const scalar);
187 
188 
189  // Friend operators
190 
191  friend rhoConst operator+ <Specie>
192  (
193  const rhoConst&,
194  const rhoConst&
195  );
196 
197  friend rhoConst operator* <Specie>
198  (
199  const scalar s,
200  const rhoConst&
201  );
202 
203  friend rhoConst operator== <Specie>
204  (
205  const rhoConst&,
206  const rhoConst&
207  );
208 
209 
210  // Ostream Operator
211 
212  friend Ostream& operator<< <Specie>
213  (
214  Ostream&,
215  const rhoConst&
216  );
217 };
218 
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 } // End namespace Foam
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #include "rhoConstI.H"
227 
228 #ifdef NoRepository
229  #include "rhoConst.C"
230 #endif
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #endif
235 
236 // ************************************************************************* //
scalar alphav(const scalar p, const scalar T) const
Return volumetric coefficient of thermal expansion [1/T].
Definition: rhoConstI.H:137
scalar Sp(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cp/T [J/kg/K].
Definition: rhoConstI.H:102
dictionary dict
void operator+=(const rhoConst &)
Definition: rhoConstI.H:146
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: rhoConst.H:143
scalar E(const scalar p, const scalar T) const
Return internal energy contribution [J/kg].
Definition: rhoConstI.H:88
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
scalar psi(scalar p, scalar T) const
Return compressibility [s^2/m^2].
Definition: rhoConstI.H:116
scalar H(const scalar p, const scalar T) const
Return enthalpy contribution [J/kg].
Definition: rhoConstI.H:74
void write(Ostream &os) const
Write to Ostream.
Definition: rhoConst.C:42
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: rhoConstI.H:123
rhoConst(const Specie &sp, const scalar rho)
Construct from components.
Definition: rhoConstI.H:32
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
Definition: rhoConstI.H:130
scalar Cp(scalar p, scalar T) const
Return Cp contribution [J/(kg K].
Definition: rhoConstI.H:81
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: rhoConstI.H:67
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: rhoConstI.H:95
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: rhoConst.H:146
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
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
autoPtr< rhoConst > clone() const
Construct and return a clone.
Definition: rhoConstI.H:58
scalar Sv(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cv/T [J/kg/K].
Definition: rhoConstI.H:109
static word typeName()
Return the instantiated type name.
Definition: rhoConst.H:134
void operator*=(const scalar)
Definition: rhoConstI.H:159
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Constant density equations of state.
Definition: rhoConst.H:68
volScalarField & p
Namespace for OpenFOAM.