KinematicParcel.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) 2011-2016 OpenFOAM Foundation
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::KinematicParcel
26 
27 Description
28  Kinematic parcel class with rotational motion (as spherical
29  particles only) and one/two-way coupling with the continuous
30  phase.
31 
32  Sub-models include:
33  - drag
34  - turbulent dispersion
35  - wall interactions
36 
37 SourceFiles
38  KinematicParcelI.H
39  KinematicParcel.C
40  KinematicParcelIO.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef KinematicParcel_H
45 #define KinematicParcel_H
46 
47 #include "particle.H"
48 #include "IOstream.H"
49 #include "autoPtr.H"
50 #include "interpolation.H"
51 #include "demandDrivenEntry.H"
52 
53 // #include "ParticleForceList.H" // TODO
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 template<class ParcelType>
61 class KinematicParcel;
62 
63 // Forward declaration of friend functions
64 
65 template<class ParcelType>
66 Ostream& operator<<
67 (
68  Ostream&,
70 );
71 
72 /*---------------------------------------------------------------------------*\
73  Class KinematicParcel Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 template<class ParcelType>
77 class KinematicParcel
78 :
79  public ParcelType
80 {
81  // Private data
82 
83  //- Size in bytes of the fields
84  static const std::size_t sizeofFields_;
85 
86  //- Number of particle tracking attempts before we assume that it stalls
87  static label maxTrackAttempts;
88 
89 
90 public:
91 
92  //- Class to hold kinematic particle constant properties
93  class constantProperties
94  {
95  protected:
96 
97  // Protected data
98 
99  //- Constant properties dictionary
100  const dictionary dict_;
101 
102 
103  private:
104 
105  // Private data
106 
107  //- Parcel type id - used for post-processing to flag the type
108  // of parcels issued by this cloud
109  demandDrivenEntry<label> parcelTypeId_;
110 
111  //- Minimum density [kg/m3]
113 
114  //- Particle density [kg/m3] (constant)
116 
117  //- Minimum parcel mass [kg]
118  demandDrivenEntry<scalar> minParcelMass_;
119 
120 
121  public:
122 
123  // Constructors
124 
125  //- Null constructor
127 
128  //- Copy constructor
130 
131  //- Construct from dictionary
132  constantProperties(const dictionary& parentDict);
133 
134 
135  // Member functions
136 
137  //- Return const access to the constant properties dictionary
138  inline const dictionary& dict() const;
139 
140  //- Return const access to the parcel type id
141  inline label parcelTypeId() const;
142 
143  //- Return const access to the minimum density
144  inline scalar rhoMin() const;
145 
146  //- Return const access to the particle density
147  inline scalar rho0() const;
148 
149  //- Return const access to the minimum parcel mass
150  inline scalar minParcelMass() const;
151  };
152 
153 
154  template<class CloudType>
155  class TrackingData
156  :
157  public ParcelType::template TrackingData<CloudType>
158  {
159  public:
161  enum trackPart
162  {
163  tpVelocityHalfStep,
164  tpLinearTrack,
165  tpRotationalTrack
166  };
167 
168 
169  private:
170 
171  // Private data
172 
173  // Interpolators for continuous phase fields
174 
175  //- Density interpolator
176  autoPtr<interpolation<scalar>> rhoInterp_;
177 
178  //- Velocity interpolator
180 
181  //- Dynamic viscosity interpolator
183 
184 
185  //- Local gravitational or other body-force acceleration
186  const vector& g_;
187 
188  // label specifying which part of the integration
189  // algorithm is taking place
190  trackPart part_;
191 
192 
193  public:
194 
195  // Constructors
196 
197  //- Construct from components
198  inline TrackingData
199  (
200  CloudType& cloud,
201  trackPart part = tpLinearTrack
202  );
203 
204 
205  // Member functions
206 
207  //- Return conat access to the interpolator for continuous
208  // phase density field
209  inline const interpolation<scalar>& rhoInterp() const;
210 
211  //- Return conat access to the interpolator for continuous
212  // phase velocity field
213  inline const interpolation<vector>& UInterp() const;
214 
215  //- Return conat access to the interpolator for continuous
216  // phase dynamic viscosity field
217  inline const interpolation<scalar>& muInterp() const;
218 
219  // Return const access to the gravitational acceleration vector
220  inline const vector& g() const;
221 
222  //- Return the part of the tracking operation taking place
223  inline trackPart part() const;
224 
225  //- Return access to the part of the tracking operation taking place
226  inline trackPart& part();
227  };
228 
229 
230 protected:
231 
232  // Protected data
233 
234  // Parcel properties
235 
236  //- Active flag - tracking inactive when active = false
237  bool active_;
238 
239  //- Parcel type id
240  label typeId_;
241 
242  //- Number of particles in Parcel
243  scalar nParticle_;
244 
245  //- Diameter [m]
246  scalar d_;
247 
248  //- Target diameter [m]
249  scalar dTarget_;
250 
251  //- Velocity of Parcel [m/s]
252  vector U_;
253 
254  //- Density [kg/m3]
255  scalar rho_;
256 
257  //- Age [s]
258  scalar age_;
259 
260  //- Time spent in turbulent eddy [s]
261  scalar tTurb_;
262 
263  //- Turbulent velocity fluctuation [m/s]
264  vector UTurb_;
265 
266 
267  // Cell-based quantities
268 
269  //- Density [kg/m3]
270  scalar rhoc_;
271 
272  //- Velocity [m/s]
273  vector Uc_;
274 
275  //- Viscosity [Pa.s]
276  scalar muc_;
277 
278 
279  // Protected Member Functions
280 
281  //- Calculate new particle velocity
282  template<class TrackData>
283  const vector calcVelocity
284  (
285  TrackData& td,
286  const scalar dt, // timestep
287  const label celli, // owner cell
288  const scalar Re, // Reynolds number
289  const scalar mu, // local carrier viscosity
290  const scalar mass, // mass
291  const vector& Su, // explicit particle momentum source
292  vector& dUTrans, // momentum transfer to carrier
293  scalar& Spu // linearised drag coefficient
294  ) const;
295 
296 
297 public:
298 
299  // Static data members
300 
301  //- Runtime type information
302  TypeName("KinematicParcel");
303 
304  //- String representation of properties
306  (
307  ParcelType,
308  " active"
309  + " typeId"
310  + " nParticle"
311  + " d"
312  + " dTarget "
313  + " (Ux Uy Uz)"
314  + " rho"
315  + " age"
316  + " tTurb"
317  + " (UTurbx UTurby UTurbz)"
318  );
319 
320 
321  // Constructors
322 
323  //- Construct from owner, position, and cloud owner
324  // Other properties initialised as null
325  inline KinematicParcel
326  (
327  const polyMesh& mesh,
328  const vector& position,
329  const label celli,
330  const label tetFacei,
331  const label tetPtI
332  );
333 
334  //- Construct from components
335  inline KinematicParcel
336  (
337  const polyMesh& mesh,
338  const vector& position,
339  const label celli,
340  const label tetFacei,
341  const label tetPtI,
342  const label typeId,
343  const scalar nParticle0,
344  const scalar d0,
345  const scalar dTarget0,
346  const vector& torque0,
347  const constantProperties& constProps
348  );
349 
350  //- Construct from Istream
352  (
353  const polyMesh& mesh,
354  Istream& is,
355  bool readFields = true
356  );
357 
358  //- Construct as a copy
360 
361  //- Construct as a copy
363 
364  //- Construct and return a (basic particle) clone
365  virtual autoPtr<particle> clone() const
366  {
367  return autoPtr<particle>(new KinematicParcel(*this));
368  }
369 
370  //- Construct and return a (basic particle) clone
371  virtual autoPtr<particle> clone(const polyMesh& mesh) const
372  {
373  return autoPtr<particle>(new KinematicParcel(*this, mesh));
374  }
375 
376  //- Factory class to read-construct particles used for
377  // parallel transfer
378  class iNew
379  {
380  const polyMesh& mesh_;
381 
382  public:
384  iNew(const polyMesh& mesh)
385  :
386  mesh_(mesh)
387  {}
389  autoPtr<KinematicParcel<ParcelType>> operator()(Istream& is) const
390  {
392  (
393  new KinematicParcel<ParcelType>(mesh_, is, true)
394  );
395  }
396  };
397 
398 
399  // Member Functions
400 
401  // Access
402 
403  //- Return const access to active flag
404  inline bool active() const;
405 
406  //- Return const access to type id
407  inline label typeId() const;
408 
409  //- Return const access to number of particles
410  inline scalar nParticle() const;
411 
412  //- Return const access to diameter
413  inline scalar d() const;
414 
415  //- Return const access to target diameter
416  inline scalar dTarget() const;
417 
418  //- Return const access to velocity
419  inline const vector& U() const;
420 
421  //- Return const access to density
422  inline scalar rho() const;
423 
424  //- Return const access to the age
425  inline scalar age() const;
426 
427  //- Return const access to time spent in turbulent eddy
428  inline scalar tTurb() const;
429 
430  //- Return const access to turbulent velocity fluctuation
431  inline const vector& UTurb() const;
432 
433  //- Return const access to carrier density [kg/m3]
434  inline scalar rhoc() const;
435 
436  //- Return const access to carrier velocity [m/s]
437  inline const vector& Uc() const;
438 
439  //- Return const access to carrier viscosity [Pa.s]
440  inline scalar muc() const;
441 
442 
443  // Edit
444 
445  //- Return const access to active flag
446  inline bool& active();
447 
448  //- Return access to type id
449  inline label& typeId();
450 
451  //- Return access to number of particles
452  inline scalar& nParticle();
453 
454  //- Return access to diameter
455  inline scalar& d();
456 
457  //- Return access to target diameter
458  inline scalar& dTarget();
459 
460  //- Return access to velocity
461  inline vector& U();
462 
463  //- Return access to density
464  inline scalar& rho();
465 
466  //- Return access to the age
467  inline scalar& age();
468 
469  //- Return access to time spent in turbulent eddy
470  inline scalar& tTurb();
471 
472  //- Return access to turbulent velocity fluctuation
473  inline vector& UTurb();
474 
475 
476  // Helper functions
477 
478  //- Return the index of the face used in the interpolation routine
479  inline label faceInterpolation() const;
480 
481  //- Cell owner mass
482  inline scalar massCell(const label celli) const;
483 
484  //- Particle mass
485  inline scalar mass() const;
486 
487  //- Particle moment of inertia around diameter axis
488  inline scalar momentOfInertia() const;
489 
490  //- Particle volume
491  inline scalar volume() const;
492 
493  //- Particle volume for a given diameter
494  inline static scalar volume(const scalar d);
495 
496  //- Particle projected area
497  inline scalar areaP() const;
498 
499  //- Projected area for given diameter
500  inline static scalar areaP(const scalar d);
501 
502  //- Particle surface area
503  inline scalar areaS() const;
504 
505  //- Surface area for given diameter
506  inline static scalar areaS(const scalar d);
507 
508  //- Reynolds number
509  inline scalar Re
510  (
511  const vector& U, // particle velocity
512  const scalar d, // particle diameter
513  const scalar rhoc, // carrier density
514  const scalar muc // carrier dynamic viscosity
515  ) const;
516 
517  //- Weber number
518  inline scalar We
519  (
520  const vector& U, // particle velocity
521  const scalar d, // particle diameter
522  const scalar rhoc, // carrier density
523  const scalar sigma // particle surface tension
524  ) const;
525 
526  //- Eotvos number
527  inline scalar Eo
528  (
529  const vector& a, // acceleration
530  const scalar d, // particle diameter
531  const scalar sigma // particle surface tension
532  ) const;
533 
534 
535  // Main calculation loop
536 
537  //- Set cell values
538  template<class TrackData>
539  void setCellValues
540  (
541  TrackData& td,
542  const scalar dt,
543  const label celli
544  );
545 
546  //- Correct cell values using latest transfer information
547  template<class TrackData>
549  (
550  TrackData& td,
551  const scalar dt,
552  const label celli
553  );
554 
555  //- Update parcel properties over the time interval
556  template<class TrackData>
557  void calc
558  (
559  TrackData& td,
560  const scalar dt,
561  const label celli
562  );
563 
564 
565  // Tracking
566 
567  //- Move the parcel
568  template<class TrackData>
569  bool move(TrackData& td, const scalar trackTime);
570 
571 
572  // Patch interactions
573 
574  //- Overridable function to handle the particle hitting a face
575  // without trackData
576  void hitFace(int& td);
577 
578  //- Overridable function to handle the particle hitting a face
579  template<class TrackData>
580  void hitFace(TrackData& td);
581 
582  //- Overridable function to handle the particle hitting a patch
583  // Executed before other patch-hitting functions
584  template<class TrackData>
585  bool hitPatch
586  (
587  const polyPatch& p,
588  TrackData& td,
589  const label patchi,
590  const scalar trackFraction,
591  const tetIndices& tetIs
592  );
593 
594  //- Overridable function to handle the particle hitting a
595  // processorPatch
596  template<class TrackData>
597  void hitProcessorPatch
598  (
599  const processorPolyPatch&,
600  TrackData& td
601  );
602 
603  //- Overridable function to handle the particle hitting a wallPatch
604  template<class TrackData>
605  void hitWallPatch
606  (
607  const wallPolyPatch&,
608  TrackData& td,
609  const tetIndices&
610  );
611 
612  //- Overridable function to handle the particle hitting a polyPatch
613  template<class TrackData>
614  void hitPatch
615  (
616  const polyPatch&,
617  TrackData& td
618  );
619 
620  //- Transform the physical properties of the particle
621  // according to the given transformation tensor
622  virtual void transformProperties(const tensor& T);
623 
624  //- Transform the physical properties of the particle
625  // according to the given separation vector
626  virtual void transformProperties(const vector& separation);
627 
628  //- The nearest distance to a wall that the particle can be
629  // in the n direction
630  virtual scalar wallImpactDistance(const vector& n) const;
631 
632 
633  // I-O
634 
635  //- Read
636  template<class CloudType>
637  static void readFields(CloudType& c);
638 
639  //- Write
640  template<class CloudType>
641  static void writeFields(const CloudType& c);
642 
643 
644  // Ostream Operator
645 
646  friend Ostream& operator<< <ParcelType>
647  (
648  Ostream&,
650  );
651 };
652 
653 
654 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
655 
656 } // End namespace Foam
657 
658 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
659 
660 #include "KinematicParcelI.H"
662 
663 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
664 
665 #ifdef NoRepository
666  #include "KinematicParcel.C"
667 #endif
668 
669 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
670 
671 #endif
672 
673 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
static void readFields(CloudType &c)
Read.
scalar mass() const
Particle mass.
bool hitPatch(const polyPatch &p, TrackData &td, const label patchi, const scalar trackFraction, const tetIndices &tetIs)
Overridable function to handle the particle hitting a patch.
virtual autoPtr< particle > clone() const
Construct and return a (basic particle) clone.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Kinematic parcel class with rotational motion (as spherical particles only) and one/two-way coupling ...
scalar Eo(const vector &a, const scalar d, const scalar sigma) const
Eotvos number.
scalar Re(const vector &U, const scalar d, const scalar rhoc, const scalar muc) const
Reynolds number.
const dictionary & dict() const
Return const access to the constant properties dictionary.
TypeName("KinematicParcel")
Runtime type information.
scalar rho0() const
Return const access to the particle density.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Class to hold kinematic particle constant properties.
scalar rho() const
Return const access to density.
scalar tTurb_
Time spent in turbulent eddy [s].
scalar age_
Age [s].
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m2/K4].
KinematicParcel(const polyMesh &mesh, const vector &position, const label celli, const label tetFacei, const label tetPtI)
Construct from owner, position, and cloud owner.
label faceInterpolation() const
Return the index of the face used in the interpolation routine.
bool cp(const fileName &src, const fileName &dst)
Copy, recursively if necessary, the source to the destination.
Definition: POSIX.C:620
const vector & Uc() const
Return const access to carrier velocity [m/s].
scalar volume() const
Particle volume.
scalar massCell(const label celli) const
Cell owner mass.
virtual scalar wallImpactDistance(const vector &n) const
The nearest distance to a wall that the particle can be.
Factory class to read-construct particles used for.
scalar dTarget() const
Return const access to target diameter.
AddToPropertyList(ParcelType," active"+" typeId"+" nParticle"+" d"+" dTarget "+" (Ux Uy Uz)"+" rho"+" age"+" tTurb"+" (UTurbx UTurby UTurbz)")
String representation of properties.
const vector & UTurb() const
Return const access to turbulent velocity fluctuation.
scalar muc() const
Return const access to carrier viscosity [Pa.s].
vector Uc_
Velocity [m/s].
Neighbour processor patch.
scalar areaS() const
Particle surface area.
bool move(TrackData &td, const scalar trackTime)
Move the parcel.
scalar dTarget_
Target diameter [m].
scalar rhoc() const
Return const access to carrier density [kg/m3].
scalar tTurb() const
Return const access to time spent in turbulent eddy.
scalar We(const vector &U, const scalar d, const scalar rhoc, const scalar sigma) const
Weber number.
scalar momentOfInertia() const
Particle moment of inertia around diameter axis.
dynamicFvMesh & mesh
scalar rho_
Density [kg/m3].
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
scalar muc_
Viscosity [Pa.s].
void hitFace(int &td)
Overridable function to handle the particle hitting a face.
bool active_
Active flag - tracking inactive when active = false.
const dictionary dict_
Constant properties dictionary.
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
Foam::wallPolyPatch.
Definition: wallPolyPatch.H:48
label typeId_
Parcel type id.
vector UTurb_
Turbulent velocity fluctuation [m/s].
label parcelTypeId() const
Return const access to the parcel type id.
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
const vector calcVelocity(TrackData &td, const scalar dt, const label celli, const scalar Re, const scalar mu, const scalar mass, const vector &Su, vector &dUTrans, scalar &Spu) const
Calculate new particle velocity.
scalar age() const
Return const access to the age.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const dimensionedVector & g
scalar nParticle_
Number of particles in Parcel.
void cellValueSourceCorrection(TrackData &td, const scalar dt, const label celli)
Correct cell values using latest transfer information.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void calc(TrackData &td, const scalar dt, const label celli)
Update parcel properties over the time interval.
const dimensionedScalar mu
Atomic mass unit.
scalar rhoc_
Density [kg/m3].
vector U_
Velocity of Parcel [m/s].
label patchi
scalar rhoMin() const
Return const access to the minimum density.
bool active() const
Return const access to active flag.
const dimensionedScalar c
Speed of light in a vacuum.
void setCellValues(TrackData &td, const scalar dt, const label celli)
Set cell values.
static void writeFields(const CloudType &c)
Write.
void hitWallPatch(const wallPolyPatch &, TrackData &td, const tetIndices &)
Overridable function to handle the particle hitting a wallPatch.
label n
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
void hitProcessorPatch(const processorPolyPatch &, TrackData &td)
Overridable function to handle the particle hitting a.
volScalarField & p
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
scalar areaP() const
Particle projected area.
tmp< GeometricField< Type, fvPatchField, volMesh > > Su(const GeometricField< Type, fvPatchField, volMesh > &su, const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvcSup.C:44
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
scalar d() const
Return const access to diameter.
scalar d_
Diameter [m].
scalar nParticle() const
Return const access to number of particles.
scalar minParcelMass() const
Return const access to the minimum parcel mass.
Namespace for OpenFOAM.
const vector & U() const
Return const access to velocity.
label typeId() const
Return const access to type id.