1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2009 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 \*---------------------------------------------------------------------------*/
27 #include "DsmcParcel.H"
28 #include "IOstreams.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 template <class ParcelType>
35 Foam::DsmcParcel<ParcelType>::DsmcParcel
37 const Cloud<ParcelType>& cloud,
42 Particle<ParcelType>(cloud, is, readFields),
49 if (is.format() == IOstream::ASCII)
53 typeId_ = readLabel(is);
59 reinterpret_cast<char*>(&U_),
67 // Check state of Istream
70 "DsmcParcel<ParcelType>::DsmcParcel"
71 "(const Cloud<ParcelType>&, Istream&, bool)"
76 template<class ParcelType>
77 void Foam::DsmcParcel<ParcelType>::readFields
79 DsmcCloud<ParcelType>& c
87 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
88 c.checkFieldIOobject(c, U);
90 IOField<scalar> Ei(c.fieldIOobject("Ei", IOobject::MUST_READ));
91 c.checkFieldIOobject(c, Ei);
93 IOField<label> typeId(c.fieldIOobject("typeId", IOobject::MUST_READ));
94 c.checkFieldIOobject(c, typeId);
97 forAllIter(typename Cloud<ParcelType>, c, iter)
99 ParcelType& p = iter();
103 p.typeId_ = typeId[i];
109 template<class ParcelType>
110 void Foam::DsmcParcel<ParcelType>::writeFields
112 const DsmcCloud<ParcelType>& c
115 Particle<ParcelType>::writeFields(c);
119 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
120 IOField<scalar> Ei(c.fieldIOobject("Ei", IOobject::NO_READ), np);
121 IOField<label> typeId(c.fieldIOobject("typeId", IOobject::NO_READ), np);
124 forAllConstIter(typename Cloud<ParcelType>, c, iter)
126 const DsmcParcel<ParcelType>& p = iter();
130 typeId[i] = p.typeId();
140 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
142 template<class ParcelType>
143 Foam::Ostream& Foam::operator<<
146 const DsmcParcel<ParcelType>& p
149 if (os.format() == IOstream::ASCII)
151 os << static_cast<const Particle<ParcelType>& >(p)
152 << token::SPACE << p.U()
153 << token::SPACE << p.Ei()
154 << token::SPACE << p.typeId();
158 os << static_cast<const Particle<ParcelType>& >(p);
161 reinterpret_cast<const char*>(&p.U_),
168 // Check state of Ostream
171 "Ostream& operator<<(Ostream&, const DsmcParcel<ParcelType>&)"
178 // ************************************************************************* //