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 "DsmcParcel.H"
27 #include "IOstreams.H"
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 template <class ParcelType>
34 Foam::DsmcParcel<ParcelType>::DsmcParcel
41 ParcelType(mesh, is, readFields),
48 if (is.format() == IOstream::ASCII)
52 typeId_ = readLabel(is);
58 reinterpret_cast<char*>(&U_),
66 // Check state of Istream
69 "DsmcParcel<ParcelType>::DsmcParcel"
70 "(const Cloud<ParcelType>&, Istream&, bool)"
75 template<class ParcelType>
76 void Foam::DsmcParcel<ParcelType>::readFields(Cloud<DsmcParcel<ParcelType> >& c)
83 ParcelType::readFields(c);
85 IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
86 c.checkFieldIOobject(c, U);
88 IOField<scalar> Ei(c.fieldIOobject("Ei", IOobject::MUST_READ));
89 c.checkFieldIOobject(c, Ei);
91 IOField<label> typeId(c.fieldIOobject("typeId", IOobject::MUST_READ));
92 c.checkFieldIOobject(c, typeId);
95 forAllIter(typename Cloud<DsmcParcel<ParcelType> >, c, iter)
97 DsmcParcel<ParcelType>& p = iter();
101 p.typeId_ = typeId[i];
107 template<class ParcelType>
108 void Foam::DsmcParcel<ParcelType>::writeFields
110 const Cloud<DsmcParcel<ParcelType> >& c
113 ParcelType::writeFields(c);
117 IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
118 IOField<scalar> Ei(c.fieldIOobject("Ei", IOobject::NO_READ), np);
119 IOField<label> typeId(c.fieldIOobject("typeId", IOobject::NO_READ), np);
122 forAllConstIter(typename Cloud<DsmcParcel<ParcelType> >, c, iter)
124 const DsmcParcel<ParcelType>& p = iter();
128 typeId[i] = p.typeId();
138 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
140 template<class ParcelType>
141 Foam::Ostream& Foam::operator<<
144 const DsmcParcel<ParcelType>& p
147 if (os.format() == IOstream::ASCII)
149 os << static_cast<const ParcelType& >(p)
150 << token::SPACE << p.U()
151 << token::SPACE << p.Ei()
152 << token::SPACE << p.typeId();
156 os << static_cast<const ParcelType& >(p);
159 reinterpret_cast<const char*>(&p.U_),
166 // Check state of Ostream
169 "Ostream& operator<<(Ostream&, const DsmcParcel<ParcelType>&)"
176 // ************************************************************************* //