trackedParticle.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2017-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::trackedParticle
29 
30 Description
31  Particle class that marks cells it passes through. Used to mark cells
32  visited by feature edges.
33 
34 SourceFiles
35  trackedParticle.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_trackedParticle_H
40 #define Foam_trackedParticle_H
41 
42 #include "bitSet.H"
43 #include "particle.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward Declarations
51 
52 class trackedParticleCloud;
53 class trackedParticle;
54 
55 Ostream& operator<<(Ostream&, const trackedParticle&);
56 
57 
58 /*---------------------------------------------------------------------------*\
59  Class trackedParticle Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class trackedParticle
63 :
64  public particle
65 {
66  // Private Data
67 
68  //- Start point to track from
69  point start_;
70 
71  //- End point to track to
72  point end_;
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 Cloud<trackedParticle>;
90 
91  //- Class used to pass tracking data to the trackToFace function
92  class trackingData
93  :
95  {
96  public:
97 
99 
102 
103  // Constructors
104 
106  (
108  labelList& maxLevel,
109  List<bitSet>& featureEdgeVisited
110  )
111  :
113  maxLevel_(maxLevel),
114  featureEdgeVisited_(featureEdgeVisited)
115  {}
116 
117  };
118 
119 
120  // Static Data Members
121 
122  //- Size in bytes of the fields
123  static const std::size_t sizeofFields_;
124 
125 
126  // Constructors
127 
128  //- Construct from components
130  (
131  const polyMesh& mesh,
132  const barycentric& coordinates,
133  const label celli,
134  const label tetFacei,
135  const label tetPtI,
136  const point& end,
137  const label level,
138  const label i,
139  const label j,
140  const label k
141  );
142 
143  //- Construct from a position and a cell,
144  //- searching for the rest of the required topology
146  (
147  const polyMesh& mesh,
148  const vector& position,
149  const label celli,
150  const point& end,
151  const label level,
152  const label i,
153  const label j,
154  const label k
155  );
156 
157  //- Construct from Istream
159  (
160  const polyMesh& mesh,
161  Istream& is,
162  bool readFields = true,
163  bool newFormat = true
164  );
165 
166  //- Return a clone
167  virtual autoPtr<particle> clone() const
168  {
169  return particle::Clone(*this);
170  }
171 
172  //- Factory class to read-construct particles (for parallel transfer)
173  class iNew
174  {
175  const polyMesh& mesh_;
176 
177  public:
178 
179  iNew(const polyMesh& mesh)
180  :
181  mesh_(mesh)
182  {}
183 
184  autoPtr<trackedParticle> operator()(Istream& is) const
185  {
186  return autoPtr<trackedParticle>::New(mesh_, is, true);
187  }
188  };
189 
190 
191  // Member Functions
192 
193  //- Point to track from
194  point& start() noexcept { return start_; }
195 
196  //- Point to track to
197  point& end() noexcept { return end_; }
198 
199  //- Transported label
200  label i() const noexcept { return i_; }
201 
202  //- Transported label
203  label& i() noexcept { return i_; }
204 
205  //- Transported label
206  label j() const noexcept { return j_; }
207 
208  //- Transported label
209  label& j() noexcept { return j_; }
210 
211  //- Transported label
212  label k() const noexcept { return k_; }
213 
214  //- Transported label
215  label& k() noexcept { return k_; }
216 
218 
219  // Tracking
220 
221  //- Track all particles to their end point
222  bool move(Cloud<trackedParticle>&, trackingData&, const scalar);
223 
224  //- Overridable function to handle the particle hitting a patch
225  // Executed before other patch-hitting functions
228  //- Overridable function to handle the particle hitting a wedge
230 
231  //- Overridable function to handle the particle hitting a
232  // symmetry plane
234 
235  //- Overridable function to handle the particle hitting a
236  // symmetry patch
238 
239  //- Overridable function to handle the particle hitting a cyclic
241 
242  //- Overridable function to handle the particle hitting a cyclicAMI
243  void hitCyclicAMIPatch
244  (
246  trackingData&,
247  const vector&
248  );
249 
250  //- Overridable function to handle the particle hitting a cyclicACMI
251  void hitCyclicACMIPatch
252  (
254  trackingData&,
255  const vector&
256  );
257 
258  //- Overridable function to handle the particle hitting a
259  //- processorPatch
261 
262  //- Overridable function to handle the particle hitting a wallPatch
264 
265  //- Convert processor patch addressing to the global equivalents
266  // and set the celli to the face-neighbour
267  void correctAfterParallelTransfer(const label, trackingData&);
268 
269 
270  // Ostream Operator
271 
272  friend Ostream& operator<<(Ostream&, const trackedParticle&);
273 };
274 
275 
276 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
277 
278 //- Contiguous data for trackedParticle
279 template<> struct is_contiguous<trackedParticle> : std::true_type {};
280 
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 } // End namespace Foam
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************************************************************* //
void hitWallPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
label k() const noexcept
Transported label.
const barycentric & coordinates() const noexcept
Return current particle coordinates.
Definition: particleI.H:116
void hitCyclicAMIPatch(Cloud< trackedParticle > &, trackingData &, const vector &)
Overridable function to handle the particle hitting a cyclicAMI.
bool hitPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a patch.
void hitCyclicACMIPatch(Cloud< trackedParticle > &, trackingData &, const vector &)
Overridable function to handle the particle hitting a cyclicACMI.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
point & start() noexcept
Point to track from.
bool move(Cloud< trackedParticle > &, trackingData &, const scalar)
Track all particles to their end point.
Base particle class.
Definition: particle.H:69
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 registry collection of lagrangian particles.
Definition: cloud.H:53
autoPtr< trackedParticle > operator()(Istream &is) const
void hitWedgePatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wedge.
label j() const noexcept
Transported label.
Base cloud calls templated on particle type.
Definition: Cloud.H:51
point & end() noexcept
Point to track to.
static autoPtr< particle > Clone(const Derived &p)
Clone a particle.
Definition: particle.H:552
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
void correctAfterParallelTransfer(const label, trackingData &)
Convert processor patch addressing to the global equivalents.
trackingData(Cloud< trackedParticle > &cloud, labelList &maxLevel, List< bitSet > &featureEdgeVisited)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Class used to pass tracking data to the trackToFace function.
static const std::size_t sizeofFields_
Size in bytes of the fields.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
const polyMesh & mesh() const noexcept
Return the mesh database.
Definition: particleI.H:110
void hitSymmetryPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
A template class to specify that a data type can be considered as being contiguous in memory...
Definition: contiguous.H:70
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
void hitProcessorPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a processorPatch.
void hitCyclicPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
label i() const noexcept
Transported label.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
friend Ostream & operator<<(Ostream &, const trackedParticle &)
vector position() const
Return current particle position.
Definition: particleI.H:283
virtual autoPtr< particle > clone() const
Return a clone.
iNew(const polyMesh &mesh)
Namespace for OpenFOAM.