1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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
30 \*---------------------------------------------------------------------------*/
37 #include "labelList.H"
38 #include "pointField.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 template<class Particle>
52 class symmetryPolyPatch;
53 class cyclicPolyPatch;
54 class processorPolyPatch;
58 // Forward declaration of friend functions and operators
60 template<class ParticleType>
63 template<class ParticleType>
67 const Particle<ParticleType>&
71 /*---------------------------------------------------------------------------*\
72 Class Particle Declaration
73 \*---------------------------------------------------------------------------*/
75 template<class ParticleType>
78 public IDLList<ParticleType>::link
83 //- Class used to pass tracking data to the trackToFace function
89 //- Reference to the cloud containing this particle
90 Cloud<ParticleType>& cloud_;
103 Cloud<ParticleType>& cloud
109 //- Return a reference to the cloud
110 inline Cloud<ParticleType>& cloud();
118 //- Reference to the particle cloud
119 const Cloud<ParticleType>& cloud_;
121 //- Position of particle
124 //- Index of the cell it is in
127 //- Face index if the particle is on a face otherwise -1
130 //- Fraction of time-step completed
131 scalar stepFraction_;
134 // Private member functions
136 //- Return the 'lambda' value for the position, p, on the face,
137 // where, p = from + lamda*(to - from)
138 // for non-static meshes
144 const scalar stepFraction
147 //- Return the 'lambda' value for the position, p, on the face,
148 // where, p = from + lamda*(to - from)
157 //- Return the faces between position and cell centre
160 const vector& position
163 //- Return the faces between position and cell centre
166 const vector& position,
168 const scalar stepFraction
172 // Patch interactions
174 //- Overridable function to handle the particle hitting a wedgePatch
175 template<class TrackData>
178 const wedgePolyPatch&,
182 //- Overridable function to handle the particle hitting a
184 template<class TrackData>
185 void hitSymmetryPatch
187 const symmetryPolyPatch&,
191 //- Overridable function to handle the particle hitting a cyclicPatch
192 template<class TrackData>
195 const cyclicPolyPatch&,
199 //- Overridable function to handle the particle hitting a
201 template<class TrackData>
202 void hitProcessorPatch
204 const processorPolyPatch&,
208 //- Overridable function to handle the particle hitting a wallPatch
209 template<class TrackData>
212 const wallPolyPatch&,
216 //- Overridable function to handle the particle hitting a
218 template<class TrackData>
228 //- Transform the position the particle
229 // according to the given transformation tensor
230 virtual void transformPosition(const tensor& T);
232 //- Transform the physical properties of the particle
233 // according to the given transformation tensor
234 virtual void transformProperties(const tensor& T);
236 //- Transform the physical properties of the particle
237 // according to the given separation vector
238 virtual void transformProperties(const vector& separation);
243 //- Convert global addressing to the processor patch
245 template<class TrackData>
246 void prepareForParallelTransfer(const label patchi, TrackData& td);
248 //- Convert processor patch addressing to the global equivalents
249 // and set the celli to the face-neighbour
250 template<class TrackData>
251 void correctAfterParallelTransfer(const label patchi, TrackData& td);
256 friend class Cloud<ParticleType>;
259 //- Runtime type information
260 TypeName("Particle");
265 //- Construct from components
268 const Cloud<ParticleType>&,
269 const vector& position,
273 //- Construct from Istream
276 const Cloud<ParticleType>&,
278 bool readFields = true
281 //- Factory class to read-construct particles used for
288 const Cloud<ParticleType>& cloud_;
293 iNew(const Cloud<ParticleType>& cloud)
298 autoPtr<ParticleType> operator()(Istream& is) const
300 return autoPtr<ParticleType>(new ParticleType(cloud_, is));
315 //- Return true if particle is in cell
316 inline bool inCell() const;
318 //- Return true if position is in cell i
321 const vector& position,
323 const scalar stepFraction
326 //- Return current particle position
327 inline const vector& position() const;
329 //- Return current particle position
330 inline vector& position();
332 //- Return current cell particle is in
333 inline label& cell();
335 //- Return current cell particle is in
336 inline label cell() const;
338 //- Return current face particle is on otherwise -1
339 inline label face() const;
341 //- Return reference to the particle cloud
342 inline const Cloud<ParticleType>& cloud() const;
344 //- Return the impact model to be used, soft or hard (default).
345 inline bool softImpact() const;
350 //- Is the particle on the boundary/(or outside the domain)?
351 inline bool onBoundary() const;
353 //- Which patch is particle on
354 inline label patch(const label facei) const;
356 //- Which face of this patch is this particle on
357 inline label patchFace
363 //- The nearest distance to a wall that
364 // the particle can be in the n direction
365 inline scalar wallImpactDistance(const vector& n) const;
367 //- Return the fraction of time-step completed
368 inline scalar& stepFraction();
370 //- Return the fraction of time-step completed
371 inline scalar stepFraction() const;
376 //- Track particle to end of trajectory
377 // or until it hits the boundary.
378 // On entry 'stepFraction()' should be set to the fraction of the
379 // time-step at which the tracking starts and on exit it contains
380 // the fraction of the time-step completed.
381 // Returns the boundary face index if the track stops at the
382 // boundary, -1 otherwise.
383 template<class TrackData>
386 const vector& endPosition,
390 //- Calls the templated track with dummy TrackData
391 label track(const vector& endPosition);
393 //- Track particle to a given position and returns 1.0 if the
394 // trajectory is completed without hitting a face otherwise
395 // stops at the face and returns the fraction of the trajectory
397 // on entry 'stepFraction()' should be set to the fraction of the
398 // time-step at which the tracking starts.
399 template<class TrackData>
402 const vector& endPosition,
406 //- Calls the templated trackToFace with dummy TrackData
407 scalar trackToFace(const vector& endPosition);
409 //- Return the index of the face to be used in the interpolation
411 inline label faceInterpolation() const;
416 //- Write the fields associated with the owner cloud
417 static void writeFields
419 const Cloud<ParticleType>& c
425 friend Ostream& operator<< <ParticleType>
428 const Particle<ParticleType>&
433 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
435 } // End namespace Foam
437 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
439 #include "ParticleI.H"
441 #define defineParticleTypeNameAndDebug(Type, DebugSwitch) \
443 const Foam::word Particle<Type>::typeName(#Type); \
445 int Particle<Type>::debug(Foam::debug::debugSwitch(#Type, DebugSwitch));
447 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
450 # include "Particle.C"
453 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
457 // ************************************************************************* //