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-2016 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>::h(scalar p, scalar T) const
83 {
84  return 0;
85 }
86 
87 
88 template<class Specie>
89 inline Foam::scalar Foam::rhoConst<Specie>::cp(scalar p, scalar T) const
90 {
91  return 0;
92 }
93 
94 
95 template<class Specie>
96 inline Foam::scalar Foam::rhoConst<Specie>::s(scalar p, scalar T) const
97 {
98  return 0;
99 }
100 
101 
102 template<class Specie>
103 inline Foam::scalar Foam::rhoConst<Specie>::psi(scalar p, scalar T) const
104 {
105  return 0;
106 }
107 
108 
109 template<class Specie>
110 inline Foam::scalar Foam::rhoConst<Specie>::Z(scalar p, scalar T) const
111 {
112  return 0;
113 }
114 
115 
116 template<class Specie>
117 inline Foam::scalar Foam::rhoConst<Specie>::cpMcv(scalar p, scalar T) const
118 {
119  return 0;
120 }
121 
122 
123 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
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>
141 {
142  scalar molr1 = this->nMoles();
143 
144  Specie::operator-=(ico);
145 
146  molr1 /= this->nMoles();
147  scalar molr2 = ico.nMoles()/this->nMoles();
148 
149  rho_ = molr1*rho_ - molr2*ico.rho_;
150 }
151 
152 
153 template<class Specie>
154 inline void Foam::rhoConst<Specie>::operator*=(const scalar s)
155 {
156  Specie::operator*=(s);
157 }
158 
159 
160 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
161 
162 template<class Specie>
163 inline Foam::rhoConst<Specie> Foam::operator+
164 (
165  const rhoConst<Specie>& ico1,
166  const rhoConst<Specie>& ico2
167 )
168 {
169  scalar nMoles = ico1.nMoles() + ico2.nMoles();
170  scalar molr1 = ico1.nMoles()/nMoles;
171  scalar molr2 = ico2.nMoles()/nMoles;
172 
173  return rhoConst<Specie>
174  (
175  static_cast<const Specie&>(ico1)
176  + static_cast<const Specie&>(ico2),
177  molr1*ico1.rho_ + molr2*ico2.rho_
178  );
179 }
180 
181 
182 template<class Specie>
183 inline Foam::rhoConst<Specie> Foam::operator-
184 (
185  const rhoConst<Specie>& ico1,
186  const rhoConst<Specie>& ico2
187 )
188 {
189  scalar nMoles = ico1.nMoles() + ico2.nMoles();
190  scalar molr1 = ico1.nMoles()/nMoles;
191  scalar molr2 = ico2.nMoles()/nMoles;
192 
193  return rhoConst<Specie>
194  (
195  static_cast<const Specie&>(ico1)
196  - static_cast<const Specie&>(ico2),
197  molr1*ico1.rho_ - molr2*ico2.rho_
198  );
199 }
200 
201 
202 template<class Specie>
203 inline Foam::rhoConst<Specie> Foam::operator*
204 (
205  const scalar s,
206  const rhoConst<Specie>& ico
207 )
208 {
209  return rhoConst<Specie>(s*static_cast<const Specie&>(ico), ico.rho_);
210 }
211 
212 
213 template<class Specie>
214 inline Foam::rhoConst<Specie> Foam::operator==
215 (
216  const rhoConst<Specie>& ico1,
217  const rhoConst<Specie>& ico2
218 )
219 {
220  return ico2 - ico1;
221 }
222 
223 
224 // ************************************************************************* //
void operator+=(const rhoConst &)
Definition: rhoConstI.H:126
void operator-=(const rhoConst &)
Definition: rhoConstI.H:140
static autoPtr< rhoConst > New(Istream &is)
Definition: rhoConstI.H:66
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
rhoConst(const Specie &sp, const scalar rho)
Construct from components.
Definition: rhoConstI.H:32
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
Definition: rhoConstI.H:96
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: rhoConstI.H:75
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
Definition: rhoConstI.H:117
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 Z(scalar p, scalar T) const
Return compression factor [].
Definition: rhoConstI.H:110
const volScalarField & T
scalar cp(scalar p, scalar T) const
Return cp departure [J/(kmol K].
Definition: rhoConstI.H:89
void operator*=(const scalar)
Definition: rhoConstI.H:154
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
RhoConst (rho = const) of state.
Definition: rhoConst.H:47
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: rhoConstI.H:103
volScalarField & p
scalar h(const scalar p, const scalar T) const
Return enthalpy departure [J/kmol].
Definition: rhoConstI.H:82
autoPtr< rhoConst > clone() const
Construct and return a clone.
Definition: rhoConstI.H:58