1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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 \*---------------------------------------------------------------------------*/
26 #include "solidParticle.H"
27 #include <OpenFOAM/IOstreams.H>
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 Foam::solidParticle::solidParticle
33 const Cloud<solidParticle>& cloud,
38 Particle<solidParticle>(cloud, is, readFields)
42 if (is.format() == IOstream::ASCII)
51 reinterpret_cast<char*>(&d_),
52 sizeof(d_) + sizeof(U_)
57 // Check state of Istream
58 is.check("solidParticle::solidParticle(Istream&)");
62 void Foam::solidParticle::readFields(Cloud<solidParticle>& c)
68 IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
69 c.checkFieldIOobject(c, d);
71 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
72 c.checkFieldIOobject(c, U);
75 forAllIter(Cloud<solidParticle>, c, iter)
77 solidParticle& p = iter();
86 void Foam::solidParticle::writeFields(const Cloud<solidParticle>& c)
88 Particle<solidParticle>::writeFields(c);
92 IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
93 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
96 forAllConstIter(Cloud<solidParticle>, c, iter)
98 const solidParticle& p = iter();
110 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
112 Foam::Ostream& Foam::operator<<(Ostream& os, const solidParticle& p)
114 if (os.format() == IOstream::ASCII)
116 os << static_cast<const Particle<solidParticle>&>(p)
117 << token::SPACE << p.d_
118 << token::SPACE << p.U_;
122 os << static_cast<const Particle<solidParticle>&>(p);
125 reinterpret_cast<const char*>(&p.d_),
126 sizeof(p.d_) + sizeof(p.U_)
130 // Check state of Ostream
131 os.check("Ostream& operator<<(Ostream&, const solidParticle&)");
137 // ************************ vim: set sw=4 sts=4 et: ************************ //