findCellParticle.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::findCellParticle
26 
27 Description
28  Particle class that finds cells by tracking
29 
30 SourceFiles
31  findCellParticle.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef findCellParticle_H
36 #define findCellParticle_H
37 
38 #include "particle.H"
39 #include "Cloud.H"
40 #include "autoPtr.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 class findCellParticleCloud;
48 
49 
50 // Forward declaration of friend functions and operators
51 
52 class findCellParticle;
53 
54 Ostream& operator<<(Ostream&, const findCellParticle&);
55 
56 
57 /*---------------------------------------------------------------------------*\
58  Class findCellParticle Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class findCellParticle
62 :
63  public particle
64 {
65  // Private Data
66 
67  //- Displacement over which to track
68  vector displacement_;
69 
70  //- Passive data
71  label data_;
72 
73 
74 public:
75 
76  friend class Cloud<findCellParticle>;
77 
78  //- Class used to pass tracking data to the trackToFace function
79  class trackingData
80  :
82  {
83  labelListList& cellToData_;
84  List<List<point>>& cellToEnd_;
85 
86  public:
87 
88  // Constructors
89 
91  (
95  )
96  :
97  particle::trackingData(cloud),
98  cellToData_(cellToData),
99  cellToEnd_(cellToEnd)
100  {}
101 
102 
103  // Member Functions
106  {
107  return cellToData_;
108  }
111  {
112  return cellToEnd_;
113  }
114  };
115 
116 
117  // Constructors
118 
119  //- Construct from components
121  (
122  const polyMesh& mesh,
123  const barycentric& coordinates,
124  const label celli,
125  const label tetFacei,
126  const label tetPtI,
127  const vector& displacement,
128  const label data
129  );
130 
131  //- Construct from a position and a cell, searching for the rest of the
132  // required topology
134  (
135  const polyMesh& mesh,
136  const vector& position,
137  const label celli,
138  const vector& displacement,
139  const label data
140  );
141 
142  //- Construct from Istream
144  (
145  const polyMesh& mesh,
146  Istream& is,
147  bool readFields = true
148  );
149 
150  //- Construct and return a clone
151  autoPtr<particle> clone() const
152  {
153  return autoPtr<particle>(new findCellParticle(*this));
154  }
155 
156  //- Factory class to read-construct particles used for
157  // parallel transfer
158  class iNew
159  {
160  const polyMesh& mesh_;
161 
162  public:
164  iNew(const polyMesh& mesh)
165  :
166  mesh_(mesh)
167  {}
169  autoPtr<findCellParticle> operator()(Istream& is) const
170  {
172  (
173  new findCellParticle(mesh_, is, true)
174  );
175  }
176  };
177 
178 
179  // Member Functions
180 
181  //- Displacement over which to track
182  const vector& displacement() const
183  {
184  return displacement_;
185  }
186 
187  //- Displacement over which to track
189  {
190  return displacement_;
191  }
192 
193  //- Transported label
194  label data() const
195  {
196  return data_;
197  }
198 
199  //- Transported label
200  label& data()
201  {
202  return data_;
203  }
204 
205 
206  // Tracking
207 
208  //- Track all particles to their end point
209  bool move(Cloud<findCellParticle>&, trackingData&, const scalar);
210 
211  //- Overridable function to handle the particle hitting a wedge
213 
214  //- Overridable function to handle the particle hitting a
215  // symmetry plane
217 
218  //- Overridable function to handle the particle hitting a
219  // symmetry patch
221 
222  //- Overridable function to handle the particle hitting a cyclic
224 
225  //- Overridable function to handle the particle hitting a cyclicAMI
226  void hitCyclicAMIPatch
227  (
228  const vector&,
229  const scalar,
231  trackingData&
232  );
233 
234  //- Overridable function to handle the particle hitting a
235  //- processorPatch
237 
238  //- Overridable function to handle the particle hitting a wallPatch
240 
241 
242  // Ostream Operator
243 
244  friend Ostream& operator<<(Ostream&, const findCellParticle&);
245 };
246 
247 
248 template<>
249 inline bool contiguous<findCellParticle>()
250 {
251  return true;
252 }
253 
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 } // End namespace Foam
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #endif
262 
263 // ************************************************************************* //
friend Ostream & operator<<(Ostream &, const findCellParticle &)
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:125
bool contiguous< findCellParticle >()
autoPtr< particle > clone() const
Construct and return a clone.
bool move(Cloud< findCellParticle > &, trackingData &, const scalar)
Track all particles to their end point.
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.
Base particle class.
Definition: particle.H:81
void hitProcessorPatch(Cloud< findCellParticle > &, trackingData &)
void hitWedgePatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a wedge.
findCellParticle(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPtI, const vector &displacement, const label data)
Construct from components.
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
label data() const
Transported label.
Base cloud calls templated on particle type.
Definition: Cloud.H:52
void hitCyclicAMIPatch(const vector &, const scalar, Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a cyclicAMI.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Database for solution and other reduced data.
Definition: data.H:51
const vector & displacement() const
Displacement over which to track.
List< List< point > > & cellToEnd()
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
Ostream & operator<<(Ostream &, const ensightPart &)
Particle class that finds cells by tracking.
const barycentric & coordinates() const
Return current particle coordinates.
Definition: particleI.H:131
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
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:278
trackingData(Cloud< findCellParticle > &cloud, labelListList &cellToData, List< List< point >> &cellToEnd)
Namespace for OpenFOAM.
void hitSymmetryPlanePatch(Cloud< findCellParticle > &, trackingData &)
Overridable function to handle the particle hitting a.