findCellParticle.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) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 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::findCellParticle
29 
30 Description
31  Particle class that finds cells by tracking
32 
33 SourceFiles
34  findCellParticle.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_findCellParticle_H
39 #define Foam_findCellParticle_H
40 
41 #include "particle.H"
42 #include "autoPtr.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 class findCellParticleCloud;
51 class findCellParticle;
52 
53 Ostream& operator<<(Ostream&, const findCellParticle&);
54 
55 
56 /*---------------------------------------------------------------------------*\
57  Class findCellParticle Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class findCellParticle
61 :
62  public particle
63 {
64  // Private data
65 
66  //- Start point to track from
67  point start_;
68 
69  //- End point to track to
70  point end_;
71 
72  //- Passive data
73  label data_;
74 
75 
76 public:
77 
78  friend class Cloud<findCellParticle>;
79 
80  //- Class used to pass tracking data to the trackToFace function
81  class trackingData
82  :
84  {
85  labelListList& cellToData_;
86  List<List<point>>& cellToEnd_;
87 
88  public:
89 
90  // Constructors
91 
93  (
97  )
98  :
100  cellToData_(cellToData),
101  cellToEnd_(cellToEnd)
102  {}
103 
104 
105  // Member Functions
106 
107  labelListList& cellToData() noexcept { return cellToData_; }
108 
109  List<List<point>>& cellToEnd() noexcept { return cellToEnd_; }
110  };
111 
113  // Constructors
114 
115  //- Construct from components
117  (
118  const polyMesh& mesh,
119  const barycentric& coordinates,
120  const label celli,
121  const label tetFacei,
122  const label tetPti,
123  const point& end,
124  const label data
125  );
126 
127  //- Construct from a position and a cell,
128  //- searching for the rest of the required topology
130  (
131  const polyMesh& mesh,
132  const vector& position,
133  const label celli,
134  const point& end,
135  const label data
136  );
137 
138  //- Construct from Istream
140  (
141  const polyMesh& mesh,
142  Istream& is,
143  bool readFields = true,
144  bool newFormat = true
145  );
146 
147  //- Construct and return a clone
148  autoPtr<particle> clone() const
149  {
150  return autoPtr<particle>(new findCellParticle(*this));
151  }
152 
153  //- Factory class to read-construct particles used for
154  // parallel transfer
155  class iNew
156  {
157  const polyMesh& mesh_;
158 
159  public:
160 
161  iNew(const polyMesh& mesh)
162  :
163  mesh_(mesh)
164  {}
165 
167  {
169  (
170  new findCellParticle(mesh_, is, true)
171  );
172  }
173  };
174 
176  // Member Functions
177 
178  //- Point to track from
179  const point& start() const noexcept { return start_; }
181  //- Point to track from
182  point& start() noexcept { return start_; }
183 
184  //- Point to track to
185  const point& end() const noexcept { return end_; }
186 
187  //- Point to track to
188  point& end() noexcept { return end_; }
189 
190  //- Transported label
191  label data() const noexcept { return data_; }
192 
193  //- Transported label
194  label& data() noexcept { return data_; }
196 
197  // Tracking
198 
199  //- Track all particles to their end point
200  bool move(Cloud<findCellParticle>&, trackingData&, const scalar);
201 
202  //- Overridable function to handle the particle hitting a patch
203  // Executed before other patch-hitting functions
206  //- Overridable function to handle the particle hitting a wedge
208 
209  //- Overridable function to handle the particle hitting a
210  // symmetry plane
212 
213  //- Overridable function to handle the particle hitting a
214  // symmetry patch
216 
217  //- Overridable function to handle the particle hitting a cyclic
219 
220  //- Overridable function to handle the particle hitting a cyclicAMI
221  void hitCyclicAMIPatch
222  (
224  trackingData&,
225  const vector&
226  );
227 
228  //- Overridable function to handle the particle hitting a cyclicACMI
229  void hitCyclicACMIPatch
230  (
232  trackingData&,
233  const vector&
234  );
235 
236  //- Overridable function to handle the particle hitting a
237  //- processorPatch
239 
240  //- Overridable function to handle the particle hitting a wallPatch
242 
243 
244  // Ostream Operator
245 
246  friend Ostream& operator<<(Ostream&, const findCellParticle&);
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
251 
252 //- Contiguous data for findCellParticle
253 template<> struct is_contiguous<findCellParticle> : std::true_type {};
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 } // End namespace Foam
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
label data() const noexcept
Transported label.
friend Ostream & operator<<(Ostream &, const findCellParticle &)
void hitCyclicAMIPatch(Cloud< findCellParticle > &, trackingData &, const vector &)
Overridable function to handle the particle hitting a cyclicAMI.
autoPtr< particle > clone() const
Construct and return a clone.
bool move(Cloud< findCellParticle > &, trackingData &, const scalar)
Track all particles to their end point.
const barycentric & coordinates() const noexcept
Return current particle coordinates.
Definition: particleI.H:116
iNew(const polyMesh &mesh)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void hitCyclicPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclic.
void hitSymmetryPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a.
void hitCyclicACMIPatch(Cloud< findCellParticle > &, trackingData &, const vector &)
Overridable function to handle the particle hitting a cyclicACMI.
Base particle class.
Definition: particle.H:69
void hitProcessorPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a processorPatch.
void hitWedgePatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a wedge.
const point & start() const noexcept
Point to track from.
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:53
findCellParticle(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti, const point &end, const label data)
Construct from components.
Base cloud calls templated on particle type.
Definition: Cloud.H:51
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
List< List< point > > & cellToEnd() noexcept
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
bool hitPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a patch.
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
labelListList & cellToData() noexcept
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.
Particle class that finds cells by tracking.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
void hitWallPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
Factory class to read-construct particles used for.
Class used to pass tracking data to the trackToFace function.
vector position() const
Return current particle position.
Definition: particleI.H:283
autoPtr< findCellParticle > operator()(Istream &is) const
trackingData(Cloud< findCellParticle > &cloud, labelListList &cellToData, List< List< point >> &cellToEnd)
Namespace for OpenFOAM.
const point & end() const noexcept
Point to track to.
void hitSymmetryPlanePatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a.