1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 template <class ParcelType>
33 Foam::string Foam::ThermoParcel<ParcelType>::propHeader =
34 KinematicParcel<ParcelType>::propHeader
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 template<class ParcelType>
42 Foam::ThermoParcel<ParcelType>::ThermoParcel
44 const Cloud<ParcelType>& cloud,
49 KinematicParcel<ParcelType>(cloud, is, readFields),
57 if (is.format() == IOstream::ASCII)
66 reinterpret_cast<char*>(&T_),
73 // Check state of Istream
76 "ThermoParcel::ThermoParcel(const Cloud<ParcelType>&, Istream&, bool)"
81 template<class ParcelType>
82 void Foam::ThermoParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
89 KinematicParcel<ParcelType>::readFields(c);
91 IOField<scalar> T(c.fieldIOobject("T", IOobject::MUST_READ));
92 c.checkFieldIOobject(c, T);
94 IOField<scalar> cp(c.fieldIOobject("cp", IOobject::MUST_READ));
95 c.checkFieldIOobject(c, cp);
99 forAllIter(typename Cloud<ParcelType>, c, iter)
101 ThermoParcel<ParcelType>& p = iter();
110 template<class ParcelType>
111 void Foam::ThermoParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
113 KinematicParcel<ParcelType>::writeFields(c);
117 IOField<scalar> T(c.fieldIOobject("T", IOobject::NO_READ), np);
118 IOField<scalar> cp(c.fieldIOobject("cp", IOobject::NO_READ), np);
121 forAllConstIter(typename Cloud<ParcelType>, c, iter)
123 const ThermoParcel<ParcelType>& p = iter();
135 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
137 template<class ParcelType>
138 Foam::Ostream& Foam::operator<<
141 const ThermoParcel<ParcelType>& p
144 if (os.format() == IOstream::ASCII)
146 os << static_cast<const KinematicParcel<ParcelType>&>(p)
147 << token::SPACE << p.T()
148 << token::SPACE << p.cp();
152 os << static_cast<const KinematicParcel<ParcelType>&>(p);
155 reinterpret_cast<const char*>(&p.T_),
156 sizeof(p.T()) + sizeof(p.cp())
160 // Check state of Ostream
163 "Ostream& operator<<(Ostream&, const ThermoParcel<ParcelType>&)"
170 // ************************************************************************* //