1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "ReactingMultiphaseParcel.H"
28 #include "IOstreams.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 template <class ParcelType>
33 Foam::string Foam::ReactingMultiphaseParcel<ParcelType>::propHeader =
34 ReactingParcel<ParcelType>::propHeader
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 template<class ParcelType>
43 Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
45 const Cloud<ParcelType>& cloud,
50 ReactingParcel<ParcelType>(cloud, is, readFields),
58 const ReactingMultiphaseCloud<ParcelType>& cR =
59 dynamic_cast<const ReactingMultiphaseCloud<ParcelType>&>(cloud);
61 const label idGas = cR.composition().idGas();
62 const label nGas = cR.composition().componentNames(idGas).size();
63 const label idLiquid = cR.composition().idLiquid();
64 const label nLiquid = cR.composition().componentNames(idLiquid).size();
65 const label idSolid = cR.composition().idGas();
66 const label nSolid = cR.composition().componentNames(idSolid).size();
69 YLiquid_.setSize(nLiquid);
70 YSolid_.setSize(nSolid);
72 is >> YGas_ >> YLiquid_ >> YSolid_;
74 // scale the mass fractions
75 const scalarField& YMix = this->Y_;
76 YGas_ /= YMix[GAS] + ROOTVSMALL;
77 YLiquid_ /= YMix[LIQ] + ROOTVSMALL;
78 YSolid_ /= YMix[SLD] + ROOTVSMALL;
81 // Check state of Istream
84 "ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel"
86 "const Cloud<ParcelType>&, "
94 template<class ParcelType>
95 void Foam::ReactingMultiphaseParcel<ParcelType>::readFields
97 Cloud<ParcelType>& cIn
105 ReactingMultiphaseCloud<ParcelType>& c =
106 dynamic_cast<ReactingMultiphaseCloud<ParcelType>&>(cIn);
108 ReactingParcel<ParcelType>::readFields(c);
110 // Get names and sizes for each Y...
111 const label idGas = c.composition().idGas();
112 const wordList& gasNames = c.composition().componentNames(idGas);
113 const label idLiquid = c.composition().idLiquid();
114 const wordList& liquidNames = c.composition().componentNames(idLiquid);
115 const label idSolid = c.composition().idSolid();
116 const wordList& solidNames = c.composition().componentNames(idSolid);
117 const wordList& stateLabels = c.composition().stateLabels();
119 // Set storage for each Y... for each parcel
120 forAllIter(typename Cloud<ParcelType>, c, iter)
122 ReactingMultiphaseParcel<ParcelType>& p = iter();
123 p.YGas_.setSize(gasNames.size(), 0.0);
124 p.YLiquid_.setSize(liquidNames.size(), 0.0);
125 p.YSolid_.setSize(solidNames.size(), 0.0);
128 // Populate YGas for each parcel
135 "Y" + gasNames[j] + stateLabels[idGas],
141 forAllIter(typename Cloud<ParcelType>, c, iter)
143 ReactingMultiphaseParcel<ParcelType>& p = iter();
144 p.YGas_[j] = YGas[i++]/(p.Y()[GAS] + ROOTVSMALL);
147 // Populate YLiquid for each parcel
148 forAll(liquidNames, j)
150 IOField<scalar> YLiquid
154 "Y" + liquidNames[j] + stateLabels[idLiquid],
160 forAllIter(typename Cloud<ParcelType>, c, iter)
162 ReactingMultiphaseParcel<ParcelType>& p = iter();
163 p.YLiquid_[j] = YLiquid[i++]/(p.Y()[LIQ] + ROOTVSMALL);
166 // Populate YSolid for each parcel
167 forAll(solidNames, j)
169 IOField<scalar> YSolid
173 "Y" + solidNames[j] + stateLabels[idSolid],
179 forAllIter(typename Cloud<ParcelType>, c, iter)
181 ReactingMultiphaseParcel<ParcelType>& p = iter();
182 p.YSolid_[j] = YSolid[i++]/(p.Y()[SLD] + ROOTVSMALL);
188 template<class ParcelType>
189 void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
191 const Cloud<ParcelType>& cIn
194 const ReactingMultiphaseCloud<ParcelType>& c =
195 dynamic_cast<const ReactingMultiphaseCloud<ParcelType>&>(cIn);
197 ReactingParcel<ParcelType>::writeFields(c);
201 // Write the composition fractions
204 const wordList& stateLabels = c.composition().stateLabels();
206 const label idGas = c.composition().idGas();
207 const wordList& gasNames = c.composition().componentNames(idGas);
214 "Y" + gasNames[j] + stateLabels[idGas],
221 forAllConstIter(typename Cloud<ParcelType>, c, iter)
223 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
224 YGas[i++] = p0.YGas()[j]*p0.Y()[GAS];
230 const label idLiquid = c.composition().idLiquid();
231 const wordList& liquidNames = c.composition().componentNames(idLiquid);
232 forAll(liquidNames, j)
234 IOField<scalar> YLiquid
238 "Y" + liquidNames[j] + stateLabels[idLiquid],
245 forAllConstIter(typename Cloud<ParcelType>, c, iter)
247 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
248 YLiquid[i++] = p0.YLiquid()[j]*p0.Y()[LIQ];
254 const label idSolid = c.composition().idSolid();
255 const wordList& solidNames = c.composition().componentNames(idSolid);
256 forAll(solidNames, j)
258 IOField<scalar> YSolid
262 "Y" + solidNames[j] + stateLabels[idSolid],
269 forAllConstIter(typename Cloud<ParcelType>, c, iter)
271 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
272 YSolid[i++] = p0.YSolid()[j]*p0.Y()[SLD];
281 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
283 template<class ParcelType>
284 Foam::Ostream& Foam::operator<<
287 const ReactingMultiphaseParcel<ParcelType>& p
290 scalarField YGasLoc = p.YGas()*p.Y()[0];
291 scalarField YLiquidLoc = p.YLiquid()*p.Y()[1];
292 scalarField YSolidLoc = p.YSolid()*p.Y()[2];
293 if (os.format() == IOstream::ASCII)
295 os << static_cast<const ReactingParcel<ParcelType>&>(p)
296 << token::SPACE << YGasLoc
297 << token::SPACE << YLiquidLoc
298 << token::SPACE << YSolidLoc;
302 os << static_cast<const ReactingParcel<ParcelType>&>(p);
303 os << YGasLoc << YLiquidLoc << YSolidLoc;
306 // Check state of Ostream
309 "Ostream& operator<<"
312 "const ReactingMultiphaseParcel<ParcelType>&"
320 // ************************************************************************* //