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-2023 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  // 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
158  sampledSetParticle(Istream& is, bool readFields = true);
159 
160  //- Copy constructor
162 
163  //- Construct and return a clone
164  autoPtr<particle> clone() const
165  {
166  return autoPtr<particle>(new sampledSetParticle(*this));
167  }
168 
169  //- Construct from Istream and return
171  {
173  }
174 
175 
176  // Member Functions
177 
178  // Storage
179 
180  //- Store a point
181  void store(sampledSetCloud&, trackingData&);
182 
183  //- Store a point on a face
184  void storeFace(sampledSetCloud&, trackingData&);
185 
186  //- Store a point in a cell
187  void storeCell(sampledSetCloud&, trackingData&);
188 
189 
190  // Tracking
191 
192  //- Track all particles to their end point
193  bool move(sampledSetCloud&, trackingData&);
194 
195  //- Hit a wedge patch. Ends the track.
196  void hitWedgePatch(sampledSetCloud&, trackingData&);
197 
198  //- Hit a symmetry patch. Ends the track.
199  void hitSymmetryPlanePatch(sampledSetCloud&, trackingData&);
200 
201  //- Hit a symmetry plane patch. Ends the track.
202  void hitSymmetryPatch(sampledSetCloud&, trackingData&);
203 
204  //- Hit a cyclic patch. Ends the track.
205  void hitCyclicPatch(sampledSetCloud&, trackingData&);
206 
207  //- Hit a processor patch. Transfers the particle if there is no
208  // transformation. Ends the track if there is a transformation.
209  void hitProcessorPatch(sampledSetCloud&, trackingData&);
210 
211  //- Hit a wall patch. Ends the track.
212  void hitWallPatch(sampledSetCloud&, trackingData&);
213 
214  //- Do corrections to the particle and tracking data following a
215  // transfer between processors
216  void correctAfterParallelTransfer(sampledSetCloud&, trackingData&);
217 
218 
219  // IOstream Operators
220 
221  friend Ostream& operator<<(Ostream&, const sampledSetParticle&);
222 };
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace Foam
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #endif
232 
233 // ************************************************************************* //
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
A cloud is a collection of lagrangian particles.
Definition: cloud.H:55
Base particle class.
Definition: particle.H:83
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:255
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
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.
sampledSetParticle(const polyMesh &mesh, const point &position, const label celli, const label seti, const scalar setF, const scalar distance)
Construct from components.
void storeFace(sampledSetCloud &, trackingData &)
Store a point on a face.
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.
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 &, const ensightPart &)