FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::ExactParticle
00026 
00027 Description
00028     Special version of Particle to do tracking on non-convex cells.
00029 
00030 \*---------------------------------------------------------------------------*/
00031 
00032 #ifndef ExactParticle_H
00033 #define ExactParticle_H
00034 
00035 #include <OpenFOAM/face.H>
00036 #include <lagrangian/Particle.H>
00037 
00038 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00039 
00040 namespace Foam
00041 {
00042 
00043 template<class ExactParticle>
00044 class Cloud;
00045 
00046 // Forward declaration of friend functions and operators
00047 
00048 template<class ParticleType>
00049 class ExactParticle;
00050 
00051 template<class ParticleType>
00052 Ostream& operator<<
00053 (
00054     Ostream&,
00055     const ExactParticle<ParticleType>&
00056 );
00057 
00058 
00059 /*---------------------------------------------------------------------------*\
00060                            Class ExactParticle Declaration
00061 \*---------------------------------------------------------------------------*/
00062 
00063 template<class ParticleType>
00064 class ExactParticle
00065 :
00066     public Particle<ParticleType>
00067 {
00068 
00069 public:
00070 
00071     friend class Cloud<ParticleType>;
00072 
00073 
00074     // Constructors
00075 
00076         //- Construct from components
00077         ExactParticle
00078         (
00079             const Cloud<ParticleType>& cloud,
00080             const vector& position,
00081             const label celli
00082         )
00083         :
00084             Particle<ParticleType>(cloud, position, celli)
00085         {}
00086 
00087 
00088         //- Construct from Istream
00089         ExactParticle
00090         (
00091             const Cloud<ParticleType>& cloud,
00092             Istream& is,
00093             bool readFields = true
00094         )
00095         :
00096             Particle<ParticleType>(cloud, is, readFields)
00097         {}
00098 
00099 
00100         //- Factory class to read-construct particles used for parallel transfer
00101         class iNew
00102         {
00103 
00104             // Private data
00105 
00106             const Cloud<ParticleType>& cloud_;
00107 
00108 
00109         public:
00110 
00111             iNew(const Cloud<ParticleType>& cloud)
00112             :
00113                 cloud_(cloud)
00114             {}
00115 
00116             autoPtr<ParticleType> operator()(Istream& is) const
00117             {
00118                 return autoPtr<ParticleType>
00119                 (
00120                     new ParticleType(cloud_, is)
00121                 );
00122             }
00123         };
00124 
00125 
00126     // Destructor
00127 
00128         virtual ~ExactParticle()
00129         {}
00130 
00131 
00132     // Member Functions
00133 
00134             //- Track particle to end of trajectory
00135             //  or until it hits the boundary.
00136             //  On entry 'stepFraction()' should be set to the fraction of the
00137             //  time-step at which the tracking starts and on exit it contains
00138             //  the fraction of the time-step completed.
00139             //  Returns the boundary face index if the track stops at the
00140             //  boundary, -1 otherwise.
00141             template<class TrackingData>
00142             label track
00143             (
00144                 const vector& endPosition,
00145                 TrackingData& td
00146             );
00147 
00148             //- Calls the templated track with dummy TrackingData
00149             label track(const vector& endPosition);
00150 
00151             //- Track particle to a given position and returns 1.0 if the
00152             //  trajectory is completed without hitting a face otherwise
00153             //  stops at the face and returns the fraction of the trajectory
00154             //  completed.
00155             //  on entry 'stepFraction()' should be set to the fraction of the
00156             //  time-step at which the tracking starts.
00157             template<class TrackingData>
00158             scalar trackToFace
00159             (
00160                 const vector& endPosition,
00161                 TrackingData& td
00162             );
00163 
00164             //- Calls the templated trackToFace with dummy TrackingData
00165             scalar trackToFace(const vector& endPosition);
00166 
00167 
00168     // Ostream Operator
00169 
00170         friend Ostream& operator<< <ParticleType>
00171         (
00172             Ostream&,
00173             const ExactParticle<ParticleType>&
00174         );
00175 };
00176 
00177 
00178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00179 
00180 } // End namespace Foam
00181 
00182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00183 
00184 #ifdef NoRepository
00185 #   include <autoMesh/ExactParticle.C>
00186 #endif
00187 
00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00189 
00190 #endif
00191 
00192 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines