sampledSetParticle.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) 2021-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::sampledSetParticle
26 
27 Description
28  Particle for generating line-type sampled sets
29 
30 SourceFiles
31  sampledSetParticle.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef sampledSetParticle_H
36 #define sampledSetParticle_H
37 
38 #include "particle.H"
39 #include "Cloud.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of friend functions and operators
47 
48 class sampledSetParticle;
49 class sampledSetCloud;
50 
51 Ostream& operator<<(Ostream&, const sampledSetParticle&);
52 
53 
54 /*---------------------------------------------------------------------------*\
55  Class sampledSetParticle Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 :
60  public particle
61 {
62 public:
63 
64  //- Tracking data class
65  class trackingData
66  :
68  {
69  public:
70 
71  //- List of set points to track through
72  const List<point>& set_;
73 
74  //- Are we storing the set points?
75  const bool storeSet_;
76 
77  //- Are we storing the faces we track through?
78  const bool storeFaces_;
79 
80  //- Are we storing the cells we track through?
81  const bool storeCells_;
82 
83  //- Stored positions
85 
86  //- Stored distances
88 
89  //- Stored cell indices
91 
92  //- Stored face indices
94 
95  //- Construct from components
97  (
99  const List<point>& set,
100  bool storeSet,
101  bool storeFaces,
102  bool storeCells,
103  DynamicList<point>& positions,
104  DynamicList<scalar>& distances,
106  DynamicList<label>& faces
107  )
108  :
109  particle::trackingData(cloud),
110  set_(set),
111  storeSet_(storeSet),
112  storeFaces_(storeFaces),
113  storeCells_(storeCells),
114  positions_(positions),
115  distances_(distances),
116  cells_(cells),
117  faces_(faces)
118  {}
119  };
120 
121 
122 private:
123 
124  // Private Data
125 
126  //- The set interval we are currently within
127  label seti_;
128 
129  //- The fraction of this set interval from the end
130  scalar setF_;
131 
132  //- The scalar distance through the set
133  scalar distance_;
134 
135  //- Do we have the previous face position stored?
136  bool havePosition0_;
137 
138  //- The previous face position
139  point position0_;
140 
141 
142 public:
143 
144  // Constructors
145 
146  //- Construct from components
148  (
149  const polyMesh& mesh,
150  const point& position,
151  const label celli,
152  const label seti,
153  const scalar setF,
154  const scalar distance
155  );
156 
157  //- Construct from Istream
159  (
160  const polyMesh& mesh,
161  Istream& is,
162  bool readFields = true
163  );
164 
165  //- Copy constructor
167 
168  //- Construct and return a clone
169  autoPtr<particle> clone() const
170  {
171  return autoPtr<particle>(new sampledSetParticle(*this));
172  }
173 
174  //- Factory class to read-construct particles used for parallel transfer
175  class iNew
176  {
177  const polyMesh& mesh_;
178 
179  public:
181  iNew(const polyMesh& mesh)
182  :
183  mesh_(mesh)
184  {}
186  autoPtr<sampledSetParticle> operator()(Istream& is) const
187  {
189  (
190  new sampledSetParticle(mesh_, is, true)
191  );
192  }
193  };
194 
195 
196  // Member Functions
197 
198  // Storage
199 
200  //- Store a point
202 
203  //- Store a point on a face
205 
206  //- Store a point in a cell
208 
209 
210  // Tracking
211 
212  //- Track all particles to their end point
213  bool move(sampledSetCloud&, trackingData&, const scalar);
214 
215  //- Hit a wedge patch. Ends the track.
217 
218  //- Hit a symmetry patch. Ends the track.
220 
221  //- Hit a symmetry plane patch. Ends the track.
223 
224  //- Hit a cyclic patch. Ends the track.
226 
227  //- Hit a cyclicAMI patch. Ends the track.
228  void hitCyclicAMIPatch
229  (
230  const vector&,
231  const scalar,
233  trackingData&
234  );
235 
236  //- Hit a processor patch. Transfers the particle if there is no
237  // transformation. Ends the track if there is a transformation.
239 
240  //- Hit a wall patch. Ends the track.
242 
243 
244  // IOstream Operators
245 
246  friend Ostream& operator<<(Ostream&, const sampledSetParticle&);
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
bool move(sampledSetCloud &, trackingData &, const scalar)
Track all particles to their end point.
Particle for generating line-type sampled sets.
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:125
DynamicList< label > & faces_
Stored face indices.
void hitSymmetryPlanePatch(sampledSetCloud &, trackingData &)
Hit a symmetry patch. Ends the track.
void store(sampledSetCloud &, trackingData &)
Store a point.
friend Ostream & operator<<(Ostream &, const sampledSetParticle &)
void hitCyclicAMIPatch(const vector &, const scalar, sampledSetCloud &, trackingData &)
Hit a cyclicAMI patch. Ends the track.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
void hitSymmetryPatch(sampledSetCloud &, trackingData &)
Hit a symmetry plane patch. Ends the track.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
scalar distance(const vector &p1, const vector &p2)
Definition: curveTools.C:12
const bool storeCells_
Are we storing the cells we track through?
DynamicList< point > & positions_
Stored positions.
void hitProcessorPatch(sampledSetCloud &, trackingData &)
Hit a processor patch. Transfers the particle if there is no.
void storeFace(sampledSetCloud &, trackingData &)
Store a point on a face.
autoPtr< particle > clone() const
Construct and return a clone.
Base particle class.
Definition: particle.H:81
void storeCell(sampledSetCloud &, trackingData &)
Store a point in a cell.
const bool storeFaces_
Are we storing the faces we track through?
void hitCyclicPatch(sampledSetCloud &, trackingData &)
Hit a cyclic patch. Ends the track.
const cellShapeList & cells
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
A Cloud of sampledSet particles.
const bool storeSet_
Are we storing the set points?
DynamicList< label > & cells_
Stored cell indices.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Factory class to read-construct particles used for parallel transfer.
DynamicList< scalar > & distances_
Stored distances.
trackingData(sampledSetCloud &cloud, const List< point > &set, bool storeSet, bool storeFaces, bool storeCells, DynamicList< point > &positions, DynamicList< scalar > &distances, DynamicList< label > &cells, DynamicList< label > &faces)
Construct from components.
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
Ostream & operator<<(Ostream &, const ensightPart &)
void hitWedgePatch(sampledSetCloud &, trackingData &)
Hit a wedge patch. Ends the track.
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
const List< point > & set_
List of set points to track through.
sampledSetParticle(const polyMesh &mesh, const point &position, const label celli, const label seti, const scalar setF, const scalar distance)
Construct from components.
vector position() const
Return current particle position.
Definition: particleI.H:278
void hitWallPatch(sampledSetCloud &, trackingData &)
Hit a wall patch. Ends the track.
Namespace for OpenFOAM.