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 \*---------------------------------------------------------------------------*/
27 #include "IOstreams.H"
28 #include "IOPosition.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 Foam::string Foam::particle::propHeader =
33 "(Px Py Pz) cellI tetFaceI tetPtI origProc origId";
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields)
47 origProc_(Pstream::myProcNo()),
50 // readFields : read additional data. Should be consistent with writeFields.
52 if (is.format() == IOstream::ASCII)
54 is >> position_ >> cellI_;
58 is >> tetFaceI_ >> tetPtI_ >> origProc_ >> origId_;
63 // In binary read all particle data - needed for parallel transfer
68 reinterpret_cast<char*>(&position_),
72 + sizeof(stepFraction_)
83 reinterpret_cast<char*>(&position_),
87 + sizeof(stepFraction_)
92 // Check state of Istream
93 is.check("particle::particle(Istream&, bool)");
97 void Foam::particle::write(Ostream& os, bool writeFields) const
99 if (os.format() == IOstream::ASCII)
103 // Write the additional entries
105 << token::SPACE << cellI_
106 << token::SPACE << tetFaceI_
107 << token::SPACE << tetPtI_
108 << token::SPACE << origProc_
109 << token::SPACE << origId_;
114 << token::SPACE << cellI_;
119 // In binary write both cellI_ and faceI_, needed for parallel transfer
124 reinterpret_cast<const char*>(&position_),
128 + sizeof(stepFraction_)
139 reinterpret_cast<const char*>(&position_),
143 + sizeof(stepFraction_)
148 // Check state of Ostream
149 os.check("particle::write(Ostream& os, bool) const");
153 Foam::Ostream& Foam::operator<<(Ostream& os, const particle& p)
162 // ************************************************************************* //