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 \*---------------------------------------------------------------------------*/
27 #include "ThermoParcel.H"
28 #include "IOstreams.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 template<class ParcelType>
33 Foam::ThermoParcel<ParcelType>::ThermoParcel
35 const Cloud<ParcelType>& cloud,
40 KinematicParcel<ParcelType>(cloud, is, readFields),
48 if (is.format() == IOstream::ASCII)
57 reinterpret_cast<char*>(&T_),
64 // Check state of Istream
67 "ThermoParcel::ThermoParcel(const Cloud<ParcelType>&, Istream&, bool)"
72 template<class ParcelType>
73 void Foam::ThermoParcel<ParcelType>::readFields
75 ThermoCloud<ParcelType>& c
83 KinematicParcel<ParcelType>::readFields(c);
85 IOField<scalar> T(c.fieldIOobject("T"));
86 c.checkFieldIOobject(c, T);
88 IOField<scalar> cp(c.fieldIOobject("cp"));
89 c.checkFieldIOobject(c, cp);
93 forAllIter(typename Cloud<ParcelType>, c, iter)
95 ThermoParcel<ParcelType>& p = iter();
104 template<class ParcelType>
105 void Foam::ThermoParcel<ParcelType>::writeFields
107 const ThermoCloud<ParcelType>& c
110 KinematicParcel<ParcelType>::writeFields(c);
114 IOField<scalar> T(c.fieldIOobject("T"), np);
115 IOField<scalar> cp(c.fieldIOobject("cp"), np);
118 forAllConstIter(typename Cloud<ParcelType>, c, iter)
120 const ThermoParcel<ParcelType>& p = iter();
132 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
134 template<class ParcelType>
135 Foam::Ostream& Foam::operator<<
138 const ThermoParcel<ParcelType>& p
141 if (os.format() == IOstream::ASCII)
143 os << static_cast<const KinematicParcel<ParcelType>& >(p)
144 << token::SPACE << p.T()
145 << token::SPACE << p.cp();
149 os << static_cast<const KinematicParcel<ParcelType>& >(p);
152 reinterpret_cast<const char*>(&p.T_),
153 sizeof(p.T()) + sizeof(p.cp())
157 // Check state of Ostream
160 "Ostream& operator<<(Ostream&, const ThermoParcel<ParcelType>&)"
167 // ************************************************************************* //