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 "ThermoParcel.H"
27 #include "IOstreams.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 template<class ParcelType>
32 Foam::string Foam::ThermoParcel<ParcelType>::propHeader =
33 ParcelType::propHeader
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 template<class ParcelType>
41 Foam::ThermoParcel<ParcelType>::ThermoParcel
48 ParcelType(mesh, is, readFields),
56 if (is.format() == IOstream::ASCII)
65 reinterpret_cast<char*>(&T_),
72 // Check state of Istream
75 "ThermoParcel::ThermoParcel(const polyMesh&, Istream&, bool)"
80 template<class ParcelType>
81 template<class CloudType>
82 void Foam::ThermoParcel<ParcelType>::readFields(CloudType& c)
89 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<ThermoParcel<ParcelType> >, c, iter)
101 ThermoParcel<ParcelType>& p = iter();
110 template<class ParcelType>
111 template<class CloudType>
112 void Foam::ThermoParcel<ParcelType>::writeFields(const CloudType& c)
114 ParcelType::writeFields(c);
118 IOField<scalar> T(c.fieldIOobject("T", IOobject::NO_READ), np);
119 IOField<scalar> Cp(c.fieldIOobject("Cp", IOobject::NO_READ), np);
122 forAllConstIter(typename Cloud<ThermoParcel<ParcelType> >, c, iter)
124 const ThermoParcel<ParcelType>& p = iter();
136 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
138 template<class ParcelType>
139 Foam::Ostream& Foam::operator<<
142 const ThermoParcel<ParcelType>& p
145 if (os.format() == IOstream::ASCII)
147 os << static_cast<const ParcelType&>(p)
148 << token::SPACE << p.T()
149 << token::SPACE << p.Cp();
153 os << static_cast<const ParcelType&>(p);
156 reinterpret_cast<const char*>(&p.T_),
157 sizeof(p.T()) + sizeof(p.Cp())
161 // Check state of Ostream
164 "Ostream& operator<<(Ostream&, const ThermoParcel<ParcelType>&)"
171 // ************************************************************************* //