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 \*---------------------------------------------------------------------------*/
27 #include "KinematicParcel.H"
28 #include "IOstreams.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 template <class ParcelType>
35 Foam::string Foam::KinematicParcel<ParcelType>::propHeader =
36 Particle<ParcelType>::propHeader
43 + " (UTurbx UTurby UTurbz)";
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 template <class ParcelType>
49 Foam::KinematicParcel<ParcelType>::KinematicParcel
51 const Cloud<ParcelType>& cloud,
56 Particle<ParcelType>(cloud, is, readFields),
70 if (is.format() == IOstream::ASCII)
72 typeId_ = readLabel(is);
73 nParticle_ = readScalar(is);
76 rho_ = readScalar(is);
77 tTurb_ = readScalar(is);
84 reinterpret_cast<char*>(&typeId_),
96 // Check state of Istream
99 "KinematicParcel<ParcelType>::KinematicParcel"
100 "(const Cloud<ParcelType>&, Istream&, bool)"
105 template<class ParcelType>
106 void Foam::KinematicParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
113 Particle<ParcelType>::readFields(c);
115 IOField<label> typeId(c.fieldIOobject("typeId", IOobject::MUST_READ));
116 c.checkFieldIOobject(c, typeId);
119 nParticle(c.fieldIOobject("nParticle", IOobject::MUST_READ));
120 c.checkFieldIOobject(c, nParticle);
122 IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
123 c.checkFieldIOobject(c, d);
125 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
126 c.checkFieldIOobject(c, U);
128 IOField<scalar> rho(c.fieldIOobject("rho", IOobject::MUST_READ));
129 c.checkFieldIOobject(c, rho);
131 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::MUST_READ));
132 c.checkFieldIOobject(c, tTurb);
134 IOField<vector> UTurb(c.fieldIOobject("UTurb", IOobject::MUST_READ));
135 c.checkFieldIOobject(c, UTurb);
138 forAllIter(typename Cloud<ParcelType>, c, iter)
140 ParcelType& p = iter();
142 p.typeId_ = typeId[i];
143 p.nParticle_ = nParticle[i];
154 template<class ParcelType>
155 void Foam::KinematicParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
157 Particle<ParcelType>::writeFields(c);
161 IOField<label> typeId(c.fieldIOobject("typeId", IOobject::NO_READ), np);
162 IOField<scalar> nParticle
164 c.fieldIOobject("nParticle", IOobject::NO_READ),
167 IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
168 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
169 IOField<scalar> rho(c.fieldIOobject("rho", IOobject::NO_READ), np);
170 IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::NO_READ), np);
171 IOField<vector> UTurb(c.fieldIOobject("UTurb", IOobject::NO_READ), np);
174 forAllConstIter(typename Cloud<ParcelType>, c, iter)
176 const KinematicParcel<ParcelType>& p = iter();
178 typeId[i] = p.typeId();
179 nParticle[i] = p.nParticle();
183 tTurb[i] = p.tTurb();
184 UTurb[i] = p.UTurb();
198 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
200 template<class ParcelType>
201 Foam::Ostream& Foam::operator<<
204 const KinematicParcel<ParcelType>& p
207 if (os.format() == IOstream::ASCII)
209 os << static_cast<const Particle<ParcelType>&>(p)
210 << token::SPACE << p.typeId()
211 << token::SPACE << p.nParticle()
212 << token::SPACE << p.d()
213 << token::SPACE << p.U()
214 << token::SPACE << p.rho()
215 << token::SPACE << p.tTurb()
216 << token::SPACE << p.UTurb();
220 os << static_cast<const Particle<ParcelType>&>(p);
223 reinterpret_cast<const char*>(&p.typeId_),
225 + sizeof(p.nParticle())
234 // Check state of Ostream
237 "Ostream& operator<<(Ostream&, const KinematicParcel<ParcelType>&)"
244 // ************************************************************************* //