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 p/rho_;
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>::E(scalar p, scalar T) const
89 {
90  return 0;
91 }
92 
93 
94 template<class Specie>
95 inline Foam::scalar Foam::rhoConst<Specie>::Cv(scalar p, scalar T) const
96 {
97  return 0;
98 }
99 
100 
101 template<class Specie>
102 inline Foam::scalar Foam::rhoConst<Specie>::S(scalar p, scalar T) const
103 {
104  return 0;
105 }
106 
107 
108 template<class Specie>
109 inline Foam::scalar Foam::rhoConst<Specie>::psi(scalar p, scalar T) const
110 {
111  return 0;
112 }
113 
114 
115 template<class Specie>
116 inline Foam::scalar Foam::rhoConst<Specie>::Z(scalar p, scalar T) const
117 {
118  return 0;
119 }
120 
121 
122 template<class Specie>
123 inline Foam::scalar Foam::rhoConst<Specie>::CpMCv(scalar p, scalar T) const
124 {
125  return 0;
126 }
127 
128 
129 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
130 
131 template<class Specie>
133 {
134  scalar Y1 = this->Y();
135  Specie::operator+=(ico);
136 
137  if (mag(this->Y()) > small)
138  {
139  Y1 /= this->Y();
140  const scalar Y2 = ico.Y()/this->Y();
141 
142  rho_ = Y1*rho_ + Y2*ico.rho_;
143  }
144 }
145 
146 
147 template<class Specie>
148 inline void Foam::rhoConst<Specie>::operator*=(const scalar s)
149 {
150  Specie::operator*=(s);
151 }
152 
153 
154 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
155 
156 template<class Specie>
157 inline Foam::rhoConst<Specie> Foam::operator+
158 (
159  const rhoConst<Specie>& ico1,
160  const rhoConst<Specie>& ico2
161 )
162 {
163  Specie sp
164  (
165  static_cast<const Specie&>(ico1)
166  + static_cast<const Specie&>(ico2)
167  );
168 
169  if (mag(sp.Y()) < small)
170  {
171  return rhoConst<Specie>
172  (
173  sp,
174  ico1.rho_
175  );
176  }
177  else
178  {
179  const scalar Y1 = ico1.Y()/sp.Y();
180  const scalar Y2 = ico2.Y()/sp.Y();
181 
182  return rhoConst<Specie>
183  (
184  sp,
185  Y1*ico1.rho_ + Y2*ico2.rho_
186  );
187  }
188 }
189 
190 
191 template<class Specie>
192 inline Foam::rhoConst<Specie> Foam::operator*
193 (
194  const scalar s,
195  const rhoConst<Specie>& ico
196 )
197 {
198  return rhoConst<Specie>(s*static_cast<const Specie&>(ico), ico.rho_);
199 }
200 
201 
202 template<class Specie>
203 inline Foam::rhoConst<Specie> Foam::operator==
204 (
205  const rhoConst<Specie>& ico1,
206  const rhoConst<Specie>& ico2
207 )
208 {
209  Specie sp
210  (
211  static_cast<const Specie&>(ico1)
212  == static_cast<const Specie&>(ico2)
213  );
214 
215  const scalar Y1 = ico1.Y()/sp.Y();
216  const scalar Y2 = ico2.Y()/sp.Y();
217 
218  return rhoConst<Specie>
219  (
220  sp,
221  Y2*ico2.rho_ - Y1*ico1.rho_
222  );
223 }
224 
225 
226 // ************************************************************************* //
void operator+=(const rhoConst &)
Definition: rhoConstI.H:132
scalar E(const scalar p, const scalar T) const
Return internal energy departure [J/kg].
Definition: rhoConstI.H:88
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: rhoConstI.H:109
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:116
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:123
scalar S(const scalar p, const scalar T) const
Return entropy [J/kg/K].
Definition: rhoConstI.H:102
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
scalar Cv(scalar p, scalar T) const
Return Cv departure [J/(kg K].
Definition: rhoConstI.H:95
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:148
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