specieI.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) 2011-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 "specie.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 inline specie::specie
36 (
37  const word& name,
38  const scalar Y,
39  const scalar molWeight
40 )
41 :
42  name_(name),
43  Y_(Y),
44  molWeight_(molWeight)
45 {}
46 
47 
48 inline specie::specie
49 (
50  const scalar Y,
51  const scalar molWeight
52 )
53 :
54  Y_(Y),
55  molWeight_(molWeight)
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
61 inline specie::specie(const word& name, const specie& st)
62 :
63  name_(name),
64  Y_(st.Y_),
65  molWeight_(st.molWeight_)
66 {}
67 
68 
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 
71 inline const word& specie::name() const
72 {
73  return name_;
74 }
75 
76 
77 inline scalar specie::W() const
78 {
79  return molWeight_;
80 }
81 
82 
83 inline scalar specie::Y() const
84 {
85  return Y_;
86 }
87 
88 
89 inline scalar specie::R() const
90 {
91  return RR/molWeight_;
92 }
93 
94 
95 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
96 
97 inline void specie::operator=(const specie& st)
98 {
99  // name_ = st.name_;
100  Y_ = st.Y_;
101  molWeight_ = st.molWeight_;
102 }
103 
104 
105 inline void specie::operator+=(const specie& st)
106 {
107  const scalar sumY = Y_ + st.Y_;
108  if (mag(sumY) > small)
109  {
110  molWeight_ = sumY/(Y_/molWeight_ + st.Y_/st.molWeight_);
111  }
112 
113  Y_ = sumY;
114 }
115 
116 
117 inline void specie::operator*=(const scalar s)
118 {
119  Y_ *= s;
120 }
121 
122 
123 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
124 
125 inline specie operator+(const specie& st1, const specie& st2)
126 {
127  const scalar sumY = max(st1.Y_ + st2.Y_, small);
128 
129  if (mag(sumY) > small)
130  {
131  return specie
132  (
133  sumY,
134  sumY/(st1.Y_/st1.molWeight_ + st2.Y_/st2.molWeight_)
135  );
136  }
137  else
138  {
139  return st1;
140  }
141 }
142 
143 
144 inline specie operator*(const scalar s, const specie& st)
145 {
146  return specie
147  (
148  s*st.Y_,
149  st.molWeight_
150  );
151 }
152 
153 
154 inline specie operator==(const specie& st1, const specie& st2)
155 {
156  scalar diffY = st2.Y_ - st1.Y_;
157  if (mag(diffY) < small)
158  {
159  diffY = small;
160  }
161 
162  const scalar diffRW =
163  st2.Y_/st2.molWeight_ - st1.Y_/st1.molWeight_;
164 
165  scalar molWeight = great;
166  if (mag(diffRW) > small)
167  {
168  molWeight = diffY/diffRW;
169  }
170 
171  return specie(diffY, molWeight);
172 }
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace Foam
178 
179 // ************************************************************************* //
const word & name() const
Name.
Definition: specieI.H:71
void operator=(const specie &)
Definition: specieI.H:97
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void operator*=(const scalar)
Definition: specieI.H:117
scalar R() const
Gas constant [J/kg/K].
Definition: specieI.H:89
scalar Y() const
Mass fraction of this specie in mixture.
Definition: specieI.H:83
friend specie operator==(const specie &, const specie &)
Definition: specieI.H:154
Base class of the thermophysical property types.
Definition: specie.H:65
const dimensionedScalar RR
Universal gas constant: default SI units: [J/kmol/K].
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))
friend specie operator*(const scalar, const specie &)
Definition: specieI.H:144
A class for handling words, derived from string.
Definition: word.H:59
friend specie operator+(const specie &, const specie &)
Definition: specieI.H:125
specie(const scalar Y, const scalar molWeight)
Construct from components without name.
Definition: specieI.H:49
scalar W() const
Molecular weight [kg/kmol].
Definition: specieI.H:77
dimensioned< scalar > mag(const dimensioned< Type > &)
void operator+=(const specie &)
Definition: specieI.H:105
Namespace for OpenFOAM.