rhoConstI.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-2018 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 \*---------------------------------------------------------------------------*/
25 
26 #include "rhoConst.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class Specie>
32 (
33  const Specie& sp,
34  const scalar rho
35 )
36 :
37  Specie(sp),
38  rho_(rho)
39 {}
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
44 template<class Specie>
46 (
47  const word& name,
48  const rhoConst<Specie>& ico
49 )
50 :
51  Specie(name, ico),
52  rho_(ico.rho_)
53 {}
54 
55 
56 template<class Specie>
59 {
60  return autoPtr<rhoConst<Specie>>(new rhoConst<Specie>(*this));
61 }
62 
63 
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 
66 template<class Specie>
67 inline Foam::scalar Foam::rhoConst<Specie>::rho(scalar p, scalar T) const
68 {
69  return rho_;
70 }
71 
72 
73 template<class Specie>
74 inline Foam::scalar Foam::rhoConst<Specie>::H(scalar p, scalar T) const
75 {
76  return 0;
77 }
78 
79 
80 template<class Specie>
81 inline Foam::scalar Foam::rhoConst<Specie>::Cp(scalar p, scalar T) const
82 {
83  return 0;
84 }
85 
86 
87 template<class Specie>
88 inline Foam::scalar Foam::rhoConst<Specie>::S(scalar p, scalar T) const
89 {
90  return 0;
91 }
92 
93 
94 template<class Specie>
95 inline Foam::scalar Foam::rhoConst<Specie>::psi(scalar p, scalar T) const
96 {
97  return 0;
98 }
99 
100 
101 template<class Specie>
102 inline Foam::scalar Foam::rhoConst<Specie>::Z(scalar p, scalar T) const
103 {
104  return 0;
105 }
106 
107 
108 template<class Specie>
109 inline Foam::scalar Foam::rhoConst<Specie>::CpMCv(scalar p, scalar T) const
110 {
111  return 0;
112 }
113 
114 
115 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
116 
117 template<class Specie>
119 {
120  scalar Y1 = this->Y();
121  Specie::operator+=(ico);
122 
123  if (mag(this->Y()) > small)
124  {
125  Y1 /= this->Y();
126  const scalar Y2 = ico.Y()/this->Y();
127 
128  rho_ = Y1*rho_ + Y2*ico.rho_;
129  }
130 }
131 
132 
133 template<class Specie>
134 inline void Foam::rhoConst<Specie>::operator*=(const scalar s)
135 {
136  Specie::operator*=(s);
137 }
138 
139 
140 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
141 
142 template<class Specie>
143 inline Foam::rhoConst<Specie> Foam::operator+
144 (
145  const rhoConst<Specie>& ico1,
146  const rhoConst<Specie>& ico2
147 )
148 {
149  Specie sp
150  (
151  static_cast<const Specie&>(ico1)
152  + static_cast<const Specie&>(ico2)
153  );
154 
155  if (mag(sp.Y()) < small)
156  {
157  return rhoConst<Specie>
158  (
159  sp,
160  ico1.rho_
161  );
162  }
163  else
164  {
165  const scalar Y1 = ico1.Y()/sp.Y();
166  const scalar Y2 = ico2.Y()/sp.Y();
167 
168  return rhoConst<Specie>
169  (
170  sp,
171  Y1*ico1.rho_ + Y2*ico2.rho_
172  );
173  }
174 }
175 
176 
177 template<class Specie>
178 inline Foam::rhoConst<Specie> Foam::operator*
179 (
180  const scalar s,
181  const rhoConst<Specie>& ico
182 )
183 {
184  return rhoConst<Specie>(s*static_cast<const Specie&>(ico), ico.rho_);
185 }
186 
187 
188 template<class Specie>
189 inline Foam::rhoConst<Specie> Foam::operator==
190 (
191  const rhoConst<Specie>& ico1,
192  const rhoConst<Specie>& ico2
193 )
194 {
195  Specie sp
196  (
197  static_cast<const Specie&>(ico1)
198  == static_cast<const Specie&>(ico2)
199  );
200 
201  const scalar Y1 = ico1.Y()/sp.Y();
202  const scalar Y2 = ico2.Y()/sp.Y();
203 
204  return rhoConst<Specie>
205  (
206  sp,
207  Y2*ico2.rho_ - Y1*ico1.rho_
208  );
209 }
210 
211 
212 // ************************************************************************* //
void operator+=(const rhoConst &)
Definition: rhoConstI.H:118
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: rhoConstI.H:95
scalar H(const scalar p, const scalar T) const
Return enthalpy departure [J/kg].
Definition: rhoConstI.H:74
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: rhoConstI.H:102
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:109
scalar S(const scalar p, const scalar T) const
Return entropy [J/(kg K)].
Definition: rhoConstI.H:88
scalar Cp(scalar p, scalar T) const
Return Cp departure [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
const volScalarField & T
autoPtr< rhoConst > clone() const
Construct and return a clone.
Definition: rhoConstI.H:58
PtrList< volScalarField > & Y
void operator*=(const scalar)
Definition: rhoConstI.H:134
dimensioned< scalar > mag(const dimensioned< Type > &)
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