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-2023 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 
95  const scalar maxTrackLen_;
96 
98 
100 
101 
102  // Constructors
103 
105  (
107  const scalar maxTrackLen,
108  labelList& maxLevel,
109  List<PackedBoolList>& featureEdgeVisited
110  )
111  :
113  maxTrackLen_(maxTrackLen),
114  maxLevel_(maxLevel),
115  featureEdgeVisited_(featureEdgeVisited)
116  {}
117  };
118 
119 
120 
121  // Constructors
122 
123  //- Construct from a position and a cell, searching for the rest of the
124  // required topology
126  (
127  const polyMesh& mesh,
128  const vector& position,
129  const label celli,
130  label& nLocateBoundaryHits,
131  const point& end,
132  const label level,
133  const label i,
134  const label j,
135  const label k
136  );
137 
138  //- Construct from Istream
139  trackedParticle(Istream& is, bool readFields = true);
140 
141  //- Construct and return a clone
142  autoPtr<particle> clone() const
143  {
144  return autoPtr<particle>(new trackedParticle(*this));
145  }
146 
147  //- Construct from Istream and return
149  {
151  }
152 
153 
154  // Member Functions
155 
156  //- Point to track from
157  point& start()
158  {
159  return start_;
160  }
161 
162  //- Point to track to
163  point& end()
164  {
165  return end_;
166  }
167 
168  //- Transported label
169  label i() const
170  {
171  return i_;
172  }
173 
174  //- Transported label
175  label& i()
176  {
177  return i_;
178  }
179 
180  //- Transported label
181  label j() const
182  {
183  return j_;
184  }
185 
186  //- Transported label
187  label& j()
188  {
189  return j_;
190  }
191 
192  //- Transported label
193  label k() const
194  {
195  return k_;
196  }
197 
198  //- Transported label
199  label& k()
200  {
201  return k_;
202  }
203 
204 
205 
206  // Tracking
207 
208  //- Track all particles to their end point
209  bool move(Cloud<trackedParticle>&, trackingData&);
210 
211  //- Overridable function to handle the particle hitting a wedge
212  void hitWedgePatch(Cloud<trackedParticle>&, trackingData&);
213 
214  //- Overridable function to handle the particle hitting a
215  // symmetry plane
216  void hitSymmetryPlanePatch(Cloud<trackedParticle>&, trackingData&);
217 
218  //- Overridable function to handle the particle hitting a
219  // symmetry patch
220  void hitSymmetryPatch(Cloud<trackedParticle>&, trackingData&);
221 
222  //- Overridable function to handle the particle hitting a cyclic
223  void hitCyclicPatch(Cloud<trackedParticle>&, trackingData&);
224 
225  //- Overridable function to handle the particle hitting a wallPatch
226  void hitWallPatch(Cloud<trackedParticle>&, trackingData&);
227 
228  //- Do corrections to the particle and tracking data following a
229  // transfer between processors
231  (
233  trackingData&
234  );
235 
236 
237  // Ostream Operator
238 
239  friend Ostream& operator<<(Ostream&, const trackedParticle&);
240 };
241 
242 
243 template<>
244 inline bool contiguous<trackedParticle>()
245 {
246  return true;
247 }
248 
249 //template<>
250 //void Cloud<trackedParticle>::readFields();
251 //
252 //template<>
253 //void Cloud<trackedParticle>::writeFields() const;
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 } // End namespace Foam
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
Base cloud calls templated on particle type.
Definition: Cloud.H:74
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
A cloud is a collection of lagrangian particles.
Definition: cloud.H:55
Base particle class.
Definition: particle.H:83
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:255
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class used to pass tracking data to the trackToFace function.
trackingData(Cloud< trackedParticle > &cloud, const scalar maxTrackLen, labelList &maxLevel, List< PackedBoolList > &featureEdgeVisited)
List< PackedBoolList > & featureEdgeVisited_
Particle class that marks cells it passes through. Used to mark cells visited by feature edges.
void hitWedgePatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wedge.
trackedParticle(const polyMesh &mesh, 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.
friend Ostream & operator<<(Ostream &, const trackedParticle &)
label j() const
Transported label.
point & start()
Point to track from.
void hitSymmetryPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
void hitSymmetryPlanePatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
label i() const
Transported label.
void hitWallPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
void correctAfterParallelTransfer(Cloud< trackedParticle > &, trackingData &)
Do corrections to the particle and tracking data following 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.
void hitCyclicPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
label k() const
Transported label.
bool move(Cloud< trackedParticle > &, trackingData &)
Track all particles to their end point.
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)