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-2022 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 "Cloud.H"
41 #include "autoPtr.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of friend functions and operators
49 
50 class trackedParticle;
51 
52 Ostream& operator<<(Ostream&, const trackedParticle&);
53 
54 
55 /*---------------------------------------------------------------------------*\
56  Class trackedParticle Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class trackedParticle
60 :
61  public particle
62 {
63  // Private Data
64 
65  //- Start point to track from
66  point start_;
67 
68  //- End point to track to
69  point end_;
70 
71  //- Level of this particle
72  label level_;
73 
74  //- Passive label (used to store feature edge mesh)
75  label i_;
76 
77  //- Passive label (used to store feature edge point)
78  label j_;
79 
80  //- Passive label (used to store feature edge label)
81  label k_;
82 
83 
84 public:
85 
86  friend class Cloud<trackedParticle>;
87 
88  //- Class used to pass tracking data to the trackToFace function
89  class trackingData
90  :
92  {
93  public:
94 
96 
98 
99 
100  // Constructors
101 
103  (
105  labelList& maxLevel,
106  List<PackedBoolList>& featureEdgeVisited
107  )
108  :
109  particle::trackingData(cloud),
110  maxLevel_(maxLevel),
111  featureEdgeVisited_(featureEdgeVisited)
112  {}
113 
114  };
115 
116 
117 
118  // Constructors
119 
120  //- Construct from components
122  (
123  const polyMesh& mesh,
124  const barycentric& coordinates,
125  const label celli,
126  const label tetFacei,
127  const label tetPtI,
128  const point& end,
129  const label level,
130  const label i,
131  const label j,
132  const label k
133  );
134 
135  //- Construct from a position and a cell, searching for the rest of the
136  // required topology
138  (
139  const polyMesh& mesh,
140  const vector& position,
141  const label celli,
142  const point& end,
143  const label level,
144  const label i,
145  const label j,
146  const label k
147  );
148 
149  //- Construct from Istream
151  (
152  const polyMesh& mesh,
153  Istream& is,
154  bool readFields = true
155  );
156 
157  //- Construct and return a clone
158  autoPtr<particle> clone() const
159  {
160  return autoPtr<particle>(new trackedParticle(*this));
161  }
162 
163  //- Factory class to read-construct particles used for
164  // parallel transfer
165  class iNew
166  {
167  const polyMesh& mesh_;
168 
169  public:
171  iNew(const polyMesh& mesh)
172  :
173  mesh_(mesh)
174  {}
176  autoPtr<trackedParticle> operator()(Istream& is) const
177  {
179  (
180  new trackedParticle(mesh_, is, true)
181  );
182  }
183  };
184 
185 
186  // Member Functions
187 
188  //- Point to track from
189  point& start()
190  {
191  return start_;
192  }
193 
194  //- Point to track to
195  point& end()
196  {
197  return end_;
198  }
199 
200  //- Transported label
201  label i() const
202  {
203  return i_;
204  }
205 
206  //- Transported label
207  label& i()
208  {
209  return i_;
210  }
211 
212  //- Transported label
213  label j() const
214  {
215  return j_;
216  }
217 
218  //- Transported label
219  label& j()
220  {
221  return j_;
222  }
223 
224  //- Transported label
225  label k() const
226  {
227  return k_;
228  }
229 
230  //- Transported label
231  label& k()
232  {
233  return k_;
234  }
235 
236 
237 
238  // Tracking
239 
240  //- Track all particles to their end point
241  bool move(Cloud<trackedParticle>&, trackingData&, const scalar);
242 
243  //- Overridable function to handle the particle hitting a wedge
245 
246  //- Overridable function to handle the particle hitting a
247  // symmetry plane
249 
250  //- Overridable function to handle the particle hitting a
251  // symmetry patch
253 
254  //- Overridable function to handle the particle hitting a cyclic
256 
257  //- Overridable function to handle the particle hitting a cyclicAMI
258  void hitCyclicAMIPatch
259  (
260  const vector&,
261  const scalar,
263  trackingData&
264  );
265 
266  //- Overridable function to handle the particle hitting a wallPatch
268 
269  //- Do corrections to the particle and tracking data following a
270  // transfer between processors
272 
273 
274  // Ostream Operator
275 
276  friend Ostream& operator<<(Ostream&, const trackedParticle&);
277 };
278 
279 
280 template<>
281 inline bool contiguous<trackedParticle>()
282 {
283  return true;
284 }
285 
286 //template<>
287 //void Cloud<trackedParticle>::readFields();
288 //
289 //template<>
290 //void Cloud<trackedParticle>::writeFields() const;
291 
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 } // End namespace Foam
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #endif
300 
301 // ************************************************************************* //
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
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
List< PackedBoolList > & featureEdgeVisited_
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:81
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:54
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 correctAfterParallelTransfer(trackingData &)
Do corrections to the particle and tracking data following a.
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.
label i() const
Transported label.
Ostream & operator<<(Ostream &, const ensightPart &)
void hitCyclicPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
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:76
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.