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-2025 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  //- Fraction of the distance left to track
72  scalar fraction_;
73 
74  //- Level of this particle
75  label level_;
76 
77  //- Passive label (used to store feature edge mesh)
78  label i_;
79 
80  //- Passive label (used to store feature edge point)
81  label j_;
82 
83  //- Passive label (used to store feature edge label)
84  label k_;
85 
86 
87 public:
88 
89  friend class lagrangian::Cloud<trackedParticle>;
90 
91 
92  //- Class used to pass tracking data to the trackToFace function
93  class trackingData
94  :
96  {
97  public:
98 
99  const scalar maxTrackLen_;
100 
102 
104 
105 
106  // Constructors
107 
109  (
111  const scalar maxTrackLen,
112  labelList& maxLevel,
113  List<PackedBoolList>& featureEdgeVisited
114  )
115  :
117  maxTrackLen_(maxTrackLen),
118  maxLevel_(maxLevel),
119  featureEdgeVisited_(featureEdgeVisited)
120  {}
121  };
122 
123 
124 
125  // Static Data Members
126 
127  //- Streamlines are computed at an instant
128  static const bool instantaneous = true;
129 
130 
131  // Constructors
132 
133  //- Construct from a position and a cell, searching for the rest of the
134  // required topology
136  (
137  const meshSearch& searchEngine,
138  const vector& position,
139  const label celli,
140  label& nLocateBoundaryHits,
141  const point& end,
142  const label level,
143  const label i,
144  const label j,
145  const label k
146  );
147 
148  //- Construct from Istream
149  trackedParticle(Istream& is, bool readFields = true);
150 
151  //- Construct and return a clone
152  autoPtr<particle> clone() const
153  {
154  return autoPtr<particle>(new trackedParticle(*this));
155  }
156 
157  //- Construct from Istream and return
159  {
161  }
162 
163 
164  // Member Functions
165 
166  //- Point to track from
167  point& start()
168  {
169  return start_;
170  }
171 
172  //- Point to track to
173  point& end()
174  {
175  return end_;
176  }
177 
178  //- Fraction of the distance left to track
179  scalar& fraction()
180  {
181  return fraction_;
182  }
183 
184  //- Transported label
185  label i() const
186  {
187  return i_;
188  }
189 
190  //- Transported label
191  label& i()
192  {
193  return i_;
194  }
195 
196  //- Transported label
197  label j() const
198  {
199  return j_;
200  }
201 
202  //- Transported label
203  label& j()
204  {
205  return j_;
206  }
207 
208  //- Transported label
209  label k() const
210  {
211  return k_;
212  }
213 
214  //- Transported label
215  label& k()
216  {
217  return k_;
218  }
219 
220 
221 
222  // Tracking
223 
224  //- Track all particles to their end point
225  bool move(lagrangian::Cloud<trackedParticle>&, trackingData&);
226 
227  //- Overridable function to handle the particle hitting a wedge
228  void hitWedgePatch
229  (
231  trackingData&
232  );
233 
234  //- Overridable function to handle the particle hitting a
235  // symmetry plane
237  (
239  trackingData&
240  );
241 
242  //- Overridable function to handle the particle hitting a
243  // symmetry patch
244  void hitSymmetryPatch
245  (
247  trackingData&
248  );
249 
250  //- Overridable function to handle the particle hitting a cyclic
251  void hitCyclicPatch
252  (
254  trackingData&
255  );
256 
257  //- Overridable function to handle the particle hitting a wallPatch
258  void hitWallPatch
259  (
261  trackingData&
262  );
263 
264  //- Do corrections to the particle and tracking data following a
265  // transfer between processors
267  (
269  trackingData&
270  );
271 
272 
273  // Ostream Operator
274 
275  friend Ostream& operator<<(Ostream&, const trackedParticle&);
276 };
277 
278 
279 template<>
280 inline bool contiguous<trackedParticle>()
281 {
282  return true;
283 }
284 
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 } // End namespace Foam
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 #endif
293 
294 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
Mesh object that implements searches within the local cells and faces.
Definition: meshSearch.H:59
Base particle class.
Definition: particle.H:85
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
vector position(const polyMesh &mesh) const
Return current particle position.
Definition: particleI.H:159
Class used to pass tracking data to the trackToFace function.
List< PackedBoolList > & featureEdgeVisited_
trackingData(lagrangian::Cloud< trackedParticle > &cloud, const scalar maxTrackLen, labelList &maxLevel, List< PackedBoolList > &featureEdgeVisited)
Particle class that marks cells it passes through. Used to mark cells visited by feature edges.
scalar & fraction()
Fraction of the distance left to track.
void hitCyclicPatch(lagrangian::Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
void correctAfterParallelTransfer(lagrangian::Cloud< trackedParticle > &, trackingData &)
Do corrections to the particle and tracking data following a.
void hitWallPatch(lagrangian::Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
static const bool instantaneous
Streamlines are computed at an instant.
friend Ostream & operator<<(Ostream &, const trackedParticle &)
label j() const
Transported label.
point & start()
Point to track from.
void hitSymmetryPatch(lagrangian::Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
label i() const
Transported label.
void hitWedgePatch(lagrangian::Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wedge.
trackedParticle(const meshSearch &searchEngine, const vector &position, const label celli, label &nLocateBoundaryHits, const point &end, const label level, const label i, const label j, const label k)
Construct from a position and a cell, searching for the rest of the.
void hitSymmetryPlanePatch(lagrangian::Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
static autoPtr< trackedParticle > New(Istream &is)
Construct from Istream and return.
autoPtr< particle > clone() const
Construct and return a clone.
point & end()
Point to track to.
bool move(lagrangian::Cloud< trackedParticle > &, trackingData &)
Track all particles to their end point.
label k() const
Transported label.
Namespace for OpenFOAM.
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
bool contiguous< trackedParticle >()
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)