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