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-2019 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 #include "autoPtr.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward Declarations
52 
53 class trackedParticleCloud;
54 class trackedParticle;
55 
56 Ostream& operator<<(Ostream&, const trackedParticle&);
57 
58 
59 /*---------------------------------------------------------------------------*\
60  Class trackedParticle Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class trackedParticle
64 :
65  public particle
66 {
67  // Private Data
68 
69  //- Start point to track from
70  point start_;
71 
72  //- End point to track to
73  point end_;
74 
75  //- Level of this particle
76  label level_;
77 
78  //- Passive label (used to store feature edge mesh)
79  label i_;
80 
81  //- Passive label (used to store feature edge point)
82  label j_;
83 
84  //- Passive label (used to store feature edge label)
85  label k_;
86 
87 
88 public:
89 
90  friend class Cloud<trackedParticle>;
91 
92  //- Class used to pass tracking data to the trackToFace function
93  class trackingData
94  :
96  {
97  public:
98 
100 
103 
104  // Constructors
105 
107  (
109  labelList& maxLevel,
110  List<bitSet>& featureEdgeVisited
111  )
112  :
114  maxLevel_(maxLevel),
115  featureEdgeVisited_(featureEdgeVisited)
116  {}
117 
118  };
119 
120 
121  // Static Data Members
122 
123  //- Size in bytes of the fields
124  static const std::size_t sizeofFields_;
125 
126 
127  // Constructors
128 
129  //- Construct from components
131  (
132  const polyMesh& mesh,
133  const barycentric& coordinates,
134  const label celli,
135  const label tetFacei,
136  const label tetPtI,
137  const point& end,
138  const label level,
139  const label i,
140  const label j,
141  const label k
142  );
143 
144  //- Construct from a position and a cell,
145  //- searching for the rest of the required topology
147  (
148  const polyMesh& mesh,
149  const vector& position,
150  const label celli,
151  const point& end,
152  const label level,
153  const label i,
154  const label j,
155  const label k
156  );
157 
158  //- Construct from Istream
160  (
161  const polyMesh& mesh,
162  Istream& is,
163  bool readFields = true,
164  bool newFormat = true
165  );
166 
167  //- Construct and return a clone
168  autoPtr<particle> clone() const
169  {
171  }
172 
173  //- Factory class to read-construct particles used for
174  // parallel transfer
175  class iNew
176  {
177  const polyMesh& mesh_;
178 
179  public:
180 
181  iNew(const polyMesh& mesh)
182  :
183  mesh_(mesh)
184  {}
185 
186  autoPtr<trackedParticle> operator()(Istream& is) const
187  {
188  return autoPtr<trackedParticle>::New(mesh_, is, true);
189  }
190  };
191 
192 
193  // Member Functions
194 
195  //- Point to track from
196  point& start() noexcept { return start_; }
198  //- Point to track to
199  point& end() noexcept { return end_; }
200 
201  //- Transported label
202  label i() const noexcept { return i_; }
204  //- Transported label
205  label& i() noexcept { return i_; }
206 
207  //- Transported label
208  label j() const noexcept { return j_; }
209 
210  //- Transported label
211  label& j() noexcept { return j_; }
212 
213  //- Transported label
214  label k() const noexcept { return k_; }
215 
216  //- Transported label
217  label& k() noexcept { return k_; }
218 
219 
221  // Tracking
222 
223  //- Track all particles to their end point
224  bool move(Cloud<trackedParticle>&, trackingData&, const scalar);
226  //- Overridable function to handle the particle hitting a patch
227  // Executed before other patch-hitting functions
229 
230  //- Overridable function to handle the particle hitting a wedge
232 
233  //- Overridable function to handle the particle hitting a
234  // symmetry plane
236 
237  //- Overridable function to handle the particle hitting a
238  // symmetry patch
241  //- Overridable function to handle the particle hitting a cyclic
243 
244  //- Overridable function to handle the particle hitting a cyclicAMI
246  (
248  trackingData&,
249  const vector&
250  );
251 
252  //- Overridable function to handle the particle hitting a cyclicACMI
253  void hitCyclicACMIPatch
254  (
256  trackingData&,
257  const vector&
258  );
259 
260  //- Overridable function to handle the particle hitting a
261  //- processorPatch
263 
264  //- Overridable function to handle the particle hitting a wallPatch
266 
267  //- Convert processor patch addressing to the global equivalents
268  // and set the celli to the face-neighbour
269  void correctAfterParallelTransfer(const label, trackingData&);
270 
271 
272  // Ostream Operator
273 
274  friend Ostream& operator<<(Ostream&, const trackedParticle&);
275 };
276 
277 
278 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
279 
280 //- Contiguous data for trackedParticle
281 template<> struct is_contiguous<trackedParticle> : std::true_type {};
282 
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 } // End namespace Foam
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 #endif
291 
292 // ************************************************************************* //
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
autoPtr< particle > clone() const
Construct and return a clone.
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.
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
vector point
Point is a vector.
Definition: point.H:37
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:74
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
iNew(const polyMesh &mesh)
Namespace for OpenFOAM.