rhoConstI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2012-2015 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 template<class Specie>
67 {
69 }
70 
71 
72 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 
74 template<class Specie>
75 inline Foam::scalar Foam::rhoConst<Specie>::rho(scalar p, scalar T) const
76 {
77  return rho_;
78 }
79 
80 
81 template<class Specie>
82 inline Foam::scalar Foam::rhoConst<Specie>::s(scalar p, scalar T) const
83 {
84  return 0;
85 }
86 
87 
88 template<class Specie>
89 inline Foam::scalar Foam::rhoConst<Specie>::psi(scalar p, scalar T) const
90 {
91  return 0;
92 }
93 
94 
95 template<class Specie>
96 inline Foam::scalar Foam::rhoConst<Specie>::Z(scalar p, scalar T) const
97 {
98  return 0;
99 }
100 
101 
102 template<class Specie>
103 inline Foam::scalar Foam::rhoConst<Specie>::cpMcv(scalar p, scalar T) const
104 {
105  return 0;
106 }
107 
108 
109 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
110 
111 template<class Specie>
113 {
114  scalar molr1 = this->nMoles();
115 
116  Specie::operator+=(ico);
117 
118  molr1 /= this->nMoles();
119  scalar molr2 = ico.nMoles()/this->nMoles();
120 
121  rho_ = molr1*rho_ + molr2*ico.rho_;
122 }
123 
124 
125 template<class Specie>
127 {
128  scalar molr1 = this->nMoles();
129 
130  Specie::operator-=(ico);
131 
132  molr1 /= this->nMoles();
133  scalar molr2 = ico.nMoles()/this->nMoles();
134 
135  rho_ = molr1*rho_ - molr2*ico.rho_;
136 }
137 
138 
139 template<class Specie>
140 inline void Foam::rhoConst<Specie>::operator*=(const scalar s)
141 {
142  Specie::operator*=(s);
143 }
144 
145 
146 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
147 
148 template<class Specie>
149 inline Foam::rhoConst<Specie> Foam::operator+
150 (
151  const rhoConst<Specie>& ico1,
152  const rhoConst<Specie>& ico2
153 )
154 {
155  scalar nMoles = ico1.nMoles() + ico2.nMoles();
156  scalar molr1 = ico1.nMoles()/nMoles;
157  scalar molr2 = ico2.nMoles()/nMoles;
158 
159  return rhoConst<Specie>
160  (
161  static_cast<const Specie&>(ico1)
162  + static_cast<const Specie&>(ico2),
163  molr1*ico1.rho_ + molr2*ico2.rho_
164  );
165 }
166 
167 
168 template<class Specie>
169 inline Foam::rhoConst<Specie> Foam::operator-
170 (
171  const rhoConst<Specie>& ico1,
172  const rhoConst<Specie>& ico2
173 )
174 {
175  scalar nMoles = ico1.nMoles() + ico2.nMoles();
176  scalar molr1 = ico1.nMoles()/nMoles;
177  scalar molr2 = ico2.nMoles()/nMoles;
178 
179  return rhoConst<Specie>
180  (
181  static_cast<const Specie&>(ico1)
182  - static_cast<const Specie&>(ico2),
183  molr1*ico1.rho_ - molr2*ico2.rho_
184  );
185 }
186 
187 
188 template<class Specie>
189 inline Foam::rhoConst<Specie> Foam::operator*
190 (
191  const scalar s,
192  const rhoConst<Specie>& ico
193 )
194 {
195  return rhoConst<Specie>(s*static_cast<const Specie&>(ico), ico.rho_);
196 }
197 
198 
199 template<class Specie>
200 inline Foam::rhoConst<Specie> Foam::operator==
201 (
202  const rhoConst<Specie>& ico1,
203  const rhoConst<Specie>& ico2
204 )
205 {
206  return ico2 - ico1;
207 }
208 
209 
210 // ************************************************************************* //
Foam::rhoConst::operator*=
void operator*=(const scalar)
Definition: rhoConstI.H:140
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::rhoConst::operator-=
void operator-=(const rhoConst &)
Definition: rhoConstI.H:126
rhoConst.H
Foam::rhoConst::cpMcv
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
Definition: rhoConstI.H:103
Foam::rhoConst::Z
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: rhoConstI.H:96
Foam::rhoConst::rho
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: rhoConstI.H:75
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::rhoConst::rho_
scalar rho_
Density.
Definition: rhoConst.H:97
Foam::rhoConst::rhoConst
rhoConst(const Specie &sp, const scalar rho)
Construct from components.
Definition: rhoConstI.H:32
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
s
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))
rho
rho
Definition: pEqn.H:3
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::rhoConst::s
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
Definition: rhoConstI.H:82
Foam::rhoConst::clone
autoPtr< rhoConst > clone() const
Construct and return a clone.
Definition: rhoConstI.H:58
Foam::rhoConst::operator+=
void operator+=(const rhoConst &)
Definition: rhoConstI.H:112
Foam::rhoConst::psi
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: rhoConstI.H:89
Foam::rhoConst
RhoConst (rho = const) of state.
Definition: rhoConst.H:47
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::rhoConst::New
static autoPtr< rhoConst > New(Istream &is)
Definition: rhoConstI.H:66