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