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 "SprayParcel.H"
27 #include "IOstreams.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 template <class ParcelType>
32 Foam::string Foam::SprayParcel<ParcelType>::propHeader =
33 ParcelType::propHeader
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 template<class ParcelType>
50 Foam::SprayParcel<ParcelType>::SprayParcel
57 ParcelType(mesh, is, readFields),
59 position0_(vector::zero),
73 if (is.format() == IOstream::ASCII)
77 liquidCore_ = readScalar(is);
78 KHindex_ = readScalar(is);
80 yDot_ = readScalar(is);
83 injector_ = readScalar(is);
84 tMom_ = readScalar(is);
85 user_ = readScalar(is);
91 reinterpret_cast<char*>(&d0_),
107 // Check state of Istream
110 "SprayParcel<ParcelType>::SprayParcel"
120 template<class ParcelType>
121 template<class CloudType>
122 void Foam::SprayParcel<ParcelType>::readFields(CloudType& c)
129 ParcelType::readFields(c);
133 template<class ParcelType>
134 template<class CloudType, class CompositionType>
135 void Foam::SprayParcel<ParcelType>::readFields
138 const CompositionType& compModel
146 ParcelType::readFields(c, compModel);
148 IOField<scalar> d0(c.fieldIOobject("d0", IOobject::MUST_READ));
149 c.checkFieldIOobject(c, d0);
151 IOField<vector> position0
153 c.fieldIOobject("position0", IOobject::MUST_READ)
155 c.checkFieldIOobject(c, position0);
157 IOField<scalar> liquidCore(c.fieldIOobject
159 "liquidCore", IOobject::MUST_READ)
161 c.checkFieldIOobject(c, liquidCore);
163 IOField<scalar> KHindex(c.fieldIOobject("KHindex", IOobject::MUST_READ));
164 c.checkFieldIOobject(c, KHindex);
166 IOField<scalar> y(c.fieldIOobject("y", IOobject::MUST_READ));
167 c.checkFieldIOobject(c, y);
169 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::MUST_READ));
170 c.checkFieldIOobject(c, yDot);
172 IOField<scalar> tc(c.fieldIOobject("tc", IOobject::MUST_READ));
173 c.checkFieldIOobject(c, tc);
175 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::MUST_READ));
176 c.checkFieldIOobject(c, ms);
178 IOField<scalar> injector(c.fieldIOobject("injector", IOobject::MUST_READ));
179 c.checkFieldIOobject(c, injector);
181 IOField<scalar> tMom(c.fieldIOobject("tMom", IOobject::MUST_READ));
182 c.checkFieldIOobject(c, tMom);
184 IOField<scalar> user(c.fieldIOobject("user", IOobject::MUST_READ));
185 c.checkFieldIOobject(c, user);
188 forAllIter(typename Cloud<SprayParcel<ParcelType> >, c, iter)
190 SprayParcel<ParcelType>& p = iter();
192 p.position0_ = position0[i];
193 p.liquidCore_ = liquidCore[i];
194 p.KHindex_ = KHindex[i];
199 p.injector_ = injector[i];
207 template<class ParcelType>
208 template<class CloudType>
209 void Foam::SprayParcel<ParcelType>::writeFields(const CloudType& c)
211 ParcelType::writeFields(c);
215 template<class ParcelType>
216 template<class CloudType, class CompositionType>
217 void Foam::SprayParcel<ParcelType>::writeFields
220 const CompositionType& compModel
223 ParcelType::writeFields(c, compModel);
227 IOField<scalar> d0(c.fieldIOobject("d0", IOobject::NO_READ), np);
228 IOField<vector> position0
230 c.fieldIOobject("position0", IOobject::NO_READ),
233 IOField<scalar> liquidCore
235 c.fieldIOobject("liquidCore", IOobject::NO_READ),
238 IOField<scalar> KHindex(c.fieldIOobject("KHindex", IOobject::NO_READ), np);
239 IOField<scalar> y(c.fieldIOobject("y", IOobject::NO_READ), np);
240 IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::NO_READ), np);
241 IOField<scalar> tc(c.fieldIOobject("tc", IOobject::NO_READ), np);
242 IOField<scalar> ms(c.fieldIOobject("ms", IOobject::NO_READ), np);
243 IOField<scalar> injector
245 c.fieldIOobject("injector", IOobject::NO_READ),
248 IOField<scalar> tMom(c.fieldIOobject("tMom", IOobject::NO_READ), np);
249 IOField<scalar> user(c.fieldIOobject("user", IOobject::NO_READ), np);
252 forAllConstIter(typename Cloud<SprayParcel<ParcelType> >, c, iter)
254 const SprayParcel<ParcelType>& p = iter();
256 position0[i] = p.position0_;
257 liquidCore[i] = p.liquidCore_;
258 KHindex[i] = p.KHindex_;
263 injector[i] = p.injector_;
283 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
285 template<class ParcelType>
286 Foam::Ostream& Foam::operator<<
289 const SprayParcel<ParcelType>& p
292 if (os.format() == IOstream::ASCII)
294 os << static_cast<const ParcelType&>(p)
295 << token::SPACE << p.d0()
296 << token::SPACE << p.position0()
297 << token::SPACE << p.liquidCore()
298 << token::SPACE << p.KHindex()
299 << token::SPACE << p.y()
300 << token::SPACE << p.yDot()
301 << token::SPACE << p.tc()
302 << token::SPACE << p.ms()
303 << token::SPACE << p.injector()
304 << token::SPACE << p.tMom()
305 << token::SPACE << p.user();
309 os << static_cast<const ParcelType&>(p);
312 reinterpret_cast<const char*>(&p.d0_),
314 + sizeof(p.position0())
315 + sizeof(p.liquidCore())
316 + sizeof(p.KHindex())
321 + sizeof(p.injector())
327 // Check state of Ostream
330 "Ostream& operator<<(Ostream&, const SprayParcel<ParcelType>&)"
337 // ************************************************************************* //