findCellParticle.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) 2013-2017 OpenFOAM Foundation
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::findCellParticle
26 
27 Description
28  Particle class that finds cells by tracking
29 
30 SourceFiles
31  findCellParticle.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef findCellParticle_H
36 #define findCellParticle_H
37 
38 #include "particle.H"
39 #include "autoPtr.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 class findCellParticleCloud;
47 
48 
49 // Forward declaration of friend functions and operators
50 
51 class findCellParticle;
52 
53 Ostream& operator<<(Ostream&, const findCellParticle&);
54 
55 
56 /*---------------------------------------------------------------------------*\
57  Class findCellParticle Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class findCellParticle
61 :
62  public particle
63 {
64  // Private data
65 
66  //- Start point to track from
67  point start_;
68 
69  //- End point to track to
70  point end_;
71 
72  //- Passive data
73  label data_;
74 
75 
76 public:
77 
78  friend class Cloud<findCellParticle>;
79 
80  //- Class used to pass tracking data to the trackToFace function
81  class trackingData
82  :
83  public particle::TrackingData<Cloud<findCellParticle>>
84  {
85  labelListList& cellToData_;
86  List<List<point>>& cellToEnd_;
87 
88  public:
89 
90  // Constructors
91 
93  (
97  )
98  :
100  cellToData_(cellToData),
101  cellToEnd_(cellToEnd)
102  {}
103 
104 
105  // Member functions
108  {
109  return cellToData_;
110  }
113  {
114  return cellToEnd_;
115  }
116  };
117 
118 
119  // Constructors
120 
121  //- Construct from components
123  (
124  const polyMesh& mesh,
125  const barycentric& coordinates,
126  const label celli,
127  const label tetFacei,
128  const label tetPtI,
129  const point& end,
130  const label data
131  );
132 
133  //- Construct from a position and a cell, searching for the rest of the
134  // required topology
136  (
137  const polyMesh& mesh,
138  const vector& position,
139  const label celli,
140  const point& end,
141  const label data
142  );
143 
144  //- Construct from Istream
146  (
147  const polyMesh& mesh,
148  Istream& is,
149  bool readFields = true
150  );
151 
152  //- Construct and return a clone
153  autoPtr<particle> clone() const
154  {
155  return autoPtr<particle>(new findCellParticle(*this));
156  }
157 
158  //- Factory class to read-construct particles used for
159  // parallel transfer
160  class iNew
161  {
162  const polyMesh& mesh_;
163 
164  public:
166  iNew(const polyMesh& mesh)
167  :
168  mesh_(mesh)
169  {}
171  autoPtr<findCellParticle> operator()(Istream& is) const
172  {
174  (
175  new findCellParticle(mesh_, is, true)
176  );
177  }
178  };
179 
180 
181  // Member Functions
182 
183  //- Point to track from
184  const point& start() const
185  {
186  return start_;
187  }
188 
189  //- Point to track from
190  point& start()
191  {
192  return start_;
193  }
194 
195  //- Point to track to
196  const point& end() const
197  {
198  return end_;
199  }
200 
201  //- Point to track to
202  point& end()
203  {
204  return end_;
205  }
206 
207  //- Transported label
208  label data() const
209  {
210  return data_;
211  }
212 
213  //- Transported label
214  label& data()
215  {
216  return data_;
217  }
218 
219 
220  // Tracking
221 
222  //- Track all particles to their end point
223  bool move(trackingData&, const scalar);
224 
225 
226  //- Overridable function to handle the particle hitting a patch
227  // Executed before other patch-hitting functions
228  bool hitPatch
229  (
230  const polyPatch&,
231  trackingData& td,
232  const label patchi,
233  const scalar trackFraction,
234  const tetIndices& tetIs
235  );
236 
237  //- Overridable function to handle the particle hitting a wedge
238  void hitWedgePatch
239  (
240  const wedgePolyPatch&,
241  trackingData& td
242  );
243 
244  //- Overridable function to handle the particle hitting a
245  // symmetry plane
247  (
248  const symmetryPlanePolyPatch&,
249  trackingData& td
250  );
251 
252  //- Overridable function to handle the particle hitting a
253  // symmetry patch
254  void hitSymmetryPatch
255  (
256  const symmetryPolyPatch&,
257  trackingData& td
258  );
259 
260  //- Overridable function to handle the particle hitting a cyclic
261  void hitCyclicPatch
262  (
263  const cyclicPolyPatch&,
264  trackingData& td
265  );
266 
267  //- Overridable function to handle the particle hitting a
268  //- processorPatch
269  void hitProcessorPatch
270  (
271  const processorPolyPatch&,
272  trackingData& td
273  );
274 
275  //- Overridable function to handle the particle hitting a wallPatch
276  void hitWallPatch
277  (
278  const wallPolyPatch&,
279  trackingData& td,
280  const tetIndices&
281  );
282 
283  //- Overridable function to handle the particle hitting a polyPatch
284  void hitPatch
285  (
286  const polyPatch&,
287  trackingData& td
288  );
289 
290 
291  // Ostream Operator
292 
293  friend Ostream& operator<<(Ostream&, const findCellParticle&);
294 };
295 
296 
297 template<>
298 inline bool contiguous<findCellParticle>()
299 {
300  return true;
301 }
302 
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 } // End namespace Foam
307 
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 
310 #endif
311 
312 // ************************************************************************* //
Symmetry patch for non-planar or multi-plane patches.
void hitWedgePatch(const wedgePolyPatch &, trackingData &td)
Overridable function to handle the particle hitting a wedge.
friend Ostream & operator<<(Ostream &, const findCellParticle &)
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:45
bool contiguous< findCellParticle >()
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void hitSymmetryPatch(const symmetryPolyPatch &, trackingData &td)
Overridable function to handle the particle hitting a.
autoPtr< particle > clone() const
Construct and return a clone.
void hitCyclicPatch(const cyclicPolyPatch &, trackingData &td)
Overridable function to handle the particle hitting a cyclic.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
findCellParticle(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPtI, const point &end, const label data)
Construct from components.
static void readFields(CloudType &c)
Read the fields associated with the owner cloud.
const point & start() const
Point to track from.
Base particle class.
Definition: particle.H:81
Neighbour processor patch.
bool hitPatch(const polyPatch &, trackingData &td, const label patchi, const scalar trackFraction, const tetIndices &tetIs)
Overridable function to handle the particle hitting a patch.
Cyclic plane patch.
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
Foam::wallPolyPatch.
Definition: wallPolyPatch.H:48
Wedge front and back plane patch.
label data() const
Transported label.
void hitProcessorPatch(const processorPolyPatch &, trackingData &td)
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
void hitWallPatch(const wallPolyPatch &, trackingData &td, const tetIndices &)
Overridable function to handle the particle hitting a wallPatch.
Base cloud calls templated on particle type.
Definition: Cloud.H:52
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Database for solution data, solver performance and other reduced data.
Definition: data.H:52
const point & end() const
Point to track to.
List< List< point > > & cellToEnd()
label patchi
Ostream & operator<<(Ostream &, const ensightPart &)
Particle class that finds cells by tracking.
const barycentric & coordinates() const
Return current particle coordinates.
Definition: particleI.H:51
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
void hitSymmetryPlanePatch(const symmetryPlanePolyPatch &, trackingData &td)
Overridable function to handle the particle hitting a.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Factory class to read-construct particles used for.
Class used to pass tracking data to the trackToFace function.
bool move(trackingData &, const scalar)
Track all particles to their end point.
vector position() const
Return current particle position.
Definition: particleI.H:204
trackingData(Cloud< findCellParticle > &cloud, labelListList &cellToData, List< List< point >> &cellToEnd)
Namespace for OpenFOAM.