1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ReactingMultiphaseParcel.H"
27 #include "IOstreams.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 template <class ParcelType>
32 Foam::string Foam::ReactingMultiphaseParcel<ParcelType>::propHeader =
33 ReactingParcel<ParcelType>::propHeader
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 template<class ParcelType>
42 Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
44 const Cloud<ParcelType>& cloud,
49 ReactingParcel<ParcelType>(cloud, is, readFields),
57 const ReactingMultiphaseCloud<ParcelType>& cR =
58 dynamic_cast<const ReactingMultiphaseCloud<ParcelType>&>(cloud);
60 const label idGas = cR.composition().idGas();
61 const label nGas = cR.composition().componentNames(idGas).size();
62 const label idLiquid = cR.composition().idLiquid();
63 const label nLiquid = cR.composition().componentNames(idLiquid).size();
64 const label idSolid = cR.composition().idGas();
65 const label nSolid = cR.composition().componentNames(idSolid).size();
68 YLiquid_.setSize(nLiquid);
69 YSolid_.setSize(nSolid);
71 is >> YGas_ >> YLiquid_ >> YSolid_;
73 // scale the mass fractions
74 const scalarField& YMix = this->Y_;
75 YGas_ /= YMix[GAS] + ROOTVSMALL;
76 YLiquid_ /= YMix[LIQ] + ROOTVSMALL;
77 YSolid_ /= YMix[SLD] + ROOTVSMALL;
80 // Check state of Istream
83 "ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel"
85 "const Cloud<ParcelType>&, "
93 template<class ParcelType>
94 void Foam::ReactingMultiphaseParcel<ParcelType>::readFields
96 Cloud<ParcelType>& cIn
104 ReactingMultiphaseCloud<ParcelType>& c =
105 dynamic_cast<ReactingMultiphaseCloud<ParcelType>&>(cIn);
107 ReactingParcel<ParcelType>::readFields(c);
109 // Get names and sizes for each Y...
110 const label idGas = c.composition().idGas();
111 const wordList& gasNames = c.composition().componentNames(idGas);
112 const label idLiquid = c.composition().idLiquid();
113 const wordList& liquidNames = c.composition().componentNames(idLiquid);
114 const label idSolid = c.composition().idSolid();
115 const wordList& solidNames = c.composition().componentNames(idSolid);
116 const wordList& stateLabels = c.composition().stateLabels();
118 // Set storage for each Y... for each parcel
119 forAllIter(typename Cloud<ParcelType>, c, iter)
121 ReactingMultiphaseParcel<ParcelType>& p = iter();
122 p.YGas_.setSize(gasNames.size(), 0.0);
123 p.YLiquid_.setSize(liquidNames.size(), 0.0);
124 p.YSolid_.setSize(solidNames.size(), 0.0);
127 // Populate YGas for each parcel
134 "Y" + gasNames[j] + stateLabels[idGas],
140 forAllIter(typename Cloud<ParcelType>, c, iter)
142 ReactingMultiphaseParcel<ParcelType>& p = iter();
143 p.YGas_[j] = YGas[i++]/(p.Y()[GAS] + ROOTVSMALL);
146 // Populate YLiquid for each parcel
147 forAll(liquidNames, j)
149 IOField<scalar> YLiquid
153 "Y" + liquidNames[j] + stateLabels[idLiquid],
159 forAllIter(typename Cloud<ParcelType>, c, iter)
161 ReactingMultiphaseParcel<ParcelType>& p = iter();
162 p.YLiquid_[j] = YLiquid[i++]/(p.Y()[LIQ] + ROOTVSMALL);
165 // Populate YSolid for each parcel
166 forAll(solidNames, j)
168 IOField<scalar> YSolid
172 "Y" + solidNames[j] + stateLabels[idSolid],
178 forAllIter(typename Cloud<ParcelType>, c, iter)
180 ReactingMultiphaseParcel<ParcelType>& p = iter();
181 p.YSolid_[j] = YSolid[i++]/(p.Y()[SLD] + ROOTVSMALL);
187 template<class ParcelType>
188 void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
190 const Cloud<ParcelType>& cIn
193 const ReactingMultiphaseCloud<ParcelType>& c =
194 dynamic_cast<const ReactingMultiphaseCloud<ParcelType>&>(cIn);
196 ReactingParcel<ParcelType>::writeFields(c);
200 // Write the composition fractions
203 const wordList& stateLabels = c.composition().stateLabels();
205 const label idGas = c.composition().idGas();
206 const wordList& gasNames = c.composition().componentNames(idGas);
213 "Y" + gasNames[j] + stateLabels[idGas],
220 forAllConstIter(typename Cloud<ParcelType>, c, iter)
222 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
223 YGas[i++] = p0.YGas()[j]*p0.Y()[GAS];
229 const label idLiquid = c.composition().idLiquid();
230 const wordList& liquidNames = c.composition().componentNames(idLiquid);
231 forAll(liquidNames, j)
233 IOField<scalar> YLiquid
237 "Y" + liquidNames[j] + stateLabels[idLiquid],
244 forAllConstIter(typename Cloud<ParcelType>, c, iter)
246 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
247 YLiquid[i++] = p0.YLiquid()[j]*p0.Y()[LIQ];
253 const label idSolid = c.composition().idSolid();
254 const wordList& solidNames = c.composition().componentNames(idSolid);
255 forAll(solidNames, j)
257 IOField<scalar> YSolid
261 "Y" + solidNames[j] + stateLabels[idSolid],
268 forAllConstIter(typename Cloud<ParcelType>, c, iter)
270 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
271 YSolid[i++] = p0.YSolid()[j]*p0.Y()[SLD];
280 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
282 template<class ParcelType>
283 Foam::Ostream& Foam::operator<<
286 const ReactingMultiphaseParcel<ParcelType>& p
289 scalarField YGasLoc = p.YGas()*p.Y()[0];
290 scalarField YLiquidLoc = p.YLiquid()*p.Y()[1];
291 scalarField YSolidLoc = p.YSolid()*p.Y()[2];
292 if (os.format() == IOstream::ASCII)
294 os << static_cast<const ReactingParcel<ParcelType>&>(p)
295 << token::SPACE << YGasLoc
296 << token::SPACE << YLiquidLoc
297 << token::SPACE << YSolidLoc;
301 os << static_cast<const ReactingParcel<ParcelType>&>(p);
302 os << YGasLoc << YLiquidLoc << YSolidLoc;
305 // Check state of Ostream
308 "Ostream& operator<<"
311 "const ReactingMultiphaseParcel<ParcelType>&"
319 // ************************************************************************* //