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 "parcel.H"
00027 #include <OpenFOAM/IOstreams.H>
00028
00029
00030
00031 Foam::parcel::parcel
00032 (
00033 const Cloud<parcel>& cloud,
00034 Istream& is,
00035 bool readFields
00036 )
00037 :
00038 Particle<parcel>(cloud, is, readFields),
00039
00040 liquidComponents_
00041 (
00042 (cloud.pMesh().lookupObject<dictionary>("thermophysicalProperties"))
00043 .lookup("liquidComponents")
00044 ),
00045 X_(liquidComponents_.size(), 0.0),
00046
00047 tMom_(GREAT)
00048 {
00049
00050 label nX = X_.size();
00051
00052 if (readFields)
00053 {
00054 if (is.format() == IOstream::ASCII)
00055 {
00056 d_ = readScalar(is);
00057 T_ = readScalar(is);
00058 m_ = readScalar(is);
00059 y_ = readScalar(is);
00060 yDot_ = readScalar(is);
00061 ct_ = readScalar(is);
00062 ms_ = readScalar(is);
00063 tTurb_ = readScalar(is);
00064 liquidCore_ = readScalar(is);
00065 injector_ = readScalar(is);
00066 is >> U_;
00067 is >> Uturb_;
00068 is >> n_;
00069 for (label j=0; j<nX; j++)
00070 {
00071 X_[j] = readScalar(is);
00072 }
00073 }
00074 else
00075 {
00076 is.read
00077 (
00078 reinterpret_cast<char*>(&d_),
00079 sizeof(d_) + sizeof(T_) + sizeof(m_) + sizeof(y_)
00080 + sizeof(yDot_) + sizeof(ct_) + sizeof(ms_) + sizeof(tTurb_)
00081 + sizeof(liquidCore_) + sizeof(injector_)
00082 + sizeof(U_) + sizeof(Uturb_) + sizeof(n_)
00083 );
00084
00085 is.read
00086 (
00087 reinterpret_cast<char*>(X_.begin()),
00088 X_.size()*sizeof(scalar)
00089 );
00090 }
00091 }
00092
00093
00094 is.check("parcel::parcel(Istream&)");
00095 }
00096
00097
00098 void Foam::parcel::readFields
00099 (
00100 Cloud<parcel>& c
00101 )
00102 {
00103 if (!c.size())
00104 {
00105 return;
00106 }
00107
00108 Particle<parcel>::readFields(c);
00109
00110 IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
00111 c.checkFieldIOobject(c, d);
00112
00113 IOField<scalar> T(c.fieldIOobject("T", IOobject::MUST_READ));
00114 c.checkFieldIOobject(c, T);
00115
00116 IOField<scalar> m(c.fieldIOobject("m", IOobject::MUST_READ));
00117 c.checkFieldIOobject(c, m);
00118
00119 IOField<scalar> y(c.fieldIOobject("y", IOobject::MUST_READ));
00120 c.checkFieldIOobject(c, y);
00121
00122 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::MUST_READ));
00123 c.checkFieldIOobject(c, yDot);
00124
00125 IOField<scalar> ct(c.fieldIOobject("ct", IOobject::MUST_READ));
00126 c.checkFieldIOobject(c, ct);
00127
00128 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::MUST_READ));
00129 c.checkFieldIOobject(c, ms);
00130
00131 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::MUST_READ));
00132 c.checkFieldIOobject(c, tTurb);
00133
00134 IOField<scalar> liquidCore
00135 (
00136 c.fieldIOobject("liquidCore", IOobject::MUST_READ)
00137 );
00138 c.checkFieldIOobject(c, liquidCore);
00139
00140 IOField<scalar> injector(c.fieldIOobject("injector", IOobject::MUST_READ));
00141 c.checkFieldIOobject(c, injector);
00142
00143 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
00144 c.checkFieldIOobject(c, U);
00145
00146 IOField<vector> Uturb(c.fieldIOobject("Uturb", IOobject::MUST_READ));
00147 c.checkFieldIOobject(c, Uturb);
00148
00149 IOField<vector> n(c.fieldIOobject("n", IOobject::MUST_READ));
00150 c.checkFieldIOobject(c, n);
00151
00152 label i = 0;
00153 forAllIter(Cloud<parcel>, c, iter)
00154 {
00155 parcel& p = iter();
00156
00157 p.d_ = d[i];
00158 p.T_ = T[i];
00159 p.m_ = m[i];
00160 p.y_ = y[i];
00161 p.yDot_ = yDot[i];
00162 p.ct_ = ct[i];
00163 p.ms_ = ms[i];
00164 p.tTurb_ = tTurb[i];
00165 p.liquidCore_ = liquidCore[i];
00166 p.injector_ = injector[i];
00167
00168 p.U_ = U[i];
00169 p.Uturb_ = Uturb[i];
00170 p.n_ = n[i];
00171
00172 i++;
00173 }
00174
00175
00176 if (c.size())
00177 {
00178 Cloud<parcel>::const_iterator iter = c.begin();
00179 const parcel& p0 = iter();
00180
00181 label nX = p0.X().size();
00182 const List<word>& names = p0.liquidNames();
00183
00184 for (label j=0; j<nX; j++)
00185 {
00186 IOField<scalar> X(c.fieldIOobject(names[j], IOobject::MUST_READ));
00187
00188 label i = 0;
00189 forAllIter(Cloud<parcel>, c, iter)
00190 {
00191 parcel& p = iter();
00192 p.X_[j] = X[i++];
00193 }
00194 }
00195 }
00196 }
00197
00198
00199 void Foam::parcel::writeFields
00200 (
00201 const Cloud<parcel>& c
00202 )
00203 {
00204 Particle<parcel>::writeFields(c);
00205
00206 label np = c.size();
00207
00208 IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
00209 IOField<scalar> T(c.fieldIOobject("T", IOobject::NO_READ), np);
00210 IOField<scalar> m(c.fieldIOobject("m", IOobject::NO_READ), np);
00211 IOField<scalar> y(c.fieldIOobject("y", IOobject::NO_READ), np);
00212 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::NO_READ), np);
00213 IOField<scalar> ct(c.fieldIOobject("ct", IOobject::NO_READ), np);
00214 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::NO_READ), np);
00215 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::NO_READ), np);
00216 IOField<scalar> liquidCore
00217 (
00218 c.fieldIOobject("liquidCore", IOobject::NO_READ),
00219 np
00220 );
00221 IOField<scalar> injector
00222 (
00223 c.fieldIOobject("injector", IOobject::NO_READ),
00224 np
00225 );
00226 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
00227 IOField<vector> Uturb(c.fieldIOobject("Uturb", IOobject::NO_READ), np);
00228 IOField<vector> n(c.fieldIOobject("n", IOobject::NO_READ), np);
00229
00230 label i = 0;
00231 forAllConstIter(Cloud<parcel>, c, iter)
00232 {
00233 const parcel& p = iter();
00234
00235 d[i] = p.d_;
00236 T[i] = p.T_;
00237 m[i] = p.m_;
00238 y[i] = p.y_;
00239 yDot[i] = p.yDot_;
00240 ct[i] = p.ct_;
00241 ms[i] = p.ms_;
00242 tTurb[i] = p.tTurb_;
00243 liquidCore[i] = p.liquidCore_;
00244 injector[i] = p.injector_;
00245
00246 U[i] = p.U_;
00247 Uturb[i] = p.Uturb_;
00248 n[i] = p.n_;
00249
00250 i++;
00251 }
00252
00253 d.write();
00254 T.write();
00255 m.write();
00256 y.write();
00257 yDot.write();
00258 ct.write();
00259 ms.write();
00260 tTurb.write();
00261 liquidCore.write();
00262 injector.write();
00263
00264 U.write();
00265 Uturb.write();
00266 n.write();
00267
00268
00269 if (np > 0)
00270 {
00271 Cloud<parcel>::const_iterator iter = c.begin();
00272 const parcel& p0 = iter();
00273
00274 label nX = p0.X().size();
00275 const List<word>& names = p0.liquidNames();
00276
00277 for (label j=0; j<nX; j++)
00278 {
00279 IOField<scalar> X(c.fieldIOobject(names[j], IOobject::NO_READ), np);
00280
00281 label i = 0;
00282 forAllConstIter(Cloud<parcel>, c, iter)
00283 {
00284 const parcel& p = iter();
00285 X[i++] = p.X()[j];
00286 }
00287
00288 X.write();
00289 }
00290 }
00291 }
00292
00293
00294
00295
00296 Foam::Ostream& Foam::operator<<(Ostream& os, const parcel& p)
00297 {
00298
00299 if (os.format() == IOstream::ASCII)
00300 {
00301 os << static_cast<const Particle<parcel>&>(p)
00302 << token::SPACE << p.d_
00303 << token::SPACE << p.T_
00304 << token::SPACE << p.m_
00305 << token::SPACE << p.y_
00306 << token::SPACE << p.yDot_
00307 << token::SPACE << p.ct_
00308 << token::SPACE << p.ms_
00309 << token::SPACE << p.tTurb_
00310 << token::SPACE << p.liquidCore_
00311 << token::SPACE << p.injector_
00312 << token::SPACE << p.U_
00313 << token::SPACE << p.Uturb_
00314 << token::SPACE << p.n_
00315 << token::SPACE << p.X_;
00316 }
00317 else
00318 {
00319 os << static_cast<const Particle<parcel>&>(p);
00320 os.write
00321 (
00322 reinterpret_cast<const char*>(&p.d_),
00323 sizeof(p.d_) + sizeof(p.T_) + sizeof(p.m_) + sizeof(p.y_)
00324 + sizeof(p.yDot_) + sizeof(p.ct_) + sizeof(p.ms_) + sizeof(p.tTurb_)
00325 + sizeof(p.liquidCore_) + sizeof(p.injector_)
00326 + sizeof(p.U_) + sizeof(p.Uturb_) + sizeof(p.n_)
00327 );
00328
00329 os.write
00330 (
00331 reinterpret_cast<const char*>(p.X_.begin()),
00332 p.X_.size()*sizeof(scalar)
00333 );
00334 }
00335
00336
00337 os.check("Ostream& operator<<(Ostream&, const parcel&)");
00338
00339 return os;
00340 }
00341
00342
00343