Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "ReactingMultiphaseParcel.H"
00027 #include <OpenFOAM/IOstreams.H>
00028
00029
00030
00031 template <class ParcelType>
00032 Foam::string Foam::ReactingMultiphaseParcel<ParcelType>::propHeader =
00033 ReactingParcel<ParcelType>::propHeader
00034 + " nGas(Y1..YN)"
00035 + " nLiquid(Y1..YN)"
00036 + " nSolid(Y1..YN)";
00037
00038
00039
00040
00041 template<class ParcelType>
00042 Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
00043 (
00044 const Cloud<ParcelType>& cloud,
00045 Istream& is,
00046 bool readFields
00047 )
00048 :
00049 ReactingParcel<ParcelType>(cloud, is, readFields),
00050 YGas_(0),
00051 YLiquid_(0),
00052 YSolid_(0),
00053 canCombust_(false)
00054 {
00055 if (readFields)
00056 {
00057 const ReactingMultiphaseCloud<ParcelType>& cR =
00058 dynamic_cast<const ReactingMultiphaseCloud<ParcelType>&>(cloud);
00059
00060 const label idGas = cR.composition().idGas();
00061 const label nGas = cR.composition().componentNames(idGas).size();
00062 const label idLiquid = cR.composition().idLiquid();
00063 const label nLiquid = cR.composition().componentNames(idLiquid).size();
00064 const label idSolid = cR.composition().idGas();
00065 const label nSolid = cR.composition().componentNames(idSolid).size();
00066
00067 YGas_.setSize(nGas);
00068 YLiquid_.setSize(nLiquid);
00069 YSolid_.setSize(nSolid);
00070
00071 is >> YGas_ >> YLiquid_ >> YSolid_;
00072
00073
00074 const scalarField& YMix = this->Y_;
00075 YGas_ /= YMix[GAS] + ROOTVSMALL;
00076 YLiquid_ /= YMix[LIQ] + ROOTVSMALL;
00077 YSolid_ /= YMix[SLD] + ROOTVSMALL;
00078 }
00079
00080
00081 is.check
00082 (
00083 "ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel"
00084 "("
00085 "const Cloud<ParcelType>&, "
00086 "Istream&, "
00087 "bool"
00088 ")"
00089 );
00090 }
00091
00092
00093 template<class ParcelType>
00094 void Foam::ReactingMultiphaseParcel<ParcelType>::readFields
00095 (
00096 Cloud<ParcelType>& cIn
00097 )
00098 {
00099 if (!cIn.size())
00100 {
00101 return;
00102 }
00103
00104 ReactingMultiphaseCloud<ParcelType>& c =
00105 dynamic_cast<ReactingMultiphaseCloud<ParcelType>&>(cIn);
00106
00107 ReactingParcel<ParcelType>::readFields(c);
00108
00109
00110 const label idGas = c.composition().idGas();
00111 const wordList& gasNames = c.composition().componentNames(idGas);
00112 const label idLiquid = c.composition().idLiquid();
00113 const wordList& liquidNames = c.composition().componentNames(idLiquid);
00114 const label idSolid = c.composition().idSolid();
00115 const wordList& solidNames = c.composition().componentNames(idSolid);
00116 const wordList& stateLabels = c.composition().stateLabels();
00117
00118
00119 forAllIter(typename Cloud<ParcelType>, c, iter)
00120 {
00121 ReactingMultiphaseParcel<ParcelType>& p = iter();
00122 p.YGas_.setSize(gasNames.size(), 0.0);
00123 p.YLiquid_.setSize(liquidNames.size(), 0.0);
00124 p.YSolid_.setSize(solidNames.size(), 0.0);
00125 }
00126
00127
00128 forAll(gasNames, j)
00129 {
00130 IOField<scalar> YGas
00131 (
00132 c.fieldIOobject
00133 (
00134 "Y" + gasNames[j] + stateLabels[idGas],
00135 IOobject::MUST_READ
00136 )
00137 );
00138
00139 label i = 0;
00140 forAllIter(typename Cloud<ParcelType>, c, iter)
00141 {
00142 ReactingMultiphaseParcel<ParcelType>& p = iter();
00143 p.YGas_[j] = YGas[i++]/(p.Y()[GAS] + ROOTVSMALL);
00144 }
00145 }
00146
00147 forAll(liquidNames, j)
00148 {
00149 IOField<scalar> YLiquid
00150 (
00151 c.fieldIOobject
00152 (
00153 "Y" + liquidNames[j] + stateLabels[idLiquid],
00154 IOobject::MUST_READ
00155 )
00156 );
00157
00158 label i = 0;
00159 forAllIter(typename Cloud<ParcelType>, c, iter)
00160 {
00161 ReactingMultiphaseParcel<ParcelType>& p = iter();
00162 p.YLiquid_[j] = YLiquid[i++]/(p.Y()[LIQ] + ROOTVSMALL);
00163 }
00164 }
00165
00166 forAll(solidNames, j)
00167 {
00168 IOField<scalar> YSolid
00169 (
00170 c.fieldIOobject
00171 (
00172 "Y" + solidNames[j] + stateLabels[idSolid],
00173 IOobject::MUST_READ
00174 )
00175 );
00176
00177 label i = 0;
00178 forAllIter(typename Cloud<ParcelType>, c, iter)
00179 {
00180 ReactingMultiphaseParcel<ParcelType>& p = iter();
00181 p.YSolid_[j] = YSolid[i++]/(p.Y()[SLD] + ROOTVSMALL);
00182 }
00183 }
00184 }
00185
00186
00187 template<class ParcelType>
00188 void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
00189 (
00190 const Cloud<ParcelType>& cIn
00191 )
00192 {
00193 const ReactingMultiphaseCloud<ParcelType>& c =
00194 dynamic_cast<const ReactingMultiphaseCloud<ParcelType>&>(cIn);
00195
00196 ReactingParcel<ParcelType>::writeFields(c);
00197
00198 label np = c.size();
00199
00200
00201 if (np > 0)
00202 {
00203 const wordList& stateLabels = c.composition().stateLabels();
00204
00205 const label idGas = c.composition().idGas();
00206 const wordList& gasNames = c.composition().componentNames(idGas);
00207 forAll(gasNames, j)
00208 {
00209 IOField<scalar> YGas
00210 (
00211 c.fieldIOobject
00212 (
00213 "Y" + gasNames[j] + stateLabels[idGas],
00214 IOobject::NO_READ
00215 ),
00216 np
00217 );
00218
00219 label i = 0;
00220 forAllConstIter(typename Cloud<ParcelType>, c, iter)
00221 {
00222 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
00223 YGas[i++] = p0.YGas()[j]*p0.Y()[GAS];
00224 }
00225
00226 YGas.write();
00227 }
00228
00229 const label idLiquid = c.composition().idLiquid();
00230 const wordList& liquidNames = c.composition().componentNames(idLiquid);
00231 forAll(liquidNames, j)
00232 {
00233 IOField<scalar> YLiquid
00234 (
00235 c.fieldIOobject
00236 (
00237 "Y" + liquidNames[j] + stateLabels[idLiquid],
00238 IOobject::NO_READ
00239 ),
00240 np
00241 );
00242
00243 label i = 0;
00244 forAllConstIter(typename Cloud<ParcelType>, c, iter)
00245 {
00246 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
00247 YLiquid[i++] = p0.YLiquid()[j]*p0.Y()[LIQ];
00248 }
00249
00250 YLiquid.write();
00251 }
00252
00253 const label idSolid = c.composition().idSolid();
00254 const wordList& solidNames = c.composition().componentNames(idSolid);
00255 forAll(solidNames, j)
00256 {
00257 IOField<scalar> YSolid
00258 (
00259 c.fieldIOobject
00260 (
00261 "Y" + solidNames[j] + stateLabels[idSolid],
00262 IOobject::NO_READ
00263 ),
00264 np
00265 );
00266
00267 label i = 0;
00268 forAllConstIter(typename Cloud<ParcelType>, c, iter)
00269 {
00270 const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
00271 YSolid[i++] = p0.YSolid()[j]*p0.Y()[SLD];
00272 }
00273
00274 YSolid.write();
00275 }
00276 }
00277 }
00278
00279
00280
00281
00282 template<class ParcelType>
00283 Foam::Ostream& Foam::operator<<
00284 (
00285 Ostream& os,
00286 const ReactingMultiphaseParcel<ParcelType>& p
00287 )
00288 {
00289 scalarField YGasLoc = p.YGas()*p.Y()[0];
00290 scalarField YLiquidLoc = p.YLiquid()*p.Y()[1];
00291 scalarField YSolidLoc = p.YSolid()*p.Y()[2];
00292 if (os.format() == IOstream::ASCII)
00293 {
00294 os << static_cast<const ReactingParcel<ParcelType>&>(p)
00295 << token::SPACE << YGasLoc
00296 << token::SPACE << YLiquidLoc
00297 << token::SPACE << YSolidLoc;
00298 }
00299 else
00300 {
00301 os << static_cast<const ReactingParcel<ParcelType>&>(p);
00302 os << YGasLoc << YLiquidLoc << YSolidLoc;
00303 }
00304
00305
00306 os.check
00307 (
00308 "Ostream& operator<<"
00309 "("
00310 "Ostream&, "
00311 "const ReactingMultiphaseParcel<ParcelType>&"
00312 ")"
00313 );
00314
00315 return os;
00316 }
00317
00318
00319