OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

ExactParticle.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::ExactParticle
00027 
00028 Description
00029     Special version of Particle to do tracking on non-convex cells.
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #ifndef ExactParticle_H
00034 #define ExactParticle_H
00035 
00036 #include "face.H"
00037 #include "Particle.H"
00038 
00039 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00040 
00041 namespace Foam
00042 {
00043 
00044 template<class ExactParticle>
00045 class Cloud;
00046 
00047 // Forward declaration of friend functions and operators
00048 
00049 template<class ParticleType>
00050 class ExactParticle;
00051 
00052 template<class ParticleType>
00053 Ostream& operator<<
00054 (
00055     Ostream&,
00056     const ExactParticle<ParticleType>&
00057 );
00058 
00059 
00060 /*---------------------------------------------------------------------------*\
00061                            Class ExactParticle Declaration
00062 \*---------------------------------------------------------------------------*/
00063 
00064 template<class ParticleType>
00065 class ExactParticle
00066 :
00067     public Particle<ParticleType>
00068 {
00069 
00070 public:
00071 
00072     friend class Cloud<ParticleType>;
00073 
00074 
00075     // Constructors
00076 
00077         //- Construct from components
00078         ExactParticle
00079         (
00080             const Cloud<ParticleType>& cloud,
00081             const vector& position,
00082             const label celli
00083         )
00084         :
00085             Particle<ParticleType>(cloud, position, celli)
00086         {}
00087             
00088 
00089         //- Construct from Istream
00090         ExactParticle
00091         (
00092             const Cloud<ParticleType>& cloud,
00093             Istream& is,
00094             bool readFields = true
00095         )
00096         :
00097             Particle<ParticleType>(cloud, is, readFields)
00098         {}
00099 
00100 
00101         //- Factory class to read-construct particles used for parallel transfer
00102         class iNew
00103         {
00104 
00105             // Private data
00106 
00107             const Cloud<ParticleType>& cloud_;
00108 
00109 
00110         public:
00111 
00112             iNew(const Cloud<ParticleType>& cloud)
00113             :
00114                 cloud_(cloud)
00115             {}
00116 
00117             autoPtr<ParticleType> operator()(Istream& is) const
00118             {
00119                 return autoPtr<ParticleType>
00120                 (
00121                     new ParticleType(cloud_, is)
00122                 );
00123             }
00124         };
00125 
00126 
00127     // Destructor
00128 
00129         virtual ~ExactParticle()
00130         {}
00131 
00132 
00133     // Member Functions
00134 
00135             //- Track particle to end of trajectory
00136             //  or until it hits the boundary.
00137             //  On entry 'stepFraction()' should be set to the fraction of the
00138             //  time-step at which the tracking starts and on exit it contains
00139             //  the fraction of the time-step completed.
00140             //  Returns the boundary face index if the track stops at the
00141             //  boundary, -1 otherwise.
00142             template<class TrackingData>
00143             label track
00144             (
00145                 const vector& endPosition,
00146                 TrackingData& td
00147             );
00148 
00149             //- Calls the templated track with dummy TrackingData
00150             label track(const vector& endPosition);
00151 
00152             //- Track particle to a given position and returns 1.0 if the
00153             //  trajectory is completed without hitting a face otherwise
00154             //  stops at the face and returns the fraction of the trajectory
00155             //  completed.
00156             //  on entry 'stepFraction()' should be set to the fraction of the
00157             //  time-step at which the tracking starts.
00158             template<class TrackingData>
00159             scalar trackToFace
00160             (
00161                 const vector& endPosition,
00162                 TrackingData& td
00163             );
00164 
00165             //- Calls the templated trackToFace with dummy TrackingData
00166             scalar trackToFace(const vector& endPosition);
00167 
00168 
00169     // Ostream Operator
00170 
00171         friend Ostream& operator<< <ParticleType>
00172         (
00173             Ostream&,
00174             const ExactParticle<ParticleType>&
00175         );
00176 };
00177 
00178 
00179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00180 
00181 } // End namespace Foam
00182 
00183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00184 
00185 #ifdef NoRepository
00186 #   include "ExactParticle.C"
00187 #endif
00188 
00189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00190 
00191 #endif
00192 
00193 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd