1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "IOstreams.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 const Cloud<parcel>& cloud,
39 Particle<parcel>(cloud, is, readFields),
43 (cloud.pMesh().lookupObject<dictionary>("thermophysicalProperties"))
44 .lookup("liquidComponents")
46 X_(liquidComponents_.size(), 0.0),
55 if (is.format() == IOstream::ASCII)
61 yDot_ = readScalar(is);
64 tTurb_ = readScalar(is);
65 liquidCore_ = readScalar(is);
66 injector_ = readScalar(is);
70 for (label j=0; j<nX; j++)
72 X_[j] = readScalar(is);
79 reinterpret_cast<char*>(&d_),
80 sizeof(d_) + sizeof(T_) + sizeof(m_) + sizeof(y_)
81 + sizeof(yDot_) + sizeof(ct_) + sizeof(ms_) + sizeof(tTurb_)
82 + sizeof(liquidCore_) + sizeof(injector_)
83 + sizeof(U_) + sizeof(Uturb_) + sizeof(n_)
88 reinterpret_cast<char*>(X_.begin()),
89 X_.size()*sizeof(scalar)
94 // Check state of Istream
95 is.check("parcel::parcel(Istream&)");
99 void Foam::parcel::readFields
109 Particle<parcel>::readFields(c);
111 IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
112 c.checkFieldIOobject(c, d);
114 IOField<scalar> T(c.fieldIOobject("T", IOobject::MUST_READ));
115 c.checkFieldIOobject(c, T);
117 IOField<scalar> m(c.fieldIOobject("m", IOobject::MUST_READ));
118 c.checkFieldIOobject(c, m);
120 IOField<scalar> y(c.fieldIOobject("y", IOobject::MUST_READ));
121 c.checkFieldIOobject(c, y);
123 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::MUST_READ));
124 c.checkFieldIOobject(c, yDot);
126 IOField<scalar> ct(c.fieldIOobject("ct", IOobject::MUST_READ));
127 c.checkFieldIOobject(c, ct);
129 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::MUST_READ));
130 c.checkFieldIOobject(c, ms);
132 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::MUST_READ));
133 c.checkFieldIOobject(c, tTurb);
135 IOField<scalar> liquidCore
137 c.fieldIOobject("liquidCore", IOobject::MUST_READ)
139 c.checkFieldIOobject(c, liquidCore);
141 IOField<scalar> injector(c.fieldIOobject("injector", IOobject::MUST_READ));
142 c.checkFieldIOobject(c, injector);
144 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
145 c.checkFieldIOobject(c, U);
147 IOField<vector> Uturb(c.fieldIOobject("Uturb", IOobject::MUST_READ));
148 c.checkFieldIOobject(c, Uturb);
150 IOField<vector> n(c.fieldIOobject("n", IOobject::MUST_READ));
151 c.checkFieldIOobject(c, n);
154 forAllIter(Cloud<parcel>, c, iter)
166 p.liquidCore_ = liquidCore[i];
167 p.injector_ = injector[i];
176 // read the liquid molar fractions
179 Cloud<parcel>::const_iterator iter = c.begin();
180 const parcel& p0 = iter();
182 label nX = p0.X().size();
183 const List<word>& names = p0.liquidNames();
185 for (label j=0; j<nX; j++)
187 IOField<scalar> X(c.fieldIOobject(names[j], IOobject::MUST_READ));
190 forAllIter(Cloud<parcel>, c, iter)
200 void Foam::parcel::writeFields
202 const Cloud<parcel>& c
205 Particle<parcel>::writeFields(c);
209 IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
210 IOField<scalar> T(c.fieldIOobject("T", IOobject::NO_READ), np);
211 IOField<scalar> m(c.fieldIOobject("m", IOobject::NO_READ), np);
212 IOField<scalar> y(c.fieldIOobject("y", IOobject::NO_READ), np);
213 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::NO_READ), np);
214 IOField<scalar> ct(c.fieldIOobject("ct", IOobject::NO_READ), np);
215 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::NO_READ), np);
216 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::NO_READ), np);
217 IOField<scalar> liquidCore
219 c.fieldIOobject("liquidCore", IOobject::NO_READ),
222 IOField<scalar> injector
224 c.fieldIOobject("injector", IOobject::NO_READ),
227 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
228 IOField<vector> Uturb(c.fieldIOobject("Uturb", IOobject::NO_READ), np);
229 IOField<vector> n(c.fieldIOobject("n", IOobject::NO_READ), np);
232 forAllConstIter(Cloud<parcel>, c, iter)
234 const parcel& p = iter();
244 liquidCore[i] = p.liquidCore_;
245 injector[i] = p.injector_;
269 // write the liquid molar fractions
272 Cloud<parcel>::const_iterator iter = c.begin();
273 const parcel& p0 = iter();
275 label nX = p0.X().size();
276 const List<word>& names = p0.liquidNames();
278 for (label j=0; j<nX; j++)
280 IOField<scalar> X(c.fieldIOobject(names[j], IOobject::NO_READ), np);
283 forAllConstIter(Cloud<parcel>, c, iter)
285 const parcel& p = iter();
295 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
297 Foam::Ostream& Foam::operator<<(Ostream& os, const parcel& p)
300 if (os.format() == IOstream::ASCII)
302 os << static_cast<const Particle<parcel>&>(p)
303 << token::SPACE << p.d_
304 << token::SPACE << p.T_
305 << token::SPACE << p.m_
306 << token::SPACE << p.y_
307 << token::SPACE << p.yDot_
308 << token::SPACE << p.ct_
309 << token::SPACE << p.ms_
310 << token::SPACE << p.tTurb_
311 << token::SPACE << p.liquidCore_
312 << token::SPACE << p.injector_
313 << token::SPACE << p.U_
314 << token::SPACE << p.Uturb_
315 << token::SPACE << p.n_
316 << token::SPACE << p.X_;
320 os << static_cast<const Particle<parcel>&>(p);
323 reinterpret_cast<const char*>(&p.d_),
324 sizeof(p.d_) + sizeof(p.T_) + sizeof(p.m_) + sizeof(p.y_)
325 + sizeof(p.yDot_) + sizeof(p.ct_) + sizeof(p.ms_) + sizeof(p.tTurb_)
326 + sizeof(p.liquidCore_) + sizeof(p.injector_)
327 + sizeof(p.U_) + sizeof(p.Uturb_) + sizeof(p.n_)
332 reinterpret_cast<const char*>(p.X_.begin()),
333 p.X_.size()*sizeof(scalar)
337 // Check state of Ostream
338 os.check("Ostream& operator<<(Ostream&, const parcel&)");
344 // ************************************************************************* //