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-2025 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 label 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  const bool storeSet,
101  const label storeFaces,
102  const bool storeCells,
103  DynamicList<point>& positions,
104  DynamicList<scalar>& distances,
106  DynamicList<label>& faces
107  )
108  :
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  // Static Data Members
145 
146  //- Sample sets are computed at an instant
147  static const bool instantaneous = true;
148 
149 
150  // Constructors
151 
152  //- Construct from a position and a cell, searching for the rest of the
153  // required topology
155  (
156  const meshSearch& searchEngine,
157  const point& position,
158  const label celli,
159  label& nLocateBoundaryHits,
160  const label seti,
161  const scalar setF,
162  const scalar distance
163  );
164 
165  //- Construct from Istream
166  sampledSetParticle(Istream& is, bool readFields = true);
167 
168  //- Copy constructor
170 
171  //- Construct and return a clone
172  autoPtr<particle> clone() const
173  {
174  return autoPtr<particle>(new sampledSetParticle(*this));
175  }
176 
177  //- Construct from Istream and return
179  {
181  }
182 
183 
184  // Member Functions
185 
186  // Storage
187 
188  //- Store a point
189  void store(sampledSetCloud&, trackingData&);
190 
191  //- Store a point on a face
192  void storeFace(sampledSetCloud&, trackingData&);
193 
194  //- Store a point in a cell
195  void storeCell(sampledSetCloud&, trackingData&);
196 
197 
198  // Tracking
199 
200  //- Track all particles to their end point
201  bool move(sampledSetCloud&, trackingData&);
202 
203  //- Hit a wedge patch. Ends the track.
204  void hitWedgePatch(sampledSetCloud&, trackingData&);
205 
206  //- Hit a symmetry patch. Ends the track.
207  void hitSymmetryPlanePatch(sampledSetCloud&, trackingData&);
208 
209  //- Hit a symmetry plane patch. Ends the track.
210  void hitSymmetryPatch(sampledSetCloud&, trackingData&);
211 
212  //- Hit a cyclic patch. Ends the track.
213  void hitCyclicPatch(sampledSetCloud&, trackingData&);
214 
215  //- Hit a processor patch. Transfers the particle if there is no
216  // transformation. Ends the track if there is a transformation.
217  void hitProcessorPatch(sampledSetCloud&, trackingData&);
218 
219  //- Hit a wall patch. Ends the track.
220  void hitWallPatch(sampledSetCloud&, trackingData&);
221 
222  //- Do corrections to the particle and tracking data following a
223  // transfer between processors
224  void correctAfterParallelTransfer(sampledSetCloud&, trackingData&);
225 
226 
227  // IOstream Operators
228 
229  friend Ostream& operator<<(Ostream&, const sampledSetParticle&);
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #endif
240 
241 // ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:78
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
Mesh object that implements searches within the local cells and faces.
Definition: meshSearch.H:59
Base particle class.
Definition: particle.H:85
static void readFields(TrackCloudType &c)
Read the fields associated with the owner cloud.
vector position(const polyMesh &mesh) const
Return current particle position.
Definition: particleI.H:159
A Cloud of sampledSet particles.
trackingData(sampledSetCloud &cloud, const List< point > &set, const bool storeSet, const label storeFaces, const bool storeCells, DynamicList< point > &positions, DynamicList< scalar > &distances, DynamicList< label > &cells, DynamicList< label > &faces)
Construct from components.
DynamicList< label > & cells_
Stored cell indices.
const bool storeCells_
Are we storing the cells we track through?
DynamicList< point > & positions_
Stored positions.
const bool storeSet_
Are we storing the set points?
const List< point > & set_
List of set points to track through.
DynamicList< label > & faces_
Stored face indices.
const label storeFaces_
Are we storing the faces we track through?
DynamicList< scalar > & distances_
Stored distances.
Particle for generating line-type sampled sets.
void hitCyclicPatch(sampledSetCloud &, trackingData &)
Hit a cyclic patch. Ends the track.
void storeFace(sampledSetCloud &, trackingData &)
Store a point on a face.
static const bool instantaneous
Sample sets are computed at an instant.
void hitWallPatch(sampledSetCloud &, trackingData &)
Hit a wall patch. Ends the track.
bool move(sampledSetCloud &, trackingData &)
Track all particles to their end point.
friend Ostream & operator<<(Ostream &, const sampledSetParticle &)
void storeCell(sampledSetCloud &, trackingData &)
Store a point in a cell.
void hitSymmetryPatch(sampledSetCloud &, trackingData &)
Hit a symmetry plane patch. Ends the track.
void store(sampledSetCloud &, trackingData &)
Store a point.
void hitWedgePatch(sampledSetCloud &, trackingData &)
Hit a wedge patch. Ends the track.
sampledSetParticle(const meshSearch &searchEngine, const point &position, const label celli, label &nLocateBoundaryHits, const label seti, const scalar setF, const scalar distance)
Construct from a position and a cell, searching for the rest of the.
void correctAfterParallelTransfer(sampledSetCloud &, trackingData &)
Do corrections to the particle and tracking data following a.
static autoPtr< sampledSetParticle > New(Istream &is)
Construct from Istream and return.
autoPtr< particle > clone() const
Construct and return a clone.
void hitProcessorPatch(sampledSetCloud &, trackingData &)
Hit a processor patch. Transfers the particle if there is no.
void hitSymmetryPlanePatch(sampledSetCloud &, trackingData &)
Hit a symmetry patch. Ends the track.
const cellShapeList & cells
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)