Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 #ifndef Particle_H
00032 #define Particle_H
00033 
00034 #include <OpenFOAM/vector.H>
00035 #include <OpenFOAM/IDLList.H>
00036 #include <OpenFOAM/labelList.H>
00037 #include <OpenFOAM/pointField.H>
00038 #include <OpenFOAM/faceList.H>
00039 #include <OpenFOAM/typeInfo.H>
00040 #include <OpenFOAM/OFstream.H>
00041 
00042 
00043 
00044 namespace Foam
00045 {
00046 
00047 template<class Particle>
00048 class Cloud;
00049 
00050 class wedgePolyPatch;
00051 class symmetryPolyPatch;
00052 class cyclicPolyPatch;
00053 class processorPolyPatch;
00054 class wallPolyPatch;
00055 class polyPatch;
00056 
00057 
00058 
00059 template<class ParticleType>
00060 class Particle;
00061 
00062 template<class ParticleType>
00063 Ostream& operator<<
00064 (
00065     Ostream&,
00066     const Particle<ParticleType>&
00067 );
00068 
00069 
00070 
00071 
00072 
00073 
00074 template<class ParticleType>
00075 class Particle
00076 :
00077     public IDLList<ParticleType>::link
00078 {
00079 
00080 public:
00081 
00082     
00083     class trackData
00084     {
00085 
00086         
00087 
00088             
00089             Cloud<ParticleType>& cloud_;
00090 
00091 
00092     public:
00093 
00094         bool switchProcessor;
00095         bool keepParticle;
00096 
00097 
00098         
00099 
00100             inline trackData(Cloud<ParticleType>& cloud);
00101 
00102 
00103         
00104 
00105             
00106             inline Cloud<ParticleType>& cloud();
00107     };
00108 
00109 
00110 protected:
00111 
00112     
00113 
00114         
00115         const Cloud<ParticleType>& cloud_;
00116 
00117         
00118         vector position_;
00119 
00120         
00121         label celli_;
00122 
00123         
00124         label facei_;
00125 
00126         
00127         scalar stepFraction_;
00128 
00129         
00130         label origProc_;
00131 
00132         
00133         label origId_;
00134 
00135 
00136     
00137 
00138         
00139         
00140         
00141         inline scalar lambda
00142         (
00143             const vector& from,
00144             const vector& to,
00145             const label facei,
00146             const scalar stepFraction
00147         ) const;
00148 
00149         
00150         
00151         
00152         inline scalar lambda
00153         (
00154             const vector& from,
00155             const vector& to,
00156             const label facei
00157         ) const;
00158 
00159         
00160         void findFaces
00161         (
00162             const vector& position,
00163             DynamicList<label>& faceList
00164         ) const;
00165 
00166         
00167         void findFaces
00168         (
00169             const vector& position,
00170             const label celli,
00171             const scalar stepFraction,
00172             DynamicList<label>& faceList
00173         ) const;
00174 
00175 
00176     
00177 
00178         
00179         
00180         template<class TrackData>
00181         bool hitPatch
00182         (
00183             const polyPatch&,
00184             TrackData& td,
00185             const label patchI
00186         );
00187 
00188         
00189         template<class TrackData>
00190         void hitWedgePatch
00191         (
00192             const wedgePolyPatch&,
00193             TrackData& td
00194         );
00195 
00196         
00197         
00198         template<class TrackData>
00199         void hitSymmetryPatch
00200         (
00201             const symmetryPolyPatch&,
00202             TrackData& td
00203         );
00204 
00205         
00206         template<class TrackData>
00207         void hitCyclicPatch
00208         (
00209             const cyclicPolyPatch&,
00210             TrackData& td
00211         );
00212 
00213         
00214         
00215         template<class TrackData>
00216         void hitProcessorPatch
00217         (
00218             const processorPolyPatch&,
00219             TrackData& td
00220         );
00221 
00222         
00223         template<class TrackData>
00224         void hitWallPatch
00225         (
00226             const wallPolyPatch&,
00227             TrackData& td
00228         );
00229 
00230         
00231         
00232         template<class TrackData>
00233         void hitPatch
00234         (
00235             const polyPatch&,
00236             TrackData& td
00237         );
00238 
00239 
00240     
00241 
00242         
00243         
00244         virtual void transformPosition(const tensor& T);
00245 
00246         
00247         
00248         virtual void transformProperties(const tensor& T);
00249 
00250         
00251         
00252         virtual void transformProperties(const vector& separation);
00253 
00254 
00255     
00256 
00257         
00258         
00259         template<class TrackData>
00260         void prepareForParallelTransfer(const label patchi, TrackData& td);
00261 
00262         
00263         
00264         template<class TrackData>
00265         void correctAfterParallelTransfer(const label patchi, TrackData& td);
00266 
00267 
00268 public:
00269 
00270     friend class Cloud<ParticleType>;
00271 
00272 
00273     
00274 
00275         
00276         TypeName("Particle");
00277 
00278         
00279         static string propHeader;
00280 
00281 
00282     
00283 
00284         
00285         Particle
00286         (
00287             const Cloud<ParticleType>&,
00288             const vector& position,
00289             const label celli
00290         );
00291 
00292         
00293         Particle
00294         (
00295             const Cloud<ParticleType>&,
00296             Istream&,
00297             bool readFields = true
00298         );
00299 
00300         
00301         Particle(const Particle& p);
00302 
00303         
00304         autoPtr<ParticleType> clone() const
00305         {
00306             return autoPtr<Particle>(new Particle(*this));
00307         }
00308 
00309 
00310         
00311         
00312         class iNew
00313         {
00314             
00315 
00316                 
00317                 const Cloud<ParticleType>& cloud_;
00318 
00319 
00320         public:
00321 
00322             iNew(const Cloud<ParticleType>& cloud)
00323             :
00324                 cloud_(cloud)
00325             {}
00326 
00327             autoPtr<ParticleType> operator()(Istream& is) const
00328             {
00329                 return autoPtr<ParticleType>
00330                 (
00331                     new ParticleType
00332                     (
00333                         cloud_,
00334                         is,
00335                         true
00336                     )
00337                 );
00338             }
00339         };
00340 
00341 
00342     
00343     virtual ~Particle()
00344     {}
00345 
00346 
00347     
00348 
00349         
00350 
00351             
00352             inline bool inCell() const;
00353 
00354             
00355             inline bool inCell
00356             (
00357                 const vector& position,
00358                 const label celli,
00359                 const scalar stepFraction
00360             ) const;
00361 
00362             
00363             inline const vector& position() const;
00364 
00365             
00366             inline vector& position();
00367 
00368             
00369             inline label& cell();
00370 
00371             
00372             inline label cell() const;
00373 
00374             
00375             inline label face() const;
00376 
00377             
00378             inline const Cloud<ParticleType>& cloud() const;
00379 
00380             
00381             inline bool softImpact() const;
00382 
00383             
00384             inline scalar currentTime() const;
00385 
00386 
00387         
00388 
00389             
00390             inline bool onBoundary() const;
00391 
00392             
00393             inline label patch(const label facei) const;
00394 
00395             
00396             inline label patchFace
00397             (
00398                 const label patchi,
00399                 const label facei
00400             ) const;
00401 
00402             
00403             
00404             inline scalar wallImpactDistance(const vector& n) const;
00405 
00406             
00407             inline scalar& stepFraction();
00408 
00409             
00410             inline scalar stepFraction() const;
00411 
00412             
00413             inline label origProc() const;
00414 
00415             
00416             inline label origId() const;
00417 
00418 
00419         
00420 
00421             
00422             
00423             
00424             
00425             
00426             
00427             
00428             template<class TrackData>
00429             label track
00430             (
00431                 const vector& endPosition,
00432                 TrackData& td
00433             );
00434 
00435             
00436             label track(const vector& endPosition);
00437 
00438             
00439             
00440             
00441             
00442             
00443             
00444             template<class TrackData>
00445             scalar trackToFace
00446             (
00447                 const vector& endPosition,
00448                 TrackData& td
00449             );
00450 
00451             
00452             scalar trackToFace(const vector& endPosition);
00453 
00454             
00455             
00456             inline label faceInterpolation() const;
00457 
00458 
00459     
00460 
00461         
00462         static void readFields(Cloud<ParticleType>& c);
00463 
00464         
00465         static void writeFields(const Cloud<ParticleType>& c);
00466 
00467         
00468         void write(Ostream& os, bool writeFields) const;
00469 
00470     
00471 
00472         friend Ostream& operator<< <ParticleType>
00473         (
00474             Ostream&,
00475             const Particle<ParticleType>&
00476         );
00477 };
00478 
00479 
00480 
00481 
00482 } 
00483 
00484 
00485 
00486 #include <lagrangian/ParticleI.H>
00487 
00488 #define defineParticleTypeNameAndDebug(Type, DebugSwitch)                     \
00489     template<>                                                                \
00490     const Foam::word Particle<Type>::typeName(#Type);                         \
00491     template<>                                                                \
00492     int Particle<Type>::debug(Foam::debug::debugSwitch(#Type, DebugSwitch));
00493 
00494 
00495 
00496 #ifdef NoRepository
00497 #   include <lagrangian/Particle.C>
00498 #endif
00499 
00500 
00501 
00502 #endif
00503 
00504