FreeFOAM The Cross-Platform CFD Toolkit
ReactingParcel_.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::ReactingParcel
26 
27 Description
28  Reacting parcel class with one/two-way coupling with the continuous
29  phase.
30 
31 SourceFiles
32  ReactingParcelI.H
33  ReactingParcel.C
34  ReactingParcelIO.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef ReactingParcel_H
39 #define ReactingParcel_H
40 
41 #include <OpenFOAM/IOstream.H>
42 #include <OpenFOAM/autoPtr.H>
44 #include <OpenFOAM/contiguous.H>
45 
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 template<class ParcelType>
56 class ReactingParcel;
57 
58 template<class ParcelType>
59 Ostream& operator<<
60 (
61  Ostream&,
62  const ReactingParcel<ParcelType>&
63 );
64 
65 /*---------------------------------------------------------------------------*\
66  Class ReactingParcel Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 template<class ParcelType>
71 :
72  public reactingParcel,
73  public ThermoParcel<ParcelType>
74 {
75 public:
76 
77  //- Class to hold reacting particle constant properties
79  :
80  public ThermoParcel<ParcelType>::constantProperties
81  {
82  // Private data
83 
84  //- Minimum pressure [Pa]
85  const scalar pMin_;
86 
87  //- Constant volume flag - e.g. during mass transfer
88  Switch constantVolume_;
89 
90  //- Vaporisation temperature [K]
91  const scalar Tvap_;
92 
93  //- Boiling point [K]
94  const scalar Tbp_;
95 
96 
97  public:
98 
99  //- Constructor
100  constantProperties(const dictionary& parentDict);
101 
102  // Access
103 
104  //- Return const access to the minimum pressure
105  inline scalar pMin() const;
106 
107  //- Return const access to the constant volume flag
108  inline Switch constantVolume() const;
109 
110  //- Return const access to the vaporisation temperature
111  inline scalar Tvap() const;
112 
113  //- Return const access to the boiling point
114  inline scalar Tbp() const;
115  };
116 
117 
118  //- Class used to pass reacting tracking data to the trackToFace function
119  class trackData
120  :
121  public ThermoParcel<ParcelType>::trackData
122  {
123 
124  // Private data
125 
126  //- Reference to the cloud containing this particle
128 
129  //- Particle constant properties
130  const constantProperties& constProps_;
131 
132  //- Interpolator for continuous phase pressure field
133  const interpolation<scalar>& pInterp_;
134 
135 
136  public:
137 
139 
140 
141  // Constructors
142 
143  //- Construct from components
144  inline trackData
145  (
152  const interpolation<scalar>& CpInterp,
154  const vector& g
155  );
156 
157 
158  // Member functions
159 
160  //- Return access to the owner cloud
162 
163  //- Return const access to the constant properties
164  inline const constantProperties& constProps() const;
165 
166  //- Return const access to the interpolator for continuous
167  // phase pressure field
168  inline const interpolation<scalar>& pInterp() const;
169  };
170 
171 
172 protected:
173 
174  // Protected data
175 
176  // Parcel properties
177 
178  //- Initial particle mass [kg]
179  scalar mass0_;
180 
181  //- Mass fractions of mixture []
183 
184 
185  // Cell-based quantities
186 
187  //- Pressure [Pa]
188  scalar pc_;
189 
190 
191  // Protected member functions
192 
193  //- Calculate Phase change
194  template<class TrackData>
195  void calcPhaseChange
196  (
197  TrackData& td,
198  const scalar dt, // timestep
199  const label cellI, // owner cell
200  const scalar Re, // Reynolds number
201  const scalar Ts, // Surface temperature
202  const scalar nus, // Surface kinematic viscosity
203  const scalar d, // diameter
204  const scalar T, // temperature
205  const scalar mass, // mass
206  const label idPhase, // id of phase involved in phase change
207  const scalar YPhase, // total mass fraction
208  const scalarField& YComponents, // component mass fractions
209  scalarField& dMassPC, // mass transfer - local to particle
210  scalar& Sh, // explicit particle enthalpy source
211  scalar& N, // flux of species emitted from particle
212  scalar& NCpW, // sum of N*Cp*W of emission species
213  scalarField& Cs // carrier conc. of emission species
214  );
215 
216  //- Update mass fraction
217  scalar updateMassFraction
218  (
219  const scalar mass0,
220  const scalarField& dMass,
221  scalarField& Y
222  ) const;
223 
224 
225 public:
226 
227  // Static data members
228 
229  //- String representation of properties
230  static string propHeader;
231 
232  //- Runtime type information
233  TypeName("ReactingParcel");
234 
235 
236  friend class Cloud<ParcelType>;
237 
238 
239  // Constructors
240 
241  //- Construct from owner, position, and cloud owner
242  // Other properties initialised as null
243  inline ReactingParcel
244  (
246  const vector& position,
247  const label cellI
248  );
249 
250  //- Construct from components
251  inline ReactingParcel
252  (
254  const vector& position,
255  const label cellI,
256  const label typeId,
257  const scalar nParticle0,
258  const scalar d0,
259  const vector& U0,
260  const scalarField& Y0,
261  const constantProperties& constProps
262  );
263 
264  //- Construct from Istream
266  (
267  const Cloud<ParcelType>& c,
268  Istream& is,
269  bool readFields = true
270  );
271 
272  //- Construct as a copy
274 
275  //- Construct and return a clone
277  {
278  return autoPtr<ReactingParcel>(new ReactingParcel(*this));
279  }
280 
281 
282  // Member Functions
283 
284  // Access
285 
286  //- Return const access to initial mass
287  inline scalar mass0() const;
288 
289  //- Return const access to mass fractions of mixture
290  inline const scalarField& Y() const;
291 
292  //- Return the owner cell pressure
293  inline scalar pc() const;
294 
295 
296  // Edit
297 
298  //- Return access to initial mass
299  inline scalar& mass0();
300 
301  //- Return access to mass fractions of mixture
302  inline scalarField& Y();
303 
304 
305  // Main calculation loop
306 
307  //- Set cell values
308  template<class TrackData>
309  void setCellValues
310  (
311  TrackData& td,
312  const scalar dt,
313  const label cellI
314  );
315 
316  //- Correct cell values using latest transfer information
317  template<class TrackData>
319  (
320  TrackData& td,
321  const scalar dt,
322  const label cellI
323  );
324 
325  //- Correct surface values due to emitted species
326  template<class TrackData>
328  (
329  TrackData& td,
330  const label cellI,
331  const scalar T,
332  const scalarField& Cs,
333  scalar& rhos,
334  scalar& mus,
335  scalar& Pr,
336  scalar& kappa
337  );
338 
339  //- Update parcel properties over the time interval
340  template<class TrackData>
341  void calc
342  (
343  TrackData& td,
344  const scalar dt,
345  const label cellI
346  );
347 
348 
349  // I-O
350 
351  //- Read
352  static void readFields(Cloud<ParcelType>& c);
353 
354  //- Write
355  static void writeFields(const Cloud<ParcelType>& c);
356 
357 
358  // Ostream Operator
359 
360  friend Ostream& operator<< <ParcelType>
361  (
362  Ostream&,
364  );
365 };
366 
367 
368 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
369 
370 } // End namespace Foam
371 
372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
373 
374 #include "ReactingParcelI_.H"
375 
376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
377 
378 #ifdef NoRepository
379  #include "ReactingParcel_.C"
380 #endif
381 
382 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383 
384 #endif
385 
386 // ************************ vim: set sw=4 sts=4 et: ************************ //