intersection with triangle plane for miss
[OpenFOAM-1.5.x.git] / src / lagrangian / basic / Particle / ParticleIO.C
blob065680de075803f05ef061d153d060dc451cfcfd
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "Particle.H"
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,
38     Istream& is,
39     bool readFields
42     cloud_(cloud),
43     facei_(-1),
44     stepFraction_(0.0)
46     if (is.format() == IOstream::ASCII)
47     {
48         is >> position_ >> celli_;
49     }
50     else
51     {
52         // In binary read both celli_ and facei_, needed for parallel transfer
53         is.read
54         (
55             reinterpret_cast<char*>(&position_),
56             sizeof(position_) + sizeof(celli_)
57           + sizeof(facei_) + sizeof(stepFraction_)
58         );
59     }
61     if (celli_ == -1)
62     {
63         celli_ = cloud_.pMesh().findCell(position_);
64     }
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);
79     ioP.write();
83 template<class ParticleType>
84 Foam::Ostream& Foam::operator<<(Ostream& os, const Particle<ParticleType>& p)
86     if (os.format() == IOstream::ASCII)
87     {
88         os << p.position_
89            << token::SPACE << p.celli_;
90     }
91     else
92     {
93         // In binary write both celli_ and facei_, needed for parallel transfer
94         os.write
95         (
96             reinterpret_cast<const char*>(&p.position_),
97             sizeof(p.position_) + sizeof(p.celli_)
98           + sizeof(p.facei_) + sizeof(p.stepFraction_)
99         );
100     }
102     // Check state of Ostream
103     os.check("Ostream& operator<<(Ostream&, const Particle<ParticleType>&)");
105     return os;
109 // ************************************************************************* //