1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 \*---------------------------------------------------------------------------*/
28 #include "IOstreams.H"
29 #include "IOPosition.H"
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 // Construct from Istream
34 template<class ParticleType>
35 Foam::Particle<ParticleType>::Particle
37 const Cloud<ParticleType>& cloud,
46 if (is.format() == IOstream::ASCII)
48 is >> position_ >> celli_;
52 // In binary read both celli_ and facei_, needed for parallel transfer
55 reinterpret_cast<char*>(&position_),
56 sizeof(position_) + sizeof(celli_)
57 + sizeof(facei_) + sizeof(stepFraction_)
63 celli_ = cloud_.pMesh().findCell(position_);
66 // Check state of Istream
67 is.check("Particle<ParticleType>::Particle(Istream&)");
71 template<class ParticleType>
72 void Foam::Particle<ParticleType>::writeFields
74 const Cloud<ParticleType>& c
77 // Write the cloud position file
78 IOPosition<ParticleType> ioP(c);
83 template<class ParticleType>
84 Foam::Ostream& Foam::operator<<(Ostream& os, const Particle<ParticleType>& p)
86 if (os.format() == IOstream::ASCII)
89 << token::SPACE << p.celli_;
93 // In binary write both celli_ and facei_, needed for parallel transfer
96 reinterpret_cast<const char*>(&p.position_),
97 sizeof(p.position_) + sizeof(p.celli_)
98 + sizeof(p.facei_) + sizeof(p.stepFraction_)
102 // Check state of Ostream
103 os.check("Ostream& operator<<(Ostream&, const Particle<ParticleType>&)");
109 // ************************************************************************* //