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-2018 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:
114  enum modeType
115  {
118  mtUnknown
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  // Polygon collector
148 
149  //- Triangulation of faces
150  List<List<face>> faceTris_;
151 
152  // Concentric circles collector
153 
154  //- Number of sectors per circle
155  label nSector_;
156 
157  //- List of radii
158  List<scalar> radius_;
159 
160  //- Cylindrical co-ordinate system
161  cylindricalCS coordSys_;
162 
163 
164  //- Face areas
165  Field<scalar> area_;
166 
167  //- Polygon normal vector per face
168  Field<vector> normal_;
169 
170  //- Remove mass of parcel travelling in opposite direction to normal_
171  bool negateParcelsOppositeNormal_;
172 
173  //- Surface output format
174  const word surfaceFormat_;
175 
176  //- Flag to indicate whether data should be reset/cleared on writing
177  Switch resetOnWrite_;
178 
179  //- Total time
180  scalar totalTime_;
181 
182  //- Mass storage
183  List<scalar> mass_;
184 
185  //- Mass total storage
186  List<scalar> massTotal_;
187 
188  //- Mass flow rate storage
189  List<scalar> massFlowRate_;
190 
191  //- Flag to indicate whether data should be written to file
192  Switch log_;
193 
194  //- Output file pointer
195  autoPtr<OFstream> outputFilePtr_;
196 
197  //- Last calculation time
198  scalar timeOld_;
199 
200  //- Work list to store which faces are hit
201  mutable DynamicList<label> hitFaceIDs_;
202 
203 
204  // Private Member Functions
205 
206  //- Helper function to create log files
207  void makeLogFile
208  (
209  const faceList& faces,
210  const Field<point>& points,
211  const Field<scalar>& area
212  );
213 
214  //- Initialise polygon collectors
215  void initPolygons(const List<Field<point>>& polygons);
216 
217  //- Initialise concentric circle collectors
218  void initConcentricCircles();
219 
220  //- Collect parcels in polygon collectors
221  void collectParcelPolygon
222  (
223  const point& p1,
224  const point& p2
225  ) const;
226 
227  //- Collect parcels in concentric circle collectors
228  void collectParcelConcentricCircles
229  (
230  const point& p1,
231  const point& p2
232  ) const;
233 
234 
235 protected:
236 
237  // Protected Member Functions
238 
239  //- Write post-processing info
240  void write();
241 
242 
243 public:
244 
245  //- Runtime type information
246  TypeName("particleCollector");
247 
248 
249  // Constructors
250 
251  //- Construct from dictionary
253  (
254  const dictionary& dict,
255  CloudType& owner,
256  const word& modelName
257  );
258 
259  //- Construct copy
261 
262  //- Construct and return a clone
264  {
266  (
268  );
269  }
270 
271 
272  //- Destructor
273  virtual ~ParticleCollector();
274 
275 
276  // Member Functions
277 
278  // Access
279 
280  //- Return const access to the reset on write flag
281  inline const Switch& resetOnWrite() const;
282 
283 
284  // Evaluation
285 
286  //- Post-move hook
287  virtual void postMove
288  (
289  parcelType& p,
290  const scalar dt,
291  const point& position0,
292  bool& keepParticle
293  );
294 };
295 
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 } // End namespace Foam
300 
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 
303 #include "ParticleCollectorI.H"
304 
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 
307 #ifdef NoRepository
308  #include "ParticleCollector.C"
309 #endif
310 
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 
313 #endif
314 
315 // ************************************************************************* //
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
ParticleCollector(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
void write()
Write post-processing info.
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:104
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
const CloudType & owner() const
Return const access to the owner cloud.
TypeName("particleCollector")
Runtime type information.
Cylindrical coordinate system.
Definition: cylindricalCS.H:48
const Switch & resetOnWrite() const
Return const access to the reset on write flag.
const pointField & points
Pre-declare SubField and related Field type.
Definition: Field.H:56
A class for handling words, derived from string.
Definition: word.H:59
virtual void postMove(parcelType &p, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:215
virtual ~ParticleCollector()
Destructor.
Function object to collect the parcel mass- and mass flow rate over a set of polygons. The polygons can either be specified by sets of user- supplied points, or in a concentric circles arrangement. If a parcel is &#39;collected&#39;, it can be flagged to be removed from the domain using the removeCollected entry.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
volScalarField & p
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:69
Templated cloud function object base class.
Namespace for OpenFOAM.