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
29 Kinematic parcel class with one/two-way coupling with the continuous
34 - turbulent dispersion
42 \*---------------------------------------------------------------------------*/
44 #ifndef KinematicParcel_H
45 #define KinematicParcel_H
50 #include "interpolationCellPoint.H"
51 #include "contiguous.H"
53 #include "KinematicCloud.H"
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 template<class ParcelType>
61 class KinematicParcel;
63 // Forward declaration of friend functions
65 template<class ParcelType>
69 const KinematicParcel<ParcelType>&
72 /*---------------------------------------------------------------------------*\
73 Class KinematicParcel Declaration
74 \*---------------------------------------------------------------------------*/
76 template<class ParcelType>
79 public Particle<ParcelType>
83 //- Class to hold kinematic particle constant properties
84 class constantProperties
88 //- Constant properties dictionary
89 const dictionary dict_;
91 //- Minimum density [kg/m3]
94 //- Particle density [kg/m3] (constant)
97 //- Minimum particle mass [kg]
98 const scalar minParticleMass_;
104 constantProperties(const dictionary& parentDict);
108 //- Return const access to the constant properties dictionary
109 inline const dictionary& dict() const;
111 //- Return const access to the minimum density
112 inline scalar rhoMin() const;
114 //- Return const access to the particle density
115 inline scalar rho0() const;
117 //- Return const access to the minimum particle mass
118 inline scalar minParticleMass() const;
122 //- Class used to pass kinematic tracking data to the trackToFace function
125 public Particle<ParcelType>::trackData
129 //- Reference to the cloud containing this particle
130 KinematicCloud<ParcelType>& cloud_;
132 //- Particle constant properties
133 const constantProperties& constProps_;
136 // Interpolators for continuous phase fields
138 //- Density interpolator
139 const interpolation<scalar>& rhoInterp_;
141 //- Velocity interpolator
142 const interpolation<vector>& UInterp_;
144 //- Dynamic viscosity interpolator
145 const interpolation<scalar>& muInterp_;
147 //- Local gravitational or other body-force acceleration
155 //- Construct from components
158 KinematicCloud<ParcelType>& cloud,
159 const constantProperties& constProps,
160 const interpolation<scalar>& rhoInterp,
161 const interpolation<vector>& UInterp,
162 const interpolation<scalar>& muInterp,
169 //- Return access to the owner cloud
170 inline KinematicCloud<ParcelType>& cloud();
172 //- Return const access to the constant properties
173 inline const constantProperties& constProps() const;
175 //- Return conat access to the interpolator for continuous
176 // phase density field
177 inline const interpolation<scalar>& rhoInterp() const;
179 //- Return conat access to the interpolator for continuous
180 // phase velocity field
181 inline const interpolation<vector>& UInterp() const;
183 //- Return conat access to the interpolator for continuous
184 // phase dynamic viscosity field
185 inline const interpolation<scalar>& muInterp() const;
187 // Return const access to the gravitational acceleration vector
188 inline const vector& g() const;
201 //- Number of particles in Parcel
207 //- Velocity of Parcel [m/s]
213 //- Time spent in turbulent eddy [s]
216 //- Turbulent velocity fluctuation [m/s]
220 // Cell-based quantities
232 // Protected member functions
234 //- Calculate new particle velocity
235 template<class TrackData>
236 const vector calcVelocity
239 const scalar dt, // timestep
240 const label cellI, // owner cell
241 const scalar Re, // Reynolds number
242 const scalar mu, // local carrier viscosity
243 const scalar d, // diameter
244 const vector& U, // velocity
245 const scalar rho, // density
246 const scalar mass, // mass
247 const vector& Su, // explicit particle momentum source
248 vector& dUTrans // momentum transfer to carrier
254 // Static data members
256 //- String representation of properties
257 static string propHeader;
259 //- Runtime type information
260 TypeName("KinematicParcel");
263 friend class Cloud<ParcelType>;
268 //- Construct from owner, position, and cloud owner
269 // Other properties initialised as null
270 inline KinematicParcel
272 KinematicCloud<ParcelType>& owner,
273 const vector& position,
277 //- Construct from components
278 inline KinematicParcel
280 KinematicCloud<ParcelType>& owner,
281 const vector& position,
284 const scalar nParticle0,
287 const constantProperties& constProps
290 //- Construct from Istream
293 const Cloud<ParcelType>& c,
295 bool readFields = true
298 //- Construct as a copy
299 KinematicParcel(const KinematicParcel& p);
301 //- Construct and return a clone
302 autoPtr<KinematicParcel> clone() const
304 return autoPtr<KinematicParcel>(new KinematicParcel(*this));
312 //- Return const access to type id
313 inline label typeId() const;
315 //- Return const access to number of particles
316 inline scalar nParticle() const;
318 //- Return const access to diameter
319 inline scalar d() const;
321 //- Return const access to velocity
322 inline const vector& U() const;
324 //- Return const access to density
325 inline scalar rho() const;
327 //- Return const access to time spent in turbulent eddy
328 inline scalar tTurb() const;
330 //- Return const access to turbulent velocity fluctuation
331 inline const vector& UTurb() const;
336 //- Return access to type id
337 inline label typeId();
339 //- Return access to number of particles
340 inline scalar& nParticle();
342 //- Return access to diameter
345 //- Return access to velocity
348 //- Return access to density
349 inline scalar& rho();
351 //- Return access to time spent in turbulent eddy
352 inline scalar& tTurb();
354 //- Return access to turbulent velocity fluctuation
355 inline vector& UTurb();
360 //- The nearest distance to a wall that
361 // the particle can be in the n direction
362 inline scalar wallImpactDistance(const vector& n) const;
364 //- Return the index of the face to be used in the interpolation
366 inline label faceInterpolation() const;
369 inline scalar massCell(const label cellI) const;
372 inline scalar mass() const;
375 inline scalar volume() const;
377 //- Particle volume for a given diameter
378 inline scalar volume(const scalar d) const;
380 //- Particle projected area
381 inline scalar areaP() const;
383 //- Projected area for given diameter
384 inline scalar areaP(const scalar d) const;
386 //- Particle surface area
387 inline scalar areaS() const;
389 //- Surface area for given diameter
390 inline scalar areaS(const scalar d) const;
395 const vector& U, // particle velocity
396 const scalar d, // particle diameter
397 const scalar rhoc, // carrier density
398 const scalar muc // carrier dynamic viscosity
402 // Main calculation loop
405 template<class TrackData>
413 //- Correct cell values using latest transfer information
414 template<class TrackData>
415 void cellValueSourceCorrection
422 //- Update parcel properties over the time interval
423 template<class TrackData>
435 template<class TrackData>
436 bool move(TrackData& td);
439 // Patch interactions
441 //- Overridable function to handle the particle hitting a patch
442 // Executed before other patch-hitting functions
443 template<class TrackData>
452 //- Overridable function to handle the particle hitting a patch
453 // Executed before other patch-hitting functions without trackData
462 //- Overridable function to handle the particle hitting a
464 template<class TrackData>
465 void hitProcessorPatch
467 const processorPolyPatch&,
471 //- Overridable function to handle the particle hitting a
472 // processorPatch without trackData
473 void hitProcessorPatch
475 const processorPolyPatch&,
479 //- Overridable function to handle the particle hitting a wallPatch
480 template<class TrackData>
483 const wallPolyPatch&,
487 //- Overridable function to handle the particle hitting a wallPatch
491 const wallPolyPatch&,
495 //- Overridable function to handle the particle hitting a polyPatch
496 template<class TrackData>
503 //- Overridable function to handle the particle hitting a polyPatch
504 //- without trackData
511 //- Transform the physical properties of the particle
512 // according to the given transformation tensor
513 void transformProperties(const tensor& T);
515 //- Transform the physical properties of the particle
516 // according to the given separation vector
517 void transformProperties(const vector& separation);
523 static void readFields(Cloud<ParcelType>& c);
526 static void writeFields(const Cloud<ParcelType>& c);
531 friend Ostream& operator<< <ParcelType>
534 const KinematicParcel<ParcelType>&
539 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
541 } // End namespace Foam
543 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
545 #include "KinematicParcelI.H"
547 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
549 #define defineParcelTypeNameAndDebug(Type, DebugSwitch) \
551 const Foam::word KinematicParcel<Type>::typeName(#Type); \
553 int KinematicParcel<Type>::debug \
555 Foam::debug::debugSwitch(#Type, DebugSwitch) \
558 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
561 #include "KinematicParcel.C"
564 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
568 // ************************************************************************* //