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-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::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  //- Return a clone
148  virtual autoPtr<particle> clone() const
149  {
150  return particle::Clone(*this);
151  }
152 
153  //- Factory class to read-construct particles (for parallel transfer)
154  class iNew
155  {
156  const polyMesh& mesh_;
157 
158  public:
160  iNew(const polyMesh& mesh)
161  :
162  mesh_(mesh)
163  {}
164 
166  {
168  (
169  new findCellParticle(mesh_, is, true)
170  );
171  }
172  };
174 
175  // Member Functions
176 
177  //- Point to track from
178  const point& start() const noexcept { return start_; }
179 
180  //- Point to track from
181  point& start() noexcept { return start_; }
182 
183  //- Point to track to
184  const point& end() const noexcept { return end_; }
185 
186  //- Point to track to
187  point& end() noexcept { return end_; }
188 
189  //- Transported label
190  label data() const noexcept { return data_; }
191 
192  //- Transported label
193  label& data() noexcept { return data_; }
194 
195 
196  // Tracking
197 
198  //- Track all particles to their end point
199  bool move(Cloud<findCellParticle>&, trackingData&, const scalar);
200 
201  //- Overridable function to handle the particle hitting a patch
202  // Executed before other patch-hitting functions
204 
205  //- Overridable function to handle the particle hitting a wedge
207 
208  //- Overridable function to handle the particle hitting a
209  // symmetry plane
211 
212  //- Overridable function to handle the particle hitting a
213  // symmetry patch
215 
216  //- Overridable function to handle the particle hitting a cyclic
219  //- Overridable function to handle the particle hitting a cyclicAMI
220  void hitCyclicAMIPatch
221  (
223  trackingData&,
224  const vector&
225  );
226 
227  //- Overridable function to handle the particle hitting a cyclicACMI
228  void hitCyclicACMIPatch
229  (
231  trackingData&,
232  const vector&
233  );
234 
235  //- Overridable function to handle the particle hitting a
236  //- processorPatch
238 
239  //- Overridable function to handle the particle hitting a wallPatch
241 
242 
243  // Ostream Operator
244 
245  friend Ostream& operator<<(Ostream&, const findCellParticle&);
246 };
247 
248 
249 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
250 
251 //- Contiguous data for findCellParticle
252 template<> struct is_contiguous<findCellParticle> : std::true_type {};
253 
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 } // End namespace Foam
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #endif
262 
263 // ************************************************************************* //
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.
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
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
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
vector point
Point is a vector.
Definition: point.H:37
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.
virtual autoPtr< particle > clone() const
Return a clone.
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:75
void hitWallPatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
Factory class to read-construct particles (for parallel transfer)
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.