1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, 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 ParcelType::propHeader
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 template<class ParcelType>
42 Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
49 ParcelType(mesh, is, readFields),
57 DynamicList<scalar> Yg;
58 DynamicList<scalar> Yl;
59 DynamicList<scalar> Ys;
64 YLiquid_.transfer(Yl);
67 // scale the mass fractions
68 const scalarField& YMix = this->Y_;
69 YGas_ /= YMix[GAS] + ROOTVSMALL;
70 YLiquid_ /= YMix[LIQ] + ROOTVSMALL;
71 YSolid_ /= YMix[SLD] + ROOTVSMALL;
74 // Check state of Istream
77 "ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel"
87 template<class ParcelType>
88 template<class CloudType>
89 void Foam::ReactingMultiphaseParcel<ParcelType>::readFields(CloudType& c)
96 ParcelType::readFields(c);
100 template<class ParcelType>
101 template<class CloudType, class CompositionType>
102 void Foam::ReactingMultiphaseParcel<ParcelType>::readFields
105 const CompositionType& compModel
113 ParcelType::readFields(c, compModel);
115 // Get names and sizes for each Y...
116 const label idGas = compModel.idGas();
117 const wordList& gasNames = compModel.componentNames(idGas);
118 const label idLiquid = compModel.idLiquid();
119 const wordList& liquidNames = compModel.componentNames(idLiquid);
120 const label idSolid = compModel.idSolid();
121 const wordList& solidNames = compModel.componentNames(idSolid);
122 const wordList& stateLabels = compModel.stateLabels();
124 // Set storage for each Y... for each parcel
125 forAllIter(typename Cloud<ReactingMultiphaseParcel<ParcelType> >, c, iter)
127 ReactingMultiphaseParcel<ParcelType>& p = iter();
128 p.YGas_.setSize(gasNames.size(), 0.0);
129 p.YLiquid_.setSize(liquidNames.size(), 0.0);
130 p.YSolid_.setSize(solidNames.size(), 0.0);
133 // Populate YGas for each parcel
140 "Y" + gasNames[j] + stateLabels[idGas],
148 typename Cloud<ReactingMultiphaseParcel<ParcelType> >,
153 ReactingMultiphaseParcel<ParcelType>& p = iter();
154 p.YGas_[j] = YGas[i++]/(p.Y()[GAS] + ROOTVSMALL);
157 // Populate YLiquid for each parcel
158 forAll(liquidNames, j)
160 IOField<scalar> YLiquid
164 "Y" + liquidNames[j] + stateLabels[idLiquid],
172 typename Cloud<ReactingMultiphaseParcel<ParcelType> >,
177 ReactingMultiphaseParcel<ParcelType>& p = iter();
178 p.YLiquid_[j] = YLiquid[i++]/(p.Y()[LIQ] + ROOTVSMALL);
181 // Populate YSolid for each parcel
182 forAll(solidNames, j)
184 IOField<scalar> YSolid
188 "Y" + solidNames[j] + stateLabels[idSolid],
196 typename Cloud<ReactingMultiphaseParcel<ParcelType> >,
201 ReactingMultiphaseParcel<ParcelType>& p = iter();
202 p.YSolid_[j] = YSolid[i++]/(p.Y()[SLD] + ROOTVSMALL);
208 template<class ParcelType>
209 template<class CloudType>
210 void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields(const CloudType& c)
212 ParcelType::writeFields(c);
216 template<class ParcelType>
217 template<class CloudType, class CompositionType>
218 void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
221 const CompositionType& compModel
224 ParcelType::writeFields(c, compModel);
228 // Write the composition fractions
231 const wordList& stateLabels = compModel.stateLabels();
233 const label idGas = compModel.idGas();
234 const wordList& gasNames = compModel.componentNames(idGas);
241 "Y" + gasNames[j] + stateLabels[idGas],
250 typename Cloud<ReactingMultiphaseParcel<ParcelType> >,
255 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
256 YGas[i++] = p0.YGas()[j]*p0.Y()[GAS];
262 const label idLiquid = compModel.idLiquid();
263 const wordList& liquidNames = compModel.componentNames(idLiquid);
264 forAll(liquidNames, j)
266 IOField<scalar> YLiquid
270 "Y" + liquidNames[j] + stateLabels[idLiquid],
279 typename Cloud<ReactingMultiphaseParcel<ParcelType> >,
284 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
285 YLiquid[i++] = p0.YLiquid()[j]*p0.Y()[LIQ];
291 const label idSolid = compModel.idSolid();
292 const wordList& solidNames = compModel.componentNames(idSolid);
293 forAll(solidNames, j)
295 IOField<scalar> YSolid
299 "Y" + solidNames[j] + stateLabels[idSolid],
308 typename Cloud<ReactingMultiphaseParcel<ParcelType> >,
313 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
314 YSolid[i++] = p0.YSolid()[j]*p0.Y()[SLD];
323 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
325 template<class ParcelType>
326 Foam::Ostream& Foam::operator<<
329 const ReactingMultiphaseParcel<ParcelType>& p
332 scalarField YGasLoc(p.YGas()*p.Y()[0]);
333 scalarField YLiquidLoc(p.YLiquid()*p.Y()[1]);
334 scalarField YSolidLoc(p.YSolid()*p.Y()[2]);
335 if (os.format() == IOstream::ASCII)
337 os << static_cast<const ParcelType&>(p)
338 << token::SPACE << YGasLoc
339 << token::SPACE << YLiquidLoc
340 << token::SPACE << YSolidLoc;
344 os << static_cast<const ParcelType&>(p);
345 os << YGasLoc << YLiquidLoc << YSolidLoc;
348 // Check state of Ostream
351 "Ostream& operator<<"
354 "const ReactingMultiphaseParcel<ParcelType>&"
362 // ************************************************************************* //