initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / intermediate / parcels / Templates / ReactingParcel / ReactingParcel.H
blobf17cd211714c23e918d766d2e66555cc2bb986e5
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 Class
26     Foam::ReactingParcel
28 Description
29     Reacting parcel class with one/two-way coupling with the continuous
30     phase.
32 SourceFiles
33     ReactingParcelI.H
34     ReactingParcel.C
35     ReactingParcelIO.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef ReactingParcel_H
40 #define ReactingParcel_H
42 #include "IOstream.H"
43 #include "autoPtr.H"
44 #include "interpolationCellPoint.H"
45 #include "contiguous.H"
47 #include "ThermoParcel.H"
48 #include "ReactingCloud.H"
49 #include "reactingParcel.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 namespace Foam
56 template<class ParcelType>
57 class ReactingParcel;
59 template<class ParcelType>
60 Ostream& operator<<
62     Ostream&,
63     const ReactingParcel<ParcelType>&
66 /*---------------------------------------------------------------------------*\
67                         Class ReactingParcel Declaration
68 \*---------------------------------------------------------------------------*/
70 template<class ParcelType>
71 class ReactingParcel
73     public reactingParcel,
74     public ThermoParcel<ParcelType>
76 public:
78     //- Class to hold reacting particle constant properties
79     class constantProperties
80     :
81         public ThermoParcel<ParcelType>::constantProperties
82     {
83         // Private data
85             //- Minimum pressure [Pa]
86             const scalar pMin_;
88             //- Constant volume flag - e.g. during mass transfer
89             Switch constantVolume_;
91             //- Vaporisation temperature [K]
92             const scalar Tvap_;
94             //- Boiling point [K]
95             const scalar Tbp_;
98     public:
100         //- Constructor
101         constantProperties(const dictionary& parentDict);
103         // Access
105             //- Return const access to the minimum pressure
106             inline scalar pMin() const;
108             //- Return const access to the constant volume flag
109             inline Switch constantVolume() const;
111             //- Return const access to the vaporisation temperature
112             inline scalar Tvap() const;
114             //- Return const access to the boiling point
115             inline scalar Tbp() const;
116    };
119     //- Class used to pass reacting tracking data to the trackToFace function
120     class trackData
121     :
122         public ThermoParcel<ParcelType>::trackData
123     {
125         // Private data
127             //- Reference to the cloud containing this particle
128             ReactingCloud<ParcelType>& cloud_;
130             //- Particle constant properties
131             const constantProperties& constProps_;
133             //- Interpolator for continuous phase pressure field
134             const interpolation<scalar>& pInterp_;
137     public:
139         // Constructors
141             //- Construct from components
142             inline trackData
143             (
144                 ReactingCloud<ParcelType>& cloud,
145                 const constantProperties& constProps,
146                 const interpolation<scalar>& rhoInterp,
147                 const interpolation<vector>& UInterp,
148                 const interpolation<scalar>& muInterp,
149                 const interpolation<scalar>& TInterp,
150                 const interpolation<scalar>& CpInterp,
151                 const interpolation<scalar>& pInterp,
152                 const vector& g
153             );
156         // Member functions
158             //- Return access to the owner cloud
159             inline ReactingCloud<ParcelType>& cloud();
161             //- Return const access to the constant properties
162             inline const constantProperties& constProps() const;
164             //- Return const access to the interpolator for continuous
165             //  phase pressure field
166             inline const interpolation<scalar>& pInterp() const;
167     };
170 protected:
172     // Protected data
174         // Parcel properties
176             //- Initial particle mass [kg]
177             scalar mass0_;
179             //- Mass fractions of mixture []
180             scalarField Y_;
183         // Cell-based quantities
185             //- Pressure [Pa]
186             scalar pc_;
189     // Protected member functions
191         //- Calculate Phase change
192         template<class TrackData>
193         void calcPhaseChange
194         (
195             TrackData& td,
196             const scalar dt,           // timestep
197             const label cellI,         // owner cell
198             const scalar d,            // diameter
199             const scalar T,            // temperature
200             const vector& U,           // velocity
201             const scalar mass,         // mass
202             const label idPhase,       // id of phase involved in phase change
203             const scalar YPhase,       // total mass fraction
204             const scalarField& YComponents, // component mass fractions
205             scalarField& dMassPC,      // mass transfer - local to particle
206             scalar& Sh,                // explicit particle enthalpy source
207             scalar& dhsTrans           // sensible enthalpy transfer to carrier
208         );
210         //- Update mass fraction
211         scalar updateMassFraction
212         (
213             const scalar mass0,
214             const scalarField& dMass,
215             scalarField& Y
216         ) const;
219 public:
221     // Static data members
223         //- String representation of properties
224         static string propHeader;
226         //- Runtime type information
227         TypeName("ReactingParcel");
230     friend class Cloud<ParcelType>;
233     // Constructors
235         //- Construct from owner, position, and cloud owner
236         //  Other properties initialised as null
237         inline ReactingParcel
238         (
239             ReactingCloud<ParcelType>& owner,
240             const vector& position,
241             const label cellI
242         );
244         //- Construct from components
245         inline ReactingParcel
246         (
247             ReactingCloud<ParcelType>& owner,
248             const vector& position,
249             const label cellI,
250             const label typeId,
251             const scalar nParticle0,
252             const scalar d0,
253             const vector& U0,
254             const scalarField& Y0,
255             const constantProperties& constProps
256         );
258         //- Construct from Istream
259         ReactingParcel
260         (
261             const Cloud<ParcelType>& c,
262             Istream& is,
263             bool readFields = true
264         );
266         //- Construct as a copy
267         ReactingParcel(const ReactingParcel& p);
269         //- Construct and return a clone
270         autoPtr<ReactingParcel> clone() const
271         {
272             return autoPtr<ReactingParcel>(new ReactingParcel(*this));
273         }
276     // Member Functions
278         // Access
280             //- Return const access to initial mass
281             inline scalar mass0() const;
283             //- Return const access to mass fractions of mixture
284             inline const scalarField& Y() const;
286             //- Return the owner cell pressure
287             inline scalar pc() const;
290         // Edit
292             //- Return access to initial mass
293             inline scalar& mass0();
295             //- Return access to mass fractions of mixture
296             inline scalarField& Y();
299         // Main calculation loop
301             //- Set cell values
302             template<class TrackData>
303             void setCellValues
304             (
305                 TrackData& td,
306                 const scalar dt,
307                 const label cellI
308             );
310             //- Correct cell values using latest transfer information
311             template<class TrackData>
312             void cellValueSourceCorrection
313             (
314                 TrackData& td,
315                 const scalar dt,
316                 const label cellI
317             );
319             //- Update parcel properties over the time interval
320             template<class TrackData>
321             void calc
322             (
323                 TrackData& td,
324                 const scalar dt,
325                 const label cellI
326             );
329         // I-O
331             //- Read
332             static void readFields(ReactingCloud<ParcelType>& c);
334             //- Write
335             static void writeFields(const ReactingCloud<ParcelType>& c);
338     // Ostream Operator
340         friend Ostream& operator<< <ParcelType>
341         (
342             Ostream&,
343             const ReactingParcel<ParcelType>&
344         );
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350 } // End namespace Foam
352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 #include "ReactingParcelI.H"
356 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358 #ifdef NoRepository
359     #include "ReactingParcel.C"
360 #endif
362 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 #endif
366 // ************************************************************************* //