initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / autoMesh / autoHexMesh / trackedParticle / ExactParticle.H
blobd62c7e08cf6d42068d664155340fc20857b24695
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::ExactParticle
28 Description
29     Special version of Particle to do tracking on non-convex cells.
31 \*---------------------------------------------------------------------------*/
33 #ifndef ExactParticle_H
34 #define ExactParticle_H
36 #include "face.H"
37 #include "Particle.H"
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 namespace Foam
44 template<class ExactParticle>
45 class Cloud;
47 // Forward declaration of friend functions and operators
49 template<class ParticleType>
50 class ExactParticle;
52 template<class ParticleType>
53 Ostream& operator<<
55     Ostream&,
56     const ExactParticle<ParticleType>&
60 /*---------------------------------------------------------------------------*\
61                            Class ExactParticle Declaration
62 \*---------------------------------------------------------------------------*/
64 template<class ParticleType>
65 class ExactParticle
67     public Particle<ParticleType>
70 public:
72     friend class Cloud<ParticleType>;
75     // Constructors
77         //- Construct from components
78         ExactParticle
79         (
80             const Cloud<ParticleType>& cloud,
81             const vector& position,
82             const label celli
83         )
84         :
85             Particle<ParticleType>(cloud, position, celli)
86         {}
87             
89         //- Construct from Istream
90         ExactParticle
91         (
92             const Cloud<ParticleType>& cloud,
93             Istream& is,
94             bool readFields = true
95         )
96         :
97             Particle<ParticleType>(cloud, is, readFields)
98         {}
101         //- Factory class to read-construct particles used for parallel transfer
102         class iNew
103         {
105             // Private data
107             const Cloud<ParticleType>& cloud_;
110         public:
112             iNew(const Cloud<ParticleType>& cloud)
113             :
114                 cloud_(cloud)
115             {}
117             autoPtr<ParticleType> operator()(Istream& is) const
118             {
119                 return autoPtr<ParticleType>
120                 (
121                     new ParticleType(cloud_, is)
122                 );
123             }
124         };
127     // Destructor
129         virtual ~ExactParticle()
130         {}
133     // Member Functions
135             //- Track particle to end of trajectory
136             //  or until it hits the boundary.
137             //  On entry 'stepFraction()' should be set to the fraction of the
138             //  time-step at which the tracking starts and on exit it contains
139             //  the fraction of the time-step completed.
140             //  Returns the boundary face index if the track stops at the
141             //  boundary, -1 otherwise.
142             template<class TrackingData>
143             label track
144             (
145                 const vector& endPosition,
146                 TrackingData& td
147             );
149             //- Calls the templated track with dummy TrackingData
150             label track(const vector& endPosition);
152             //- Track particle to a given position and returns 1.0 if the
153             //  trajectory is completed without hitting a face otherwise
154             //  stops at the face and returns the fraction of the trajectory
155             //  completed.
156             //  on entry 'stepFraction()' should be set to the fraction of the
157             //  time-step at which the tracking starts.
158             template<class TrackingData>
159             scalar trackToFace
160             (
161                 const vector& endPosition,
162                 TrackingData& td
163             );
165             //- Calls the templated trackToFace with dummy TrackingData
166             scalar trackToFace(const vector& endPosition);
169     // Ostream Operator
171         friend Ostream& operator<< <ParticleType>
172         (
173             Ostream&,
174             const ExactParticle<ParticleType>&
175         );
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 } // End namespace Foam
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 #ifdef NoRepository
186 #   include "ExactParticle.C"
187 #endif
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 #endif
193 // ************************************************************************* //