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 components
154  (
155  const polyMesh& mesh,
156  const point& position,
157  const label celli,
158  label& nLocateBoundaryHits,
159  const label seti,
160  const scalar setF,
161  const scalar distance
162  );
163 
164  //- Construct from Istream
165  sampledSetParticle(Istream& is, bool readFields = true);
166 
167  //- Copy constructor
169 
170  //- Construct and return a clone
171  autoPtr<particle> clone() const
172  {
173  return autoPtr<particle>(new sampledSetParticle(*this));
174  }
175 
176  //- Construct from Istream and return
178  {
180  }
181 
182 
183  // Member Functions
184 
185  // Storage
186 
187  //- Store a point
188  void store(sampledSetCloud&, trackingData&);
189 
190  //- Store a point on a face
191  void storeFace(sampledSetCloud&, trackingData&);
192 
193  //- Store a point in a cell
194  void storeCell(sampledSetCloud&, trackingData&);
195 
196 
197  // Tracking
198 
199  //- Track all particles to their end point
200  bool move(sampledSetCloud&, trackingData&);
201 
202  //- Hit a wedge patch. Ends the track.
203  void hitWedgePatch(sampledSetCloud&, trackingData&);
204 
205  //- Hit a symmetry patch. Ends the track.
206  void hitSymmetryPlanePatch(sampledSetCloud&, trackingData&);
207 
208  //- Hit a symmetry plane patch. Ends the track.
209  void hitSymmetryPatch(sampledSetCloud&, trackingData&);
210 
211  //- Hit a cyclic patch. Ends the track.
212  void hitCyclicPatch(sampledSetCloud&, trackingData&);
213 
214  //- Hit a processor patch. Transfers the particle if there is no
215  // transformation. Ends the track if there is a transformation.
216  void hitProcessorPatch(sampledSetCloud&, trackingData&);
217 
218  //- Hit a wall patch. Ends the track.
219  void hitWallPatch(sampledSetCloud&, trackingData&);
220 
221  //- Do corrections to the particle and tracking data following a
222  // transfer between processors
223  void correctAfterParallelTransfer(sampledSetCloud&, trackingData&);
224 
225 
226  // IOstream Operators
227 
228  friend Ostream& operator<<(Ostream&, const sampledSetParticle&);
229 };
230 
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 } // End namespace Foam
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
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:63
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:159
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.
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 &)
sampledSetParticle(const polyMesh &mesh, const point &position, const label celli, label &nLocateBoundaryHits, const label seti, const scalar setF, const scalar distance)
Construct from components.
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.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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)