1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 "IOstreams.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 Foam::solidParticle::solidParticle
38 particle(mesh, 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)
69 particle::readFields(c);
71 IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
72 c.checkFieldIOobject(c, d);
74 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
75 c.checkFieldIOobject(c, U);
78 forAllIter(Cloud<solidParticle>, c, iter)
80 solidParticle& p = iter();
89 void Foam::solidParticle::writeFields(const Cloud<solidParticle>& c)
91 particle::writeFields(c);
95 IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
96 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
99 forAllConstIter(Cloud<solidParticle>, c, iter)
101 const solidParticle& p = iter();
113 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
115 Foam::Ostream& Foam::operator<<(Ostream& os, const solidParticle& p)
117 if (os.format() == IOstream::ASCII)
119 os << static_cast<const particle&>(p)
120 << token::SPACE << p.d_
121 << token::SPACE << p.U_;
125 os << static_cast<const particle&>(p);
128 reinterpret_cast<const char*>(&p.d_),
129 sizeof(p.d_) + sizeof(p.U_)
133 // Check state of Ostream
134 os.check("Ostream& operator<<(Ostream&, const solidParticle&)");
140 // ************************************************************************* //