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 trackedParticle_H
40 #define 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 
102 
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, searching for the rest of the
145  // 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 
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()
197  {
198  return start_;
199  }
200 
201  //- Point to track to
202  point& end()
203  {
204  return end_;
205  }
206 
207  //- Transported label
208  label i() const
209  {
210  return i_;
211  }
212 
213  //- Transported label
214  label& i()
215  {
216  return i_;
217  }
218 
219  //- Transported label
220  label j() const
221  {
222  return j_;
223  }
224 
225  //- Transported label
226  label& j()
227  {
228  return j_;
229  }
230 
231  //- Transported label
232  label k() const
233  {
234  return k_;
235  }
236 
237  //- Transported label
238  label& k()
239  {
240  return k_;
241  }
242 
243 
244 
245  // Tracking
246 
247  //- Track all particles to their end point
248  bool move(Cloud<trackedParticle>&, trackingData&, const scalar);
249 
250  //- Overridable function to handle the particle hitting a patch
251  // Executed before other patch-hitting functions
252  bool hitPatch(Cloud<trackedParticle>&, trackingData&);
253 
254  //- Overridable function to handle the particle hitting a wedge
255  void hitWedgePatch(Cloud<trackedParticle>&, trackingData&);
256 
257  //- Overridable function to handle the particle hitting a
258  // symmetry plane
259  void hitSymmetryPlanePatch(Cloud<trackedParticle>&, trackingData&);
260 
261  //- Overridable function to handle the particle hitting a
262  // symmetry patch
263  void hitSymmetryPatch(Cloud<trackedParticle>&, trackingData&);
264 
265  //- Overridable function to handle the particle hitting a cyclic
266  void hitCyclicPatch(Cloud<trackedParticle>&, trackingData&);
267 
268  //- Overridable function to handle the particle hitting a cyclicAMI
269  void hitCyclicAMIPatch
270  (
272  trackingData&,
273  const vector&
274  );
275 
276  //- Overridable function to handle the particle hitting a cyclicACMI
277  void hitCyclicACMIPatch
278  (
280  trackingData&,
281  const vector&
282  );
283 
284  //- Overridable function to handle the particle hitting a
285  //- processorPatch
286  void hitProcessorPatch(Cloud<trackedParticle>&, trackingData&);
287 
288  //- Overridable function to handle the particle hitting a wallPatch
289  void hitWallPatch(Cloud<trackedParticle>&, trackingData&);
290 
291  //- Convert processor patch addressing to the global equivalents
292  // and set the celli to the face-neighbour
293  void correctAfterParallelTransfer(const label, trackingData&);
294 
295 
296  // Ostream Operator
297 
298  friend Ostream& operator<<(Ostream&, const trackedParticle&);
299 };
300 
301 
302 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
303 
304 //- Contiguous data for trackedParticle
305 template<> struct is_contiguous<trackedParticle> : std::true_type {};
306 
307 
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 
310 } // End namespace Foam
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 #endif
315 
316 // ************************************************************************* //
Foam::trackedParticle::hitPatch
bool hitPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a patch.
Definition: trackedParticle.C:172
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Foam::trackedParticle::trackingData
Class used to pass tracking data to the trackToFace function.
Definition: trackedParticle.H:92
Foam::trackedParticle::iNew::iNew
iNew(const polyMesh &mesh)
Definition: trackedParticle.H:180
Foam::trackedParticle::sizeofFields_
static const std::size_t sizeofFields_
Size in bytes of the fields.
Definition: trackedParticle.H:123
Foam::trackedParticle::trackingData::trackingData
trackingData(Cloud< trackedParticle > &cloud, labelList &maxLevel, List< bitSet > &featureEdgeVisited)
Definition: trackedParticle.H:106
Foam::trackedParticle::clone
autoPtr< particle > clone() const
Construct and return a clone.
Definition: trackedParticle.H:167
Foam::particle::readFields
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
Definition: particleTemplates.C:140
bitSet.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::particle::coordinates
const barycentric & coordinates() const
Return current particle coordinates.
Definition: particleI.H:143
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::trackedParticle::hitSymmetryPlanePatch
void hitSymmetryPlanePatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
Definition: trackedParticle.C:190
Foam::trackedParticle::k
label & k()
Transported label.
Definition: trackedParticle.H:237
Foam::trackedParticle::k
label k() const
Transported label.
Definition: trackedParticle.H:231
Foam::trackedParticle::i
label i() const
Transported label.
Definition: trackedParticle.H:207
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::trackedParticle::end
point & end()
Point to track to.
Definition: trackedParticle.H:201
Foam::trackedParticle::hitSymmetryPatch
void hitSymmetryPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
Definition: trackedParticle.C:201
Foam::particle::position
vector position() const
Return current particle position.
Definition: particleI.H:314
Foam::Barycentric< scalar >
Foam::trackedParticle::iNew
Factory class to read-construct particles used for.
Definition: trackedParticle.H:174
Foam::particle::mesh
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:137
Foam::trackedParticle::i
label & i()
Transported label.
Definition: trackedParticle.H:213
Foam::trackedParticle::operator<<
friend Ostream & operator<<(Ostream &, const trackedParticle &)
Foam::trackedParticle::hitWedgePatch
void hitWedgePatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wedge.
Definition: trackedParticle.C:179
Foam::trackedParticle::trackingData::maxLevel_
labelList & maxLevel_
Definition: trackedParticle.H:98
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::trackedParticle::iNew::operator()
autoPtr< trackedParticle > operator()(Istream &is) const
Definition: trackedParticle.H:185
Foam::trackedParticle::j
label & j()
Transported label.
Definition: trackedParticle.H:225
Foam::trackedParticle::hitWallPatch
void hitWallPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
Definition: trackedParticle.C:258
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::cloud
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:57
Foam::trackedParticle::start
point & start()
Point to track from.
Definition: trackedParticle.H:195
Foam::trackedParticle::hitCyclicPatch
void hitCyclicPatch(Cloud< trackedParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
Definition: trackedParticle.C:212
Foam::trackedParticle::trackedParticle
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.
Definition: trackedParticle.C:42
Foam::trackedParticle::j
label j() const
Transported label.
Definition: trackedParticle.H:219
Foam::Vector< scalar >
Foam::List< label >
Foam::particle
Base particle class.
Definition: particle.H:76
Foam::trackedParticle::hitCyclicAMIPatch
void hitCyclicAMIPatch(Cloud< trackedParticle > &, trackingData &, const vector &)
Overridable function to handle the particle hitting a cyclicAMI.
Definition: trackedParticle.C:223
Foam::Cloud
Base cloud calls templated on particle type.
Definition: Cloud.H:55
particle.H
Foam::trackedParticle::hitProcessorPatch
void hitProcessorPatch(Cloud< trackedParticle > &, trackingData &)
Definition: trackedParticle.C:247
Foam::trackedParticle
Particle class that marks cells it passes through. Used to mark cells visited by feature edges.
Definition: trackedParticle.H:62
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::particle::trackingData
Definition: particle.H:95
Foam::trackedParticle::hitCyclicACMIPatch
void hitCyclicACMIPatch(Cloud< trackedParticle > &, trackingData &, const vector &)
Overridable function to handle the particle hitting a cyclicACMI.
Definition: trackedParticle.C:235
Foam::trackedParticle::trackingData::featureEdgeVisited_
List< bitSet > & featureEdgeVisited_
Definition: trackedParticle.H:100
Foam::is_contiguous
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:75
Foam::trackedParticle::move
bool move(Cloud< trackedParticle > &, trackingData &, const scalar)
Track all particles to their end point.
Definition: trackedParticle.C:134
Foam::trackedParticle::correctAfterParallelTransfer
void correctAfterParallelTransfer(const label, trackingData &)
Convert processor patch addressing to the global equivalents.
Definition: trackedParticle.C:269
autoPtr.H