ParticleCollector.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) 2012-2021 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::ParticleCollector
26 
27 Description
28  Function object to collect the parcel mass- and mass flow rate over a
29  set of polygons. The polygons can either be specified by sets of user-
30  supplied points, or in a concentric circles arrangement. If a
31  parcel is 'collected', it can be flagged to be removed from the
32  domain using the removeCollected entry.
33 
34  Example usage:
35  \verbatim
36  particleCollector1
37  {
38  type particleCollector;
39 
40  mode concentricCircle;
41  origin (0.05 0.025 0.005);
42  radius (0.01 0.025 0.05);
43  nSector 10;
44  refDir (1 0 0);
45  normal (0 0 1);
46 
47  negateParcelsOppositeNormal no;
48  removeCollected no;
49  surfaceFormat vtk;
50  resetOnWrite no;
51  log yes;
52  }
53 
54  particleCollector2
55  {
56  type particleCollector;
57 
58  mode polygon;
59  polygons
60  (
61  (
62  (0 0 0)
63  (1 0 0)
64  (1 1 0)
65  (0 1 0)
66  )
67  (
68  (0 0 1)
69  (1 0 1)
70  (1 1 1)
71  (0 1 1)
72  )
73  );
74  normal (0 0 1);
75 
76  negateParcelsOppositeNormal no;
77  removeCollected no;
78  surfaceFormat vtk;
79  resetOnWrite no;
80  log yes;
81  }
82  \endverbatim
83 
84 SourceFiles
85  ParticleCollector.C
86 
87 \*---------------------------------------------------------------------------*/
88 
89 #ifndef ParticleCollector_H
90 #define ParticleCollector_H
91 
92 #include "CloudFunctionObject.H"
93 #include "cylindricalCS.H"
94 #include "face.H"
95 #include "Switch.H"
96 #include "OFstream.H"
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 namespace Foam
101 {
102 
103 /*---------------------------------------------------------------------------*\
104  Class ParticleCollector Declaration
105 \*---------------------------------------------------------------------------*/
106 
107 template<class CloudType>
108 class ParticleCollector
109 :
110  public CloudFunctionObject<CloudType>
111 {
112 public:
113 
114  enum modeType
115  {
119  };
120 
121 
122 private:
123 
124  // Private Data
125 
126  // Typedefs
127 
128  //- Convenience typedef for parcel type
129  typedef typename CloudType::parcelType parcelType;
130 
131  //- Collector mode type
132  modeType mode_;
133 
134  //- Index of parcel types to collect (-1 by default = all particles)
135  const label parcelType_;
136 
137  //- Flag to remove collected particles
138  Switch removeCollected_;
139 
140  //- List of points
141  Field<point> points_;
142 
143  //- List of faces
144  List<face> faces_;
145 
146 
147  // Concentric circles collector
148 
149  //- Number of sectors per circle
150  label nSector_;
151 
152  //- List of radii
153  List<scalar> radius_;
154 
155  //- Cylindrical co-ordinate system
157 
158 
159  //- Face areas
160  Field<scalar> area_;
161 
162  //- Polygon normal vector per face
163  Field<vector> normal_;
164 
165  //- Remove mass of parcel travelling in opposite direction to normal_
166  bool negateParcelsOppositeNormal_;
167 
168  //- Surface output format
169  const word surfaceFormat_;
170 
171  //- Flag to indicate whether data should be reset/cleared on writing
172  Switch resetOnWrite_;
173 
174  //- Total time
175  scalar totalTime_;
176 
177  //- Mass storage
178  List<scalar> mass_;
179 
180  //- Mass total storage
181  List<scalar> massTotal_;
182 
183  //- Mass flow rate storage
184  List<scalar> massFlowRate_;
185 
186  //- Flag to indicate whether data should be written to file
187  Switch log_;
188 
189  //- Output file pointer
190  autoPtr<OFstream> outputFilePtr_;
191 
192  //- Last calculation time
193  scalar timeOld_;
194 
195  //- Work list to store which faces are hit
196  mutable DynamicList<label> hitFaceIDs_;
197 
198 
199  // Private Member Functions
200 
201  //- Helper function to create log files
202  void makeLogFile
203  (
204  const faceList& faces,
205  const Field<point>& points,
206  const Field<scalar>& area
207  );
208 
209  //- Initialise polygon collectors
210  void initPolygons(const List<Field<point>>& polygons);
211 
212  //- Initialise concentric circle collectors
213  void initConcentricCircles();
214 
215  //- Collect parcels in polygon collectors
216  void collectParcelPolygon
217  (
218  const point& p1,
219  const point& p2
220  ) const;
221 
222  //- Collect parcels in concentric circle collectors
223  void collectParcelConcentricCircles
224  (
225  const point& p1,
226  const point& p2
227  ) const;
228 
229 
230 protected:
231 
232  // Protected Member Functions
233 
234  //- Write post-processing info
235  void write();
236 
237 
238 public:
239 
240  //- Runtime type information
241  TypeName("particleCollector");
242 
243 
244  // Constructors
245 
246  //- Construct from dictionary
248  (
249  const dictionary& dict,
250  CloudType& owner,
251  const word& modelName
252  );
253 
254  //- Construct copy
256 
257  //- Construct and return a clone
259  {
261  (
263  );
264  }
265 
266 
267  //- Destructor
268  virtual ~ParticleCollector();
269 
270 
271  // Member Functions
272 
273  // Access
274 
275  //- Return const access to the reset on write flag
276  inline const Switch& resetOnWrite() const;
277 
278 
279  // Evaluation
280 
281  //- Post-move hook
282  virtual void postMove
283  (
284  parcelType& p,
285  const scalar dt,
286  const point& position0,
287  bool& keepParticle
288  );
289 };
290 
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 } // End namespace Foam
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 #include "ParticleCollectorI.H"
299 
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 
302 #ifdef NoRepository
303  #include "ParticleCollector.C"
304 #endif
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 #endif
309 
310 // ************************************************************************* //
Templated cloud function object base class.
const CloudType & owner() const
Return const access to the owner cloud.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:79
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:221
Pre-declare SubField and related Field type.
Definition: Field.H:82
Function object to collect the parcel mass- and mass flow rate over a set of polygons....
virtual void postMove(parcelType &p, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
virtual ~ParticleCollector()
Destructor.
ParticleCollector(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
void write()
Write post-processing info.
const Switch & resetOnWrite() const
Return const access to the reset on write flag.
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
TypeName("particleCollector")
Runtime type information.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Cylindrical coordinate system.
Definition: cylindricalCS.H:53
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:104
A class for handling words, derived from string.
Definition: word.H:62
const pointField & points
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
volScalarField & p