trackedParticle.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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::trackedParticle
26 
27 Description
28  Particle class that marks cells it passes through. Used to mark cells
29  visited by feature edges.
30 
31 SourceFiles
32  trackedParticle.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef trackedParticle_H
37 #define trackedParticle_H
38 
39 #include "particle.H"
40 #include "autoPtr.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 class trackedParticleCloud;
48 
49 
50 // Forward declaration of friend functions and operators
51 
52 class trackedParticle;
53 
54 Ostream& operator<<(Ostream&, const trackedParticle&);
55 
56 
57 /*---------------------------------------------------------------------------*\
58  Class trackedParticle Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class trackedParticle
62 :
63  public particle
64 {
65  // Private Data
66 
67  //- Start point to track from
68  point start_;
69 
70  //- End point to track to
71  point end_;
72 
73  //- Level of this particle
74  label level_;
75 
76  //- Passive label (used to store feature edge mesh)
77  label i_;
78 
79  //- Passive label (used to store feature edge point)
80  label j_;
81 
82  //- Passive label (used to store feature edge label)
83  label k_;
84 
85 
86 public:
87 
88  friend class Cloud<trackedParticle>;
89 
90  //- Class used to pass tracking data to the trackToFace function
91  class trackingData
92  :
94  {
95  public:
96 
98 
100 
101 
102  // Constructors
103 
105  (
107  labelList& maxLevel,
108  List<PackedBoolList>& featureEdgeVisited
109  )
110  :
111  particle::trackingData(cloud),
112  maxLevel_(maxLevel),
113  featureEdgeVisited_(featureEdgeVisited)
114  {}
115 
116  };
117 
118 
119 
120  // Constructors
121 
122  //- Construct from components
124  (
125  const polyMesh& mesh,
126  const barycentric& coordinates,
127  const label celli,
128  const label tetFacei,
129  const label tetPtI,
130  const point& end,
131  const label level,
132  const label i,
133  const label j,
134  const label k
135  );
136 
137  //- Construct from a position and a cell, searching for the rest of the
138  // required topology
140  (
141  const polyMesh& mesh,
142  const vector& position,
143  const label celli,
144  const point& end,
145  const label level,
146  const label i,
147  const label j,
148  const label k
149  );
150 
151  //- Construct from Istream
153  (
154  const polyMesh& mesh,
155  Istream& is,
156  bool readFields = true
157  );
158 
159  //- Construct and return a clone
160  autoPtr<particle> clone() const
161  {
162  return autoPtr<particle>(new trackedParticle(*this));
163  }
164 
165  //- Factory class to read-construct particles used for
166  // parallel transfer
167  class iNew
168  {
169  const polyMesh& mesh_;
170 
171  public:
173  iNew(const polyMesh& mesh)
174  :
175  mesh_(mesh)
176  {}
178  autoPtr<trackedParticle> operator()(Istream& is) const
179  {
181  (
182  new trackedParticle(mesh_, is, true)
183  );
184  }
185  };
186 
187 
188  // Member Functions
189 
190  //- Point to track from
191  point& start()
192  {
193  return start_;
194  }
195 
196  //- Point to track to
197  point& end()
198  {
199  return end_;
200  }
201 
202  //- Transported label
203  label i() const
204  {
205  return i_;
206  }
207 
208  //- Transported label
209  label& i()
210  {
211  return i_;
212  }
213 
214  //- Transported label
215  label j() const
216  {
217  return j_;
218  }
219 
220  //- Transported label
221  label& j()
222  {
223  return j_;
224  }
225 
226  //- Transported label
227  label k() const
228  {
229  return k_;
230  }
231 
232  //- Transported label
233  label& k()
234  {
235  return k_;
236  }
237 
238 
239 
240  // Tracking
241 
242  //- Track all particles to their end point
243  bool move(Cloud<trackedParticle>&, trackingData&, const scalar);
244 
245  //- Overridable function to handle the particle hitting a patch
246  // Executed before other patch-hitting functions
248 
249  //- Overridable function to handle the particle hitting a wedge
251 
252  //- Overridable function to handle the particle hitting a
253  // symmetry plane
255 
256  //- Overridable function to handle the particle hitting a
257  // symmetry patch
259 
260  //- Overridable function to handle the particle hitting a cyclic
262 
263  //- Overridable function to handle the particle hitting a cyclicAMI
264  void hitCyclicAMIPatch
265  (
266  const vector&,
267  const scalar,
269  trackingData&
270  );
271 
272  //- Overridable function to handle the particle hitting a cyclicACMI
273  void hitCyclicACMIPatch
274  (
275  const vector&,
276  const scalar,
278  trackingData&
279  );
280 
281  //- Overridable function to handle the particle hitting a
282  // cyclicRepeatAMI
284  (
285  const vector&,
286  const scalar,
288  trackingData&
289  );
290 
291  //- Overridable function to handle the particle hitting a
292  //- processorPatch
294 
295  //- Overridable function to handle the particle hitting a wallPatch
297 
298  //- Convert processor patch addressing to the global equivalents
299  // and set the celli to the face-neighbour
301 
302 
303  // Ostream Operator
304 
305  friend Ostream& operator<<(Ostream&, const trackedParticle&);
306 };
307 
308 
309 template<>
310 inline bool contiguous<trackedParticle>()
311 {
312  return true;
313 }
314 
315 //template<>
316 //void Cloud<trackedParticle>::readFields();
317 //
318 //template<>
319 //void Cloud<trackedParticle>::writeFields() const;
320 
321 
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 
324 } // End namespace Foam
325 
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
327 
328 #endif
329 
330 // ************************************************************************* //
void hitWallPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:125
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 hitCyclicRepeatAMIPatch(const vector &, const scalar, Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
List< PackedBoolList > & featureEdgeVisited_
bool hitPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a patch.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
autoPtr< particle > clone() const
Construct and return a clone.
bool move(Cloud< trackedParticle > &, trackingData &, const scalar)
Track all particles to their end point.
Base particle class.
Definition: particle.H:84
trackedParticle(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPtI, const point &end, const label level, const label i, const label j, const label k)
Construct from components.
Particle class that marks cells it passes through. Used to mark cells visited by feature edges...
void hitSymmetryPlanePatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
point & end()
Point to track to.
void hitWedgePatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wedge.
point & start()
Point to track from.
label k() const
Transported label.
Factory class to read-construct particles used for.
Base cloud calls templated on particle type.
Definition: Cloud.H:52
bool contiguous< trackedParticle >()
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
void correctAfterParallelTransfer(const label, trackingData &)
Convert processor patch addressing to the global equivalents.
void hitCyclicAMIPatch(const vector &, const scalar, Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclicAMI.
Class used to pass tracking data to the trackToFace function.
void hitSymmetryPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
void hitProcessorPatch(Cloud< trackedParticle > &, trackingData &)
label i() const
Transported label.
Ostream & operator<<(Ostream &, const ensightPart &)
void hitCyclicPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
void hitCyclicACMIPatch(const vector &, const scalar, Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclicACMI.
trackingData(Cloud< trackedParticle > &cloud, labelList &maxLevel, List< PackedBoolList > &featureEdgeVisited)
const barycentric & coordinates() const
Return current particle coordinates.
Definition: particleI.H:131
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
label j() const
Transported label.
friend Ostream & operator<<(Ostream &, const trackedParticle &)
vector position() const
Return current particle position.
Definition: particleI.H:278
Namespace for OpenFOAM.