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