1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "IOstreams.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 particle(mesh, is, readFields),
43 mesh.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(Cloud<parcel>& c)
106 particle::readFields(c);
108 IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
109 c.checkFieldIOobject(c, d);
111 IOField<scalar> T(c.fieldIOobject("T", IOobject::MUST_READ));
112 c.checkFieldIOobject(c, T);
114 IOField<scalar> m(c.fieldIOobject("m", IOobject::MUST_READ));
115 c.checkFieldIOobject(c, m);
117 IOField<scalar> y(c.fieldIOobject("y", IOobject::MUST_READ));
118 c.checkFieldIOobject(c, y);
120 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::MUST_READ));
121 c.checkFieldIOobject(c, yDot);
123 IOField<scalar> ct(c.fieldIOobject("ct", IOobject::MUST_READ));
124 c.checkFieldIOobject(c, ct);
126 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::MUST_READ));
127 c.checkFieldIOobject(c, ms);
129 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::MUST_READ));
130 c.checkFieldIOobject(c, tTurb);
132 IOField<scalar> liquidCore
134 c.fieldIOobject("liquidCore", IOobject::MUST_READ)
136 c.checkFieldIOobject(c, liquidCore);
138 IOField<scalar> injector(c.fieldIOobject("injector", IOobject::MUST_READ));
139 c.checkFieldIOobject(c, injector);
141 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
142 c.checkFieldIOobject(c, U);
144 IOField<vector> Uturb(c.fieldIOobject("Uturb", IOobject::MUST_READ));
145 c.checkFieldIOobject(c, Uturb);
147 IOField<vector> n(c.fieldIOobject("n", IOobject::MUST_READ));
148 c.checkFieldIOobject(c, n);
151 forAllIter(Cloud<parcel>, c, iter)
163 p.liquidCore_ = liquidCore[i];
164 p.injector_ = injector[i];
173 // read the liquid molar fractions
176 Cloud<parcel>::const_iterator iter = c.begin();
177 const parcel& p0 = iter();
179 label nX = p0.X().size();
180 const List<word>& names = p0.liquidNames();
182 for (label j=0; j<nX; j++)
184 IOField<scalar> X(c.fieldIOobject(names[j], IOobject::MUST_READ));
187 forAllIter(Cloud<parcel>, c, iter)
197 void Foam::parcel::writeFields(const Cloud<parcel>& c)
199 particle::writeFields(c);
203 IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
204 IOField<scalar> T(c.fieldIOobject("T", IOobject::NO_READ), np);
205 IOField<scalar> m(c.fieldIOobject("m", IOobject::NO_READ), np);
206 IOField<scalar> y(c.fieldIOobject("y", IOobject::NO_READ), np);
207 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::NO_READ), np);
208 IOField<scalar> ct(c.fieldIOobject("ct", IOobject::NO_READ), np);
209 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::NO_READ), np);
210 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::NO_READ), np);
211 IOField<scalar> liquidCore
213 c.fieldIOobject("liquidCore", IOobject::NO_READ),
216 IOField<scalar> injector
218 c.fieldIOobject("injector", IOobject::NO_READ),
221 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
222 IOField<vector> Uturb(c.fieldIOobject("Uturb", IOobject::NO_READ), np);
223 IOField<vector> n(c.fieldIOobject("n", IOobject::NO_READ), np);
226 forAllConstIter(Cloud<parcel>, c, iter)
228 const parcel& p = iter();
238 liquidCore[i] = p.liquidCore_;
239 injector[i] = p.injector_;
263 // write the liquid molar fractions
266 Cloud<parcel>::const_iterator iter = c.begin();
267 const parcel& p0 = iter();
269 label nX = p0.X().size();
270 const List<word>& names = p0.liquidNames();
272 for (label j=0; j<nX; j++)
274 IOField<scalar> X(c.fieldIOobject(names[j], IOobject::NO_READ), np);
277 forAllConstIter(Cloud<parcel>, c, iter)
279 const parcel& p = iter();
289 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
291 Foam::Ostream& Foam::operator<<(Ostream& os, const parcel& p)
293 if (os.format() == IOstream::ASCII)
295 os << static_cast<const particle&>(p)
296 << token::SPACE << p.d_
297 << token::SPACE << p.T_
298 << token::SPACE << p.m_
299 << token::SPACE << p.y_
300 << token::SPACE << p.yDot_
301 << token::SPACE << p.ct_
302 << token::SPACE << p.ms_
303 << token::SPACE << p.tTurb_
304 << token::SPACE << p.liquidCore_
305 << token::SPACE << p.injector_
306 << token::SPACE << p.U_
307 << token::SPACE << p.Uturb_
308 << token::SPACE << p.n_
309 << token::SPACE << p.X_;
313 os << static_cast<const particle>(p);
316 reinterpret_cast<const char*>(&p.d_),
317 sizeof(p.d_) + sizeof(p.T_) + sizeof(p.m_) + sizeof(p.y_)
318 + sizeof(p.yDot_) + sizeof(p.ct_) + sizeof(p.ms_) + sizeof(p.tTurb_)
319 + sizeof(p.liquidCore_) + sizeof(p.injector_)
320 + sizeof(p.U_) + sizeof(p.Uturb_) + sizeof(p.n_)
325 reinterpret_cast<const char*>(p.X_.begin()),
326 p.X_.size()*sizeof(scalar)
330 // Check state of Ostream
331 os.check("Ostream& operator<<(Ostream&, const parcel&)");
337 // ************************************************************************* //