FreeFOAM The Cross-Platform CFD Toolkit
ExactParticle.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::ExactParticle
26 
27 Description
28  Special version of Particle to do tracking on non-convex cells.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef ExactParticle_H
33 #define ExactParticle_H
34 
35 #include <OpenFOAM/face.H>
36 #include <lagrangian/Particle.H>
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 
43 template<class ExactParticle>
44 class Cloud;
45 
46 // Forward declaration of friend functions and operators
47 
48 template<class ParticleType>
49 class ExactParticle;
50 
51 template<class ParticleType>
52 Ostream& operator<<
53 (
54  Ostream&,
55  const ExactParticle<ParticleType>&
56 );
57 
58 
59 /*---------------------------------------------------------------------------*\
60  Class ExactParticle Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class ParticleType>
65 :
66  public Particle<ParticleType>
67 {
68 
69 public:
70 
71  friend class Cloud<ParticleType>;
72 
73 
74  // Constructors
75 
76  //- Construct from components
78  (
80  const vector& position,
81  const label celli
82  )
83  :
85  {}
86 
87 
88  //- Construct from Istream
90  (
91  const Cloud<ParticleType>& cloud,
92  Istream& is,
93  bool readFields = true
94  )
95  :
97  {}
98 
99 
100  //- Factory class to read-construct particles used for parallel transfer
101  class iNew
102  {
103 
104  // Private data
105 
106  const Cloud<ParticleType>& cloud_;
107 
108 
109  public:
110 
111  iNew(const Cloud<ParticleType>& cloud)
112  :
113  cloud_(cloud)
114  {}
115 
117  {
118  return autoPtr<ParticleType>
119  (
120  new ParticleType(cloud_, is)
121  );
122  }
123  };
124 
125 
126  // Destructor
127 
128  virtual ~ExactParticle()
129  {}
130 
131 
132  // Member Functions
133 
134  //- Track particle to end of trajectory
135  // or until it hits the boundary.
136  // On entry 'stepFraction()' should be set to the fraction of the
137  // time-step at which the tracking starts and on exit it contains
138  // the fraction of the time-step completed.
139  // Returns the boundary face index if the track stops at the
140  // boundary, -1 otherwise.
141  template<class TrackingData>
142  label track
143  (
144  const vector& endPosition,
145  TrackingData& td
146  );
147 
148  //- Calls the templated track with dummy TrackingData
149  label track(const vector& endPosition);
150 
151  //- Track particle to a given position and returns 1.0 if the
152  // trajectory is completed without hitting a face otherwise
153  // stops at the face and returns the fraction of the trajectory
154  // completed.
155  // on entry 'stepFraction()' should be set to the fraction of the
156  // time-step at which the tracking starts.
157  template<class TrackingData>
158  scalar trackToFace
159  (
160  const vector& endPosition,
161  TrackingData& td
162  );
163 
164  //- Calls the templated trackToFace with dummy TrackingData
165  scalar trackToFace(const vector& endPosition);
166 
167 
168  // Ostream Operator
169 
170  friend Ostream& operator<< <ParticleType>
171  (
172  Ostream&,
174  );
175 };
176 
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #ifdef NoRepository
185 # include <autoMesh/ExactParticle.C>
186 #endif
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #endif
191 
192 // ************************ vim: set sw=4 sts=4 et: ************************ //