1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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 "solidParticle.H"
28 #include "IOstreams.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 Foam::solidParticle::solidParticle
34 const Cloud<solidParticle>& cloud,
39 Particle<solidParticle>(cloud, is, readFields)
43 if (is.format() == IOstream::ASCII)
52 reinterpret_cast<char*>(&d_),
53 sizeof(d_) + sizeof(U_)
58 // Check state of Istream
59 is.check("solidParticle::solidParticle(Istream&)");
63 void Foam::solidParticle::readFields(Cloud<solidParticle>& c)
69 IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
70 c.checkFieldIOobject(c, d);
72 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
73 c.checkFieldIOobject(c, U);
76 forAllIter(Cloud<solidParticle>::iterator, c, iter)
78 solidParticle& p = iter();
87 void Foam::solidParticle::writeFields(const Cloud<solidParticle>& c)
89 Particle<solidParticle>::writeFields(c);
93 IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
94 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
97 forAllConstIter(Cloud<solidParticle>, c, iter)
99 const solidParticle& p = iter();
111 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
113 Foam::Ostream& Foam::operator<<(Ostream& os, const solidParticle& p)
115 if (os.format() == IOstream::ASCII)
117 os << static_cast<const Particle<solidParticle>&>(p)
118 << token::SPACE << p.d_
119 << token::SPACE << p.U_;
123 os << static_cast<const Particle<solidParticle>&>(p);
126 reinterpret_cast<const char*>(&p.d_),
127 sizeof(p.d_) + sizeof(p.U_)
131 // Check state of Ostream
132 os.check("Ostream& operator<<(Ostream&, const solidParticle&)");
138 // ************************************************************************* //