1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "IOstreams.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 const Cloud<parcel>& cloud,
38 Particle<parcel>(cloud, is, readFields),
42 (cloud.pMesh().lookupObject<dictionary>("thermophysicalProperties"))
43 .lookup("liquidComponents")
45 X_(liquidComponents_.size(), 0.0),
54 if (is.format() == IOstream::ASCII)
60 yDot_ = readScalar(is);
63 tTurb_ = readScalar(is);
64 liquidCore_ = readScalar(is);
65 injector_ = readScalar(is);
69 for (label j=0; j<nX; j++)
71 X_[j] = readScalar(is);
78 reinterpret_cast<char*>(&d_),
79 sizeof(d_) + sizeof(T_) + sizeof(m_) + sizeof(y_)
80 + sizeof(yDot_) + sizeof(ct_) + sizeof(ms_) + sizeof(tTurb_)
81 + sizeof(liquidCore_) + sizeof(injector_)
82 + sizeof(U_) + sizeof(Uturb_) + sizeof(n_)
87 reinterpret_cast<char*>(X_.begin()),
88 X_.size()*sizeof(scalar)
93 // Check state of Istream
94 is.check("parcel::parcel(Istream&)");
98 void Foam::parcel::readFields
108 Particle<parcel>::readFields(c);
110 IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
111 c.checkFieldIOobject(c, d);
113 IOField<scalar> T(c.fieldIOobject("T", IOobject::MUST_READ));
114 c.checkFieldIOobject(c, T);
116 IOField<scalar> m(c.fieldIOobject("m", IOobject::MUST_READ));
117 c.checkFieldIOobject(c, m);
119 IOField<scalar> y(c.fieldIOobject("y", IOobject::MUST_READ));
120 c.checkFieldIOobject(c, y);
122 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::MUST_READ));
123 c.checkFieldIOobject(c, yDot);
125 IOField<scalar> ct(c.fieldIOobject("ct", IOobject::MUST_READ));
126 c.checkFieldIOobject(c, ct);
128 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::MUST_READ));
129 c.checkFieldIOobject(c, ms);
131 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::MUST_READ));
132 c.checkFieldIOobject(c, tTurb);
134 IOField<scalar> liquidCore
136 c.fieldIOobject("liquidCore", IOobject::MUST_READ)
138 c.checkFieldIOobject(c, liquidCore);
140 IOField<scalar> injector(c.fieldIOobject("injector", IOobject::MUST_READ));
141 c.checkFieldIOobject(c, injector);
143 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
144 c.checkFieldIOobject(c, U);
146 IOField<vector> Uturb(c.fieldIOobject("Uturb", IOobject::MUST_READ));
147 c.checkFieldIOobject(c, Uturb);
149 IOField<vector> n(c.fieldIOobject("n", IOobject::MUST_READ));
150 c.checkFieldIOobject(c, n);
153 forAllIter(Cloud<parcel>, c, iter)
165 p.liquidCore_ = liquidCore[i];
166 p.injector_ = injector[i];
175 // read the liquid molar fractions
178 Cloud<parcel>::const_iterator iter = c.begin();
179 const parcel& p0 = iter();
181 label nX = p0.X().size();
182 const List<word>& names = p0.liquidNames();
184 for (label j=0; j<nX; j++)
186 IOField<scalar> X(c.fieldIOobject(names[j], IOobject::MUST_READ));
189 forAllIter(Cloud<parcel>, c, iter)
199 void Foam::parcel::writeFields
201 const Cloud<parcel>& c
204 Particle<parcel>::writeFields(c);
208 IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
209 IOField<scalar> T(c.fieldIOobject("T", IOobject::NO_READ), np);
210 IOField<scalar> m(c.fieldIOobject("m", IOobject::NO_READ), np);
211 IOField<scalar> y(c.fieldIOobject("y", IOobject::NO_READ), np);
212 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::NO_READ), np);
213 IOField<scalar> ct(c.fieldIOobject("ct", IOobject::NO_READ), np);
214 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::NO_READ), np);
215 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::NO_READ), np);
216 IOField<scalar> liquidCore
218 c.fieldIOobject("liquidCore", IOobject::NO_READ),
221 IOField<scalar> injector
223 c.fieldIOobject("injector", IOobject::NO_READ),
226 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
227 IOField<vector> Uturb(c.fieldIOobject("Uturb", IOobject::NO_READ), np);
228 IOField<vector> n(c.fieldIOobject("n", IOobject::NO_READ), np);
231 forAllConstIter(Cloud<parcel>, c, iter)
233 const parcel& p = iter();
243 liquidCore[i] = p.liquidCore_;
244 injector[i] = p.injector_;
268 // write the liquid molar fractions
271 Cloud<parcel>::const_iterator iter = c.begin();
272 const parcel& p0 = iter();
274 label nX = p0.X().size();
275 const List<word>& names = p0.liquidNames();
277 for (label j=0; j<nX; j++)
279 IOField<scalar> X(c.fieldIOobject(names[j], IOobject::NO_READ), np);
282 forAllConstIter(Cloud<parcel>, c, iter)
284 const parcel& p = iter();
294 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
296 Foam::Ostream& Foam::operator<<(Ostream& os, const parcel& p)
299 if (os.format() == IOstream::ASCII)
301 os << static_cast<const Particle<parcel>&>(p)
302 << token::SPACE << p.d_
303 << token::SPACE << p.T_
304 << token::SPACE << p.m_
305 << token::SPACE << p.y_
306 << token::SPACE << p.yDot_
307 << token::SPACE << p.ct_
308 << token::SPACE << p.ms_
309 << token::SPACE << p.tTurb_
310 << token::SPACE << p.liquidCore_
311 << token::SPACE << p.injector_
312 << token::SPACE << p.U_
313 << token::SPACE << p.Uturb_
314 << token::SPACE << p.n_
315 << token::SPACE << p.X_;
319 os << static_cast<const Particle<parcel>&>(p);
322 reinterpret_cast<const char*>(&p.d_),
323 sizeof(p.d_) + sizeof(p.T_) + sizeof(p.m_) + sizeof(p.y_)
324 + sizeof(p.yDot_) + sizeof(p.ct_) + sizeof(p.ms_) + sizeof(p.tTurb_)
325 + sizeof(p.liquidCore_) + sizeof(p.injector_)
326 + sizeof(p.U_) + sizeof(p.Uturb_) + sizeof(p.n_)
331 reinterpret_cast<const char*>(p.X_.begin()),
332 p.X_.size()*sizeof(scalar)
336 // Check state of Ostream
337 os.check("Ostream& operator<<(Ostream&, const parcel&)");
343 // ************************************************************************* //