ParticleCollector.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2012-2014 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  {
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
139 
140  //- List of points
142 
143  //- List of faces
145 
146 
147  // Polygon collector
148 
149  //- Triangulation of faces
151 
152  // Concentric circles collector
153 
154  //- Number of sectors per circle
155  label nSector_;
156 
157  //- List of radii
159 
160  //- Cylindrical co-ordinate system
162 
163 
164  //- Face areas
166 
167  //- Polygon normal vector per face
169 
170  //- Remove mass of parcel travelling in opposite direction to normal_
172 
173  //- Surface output format
174  const word surfaceFormat_;
175 
176  //- Flag to indicate whether data should be reset/cleared on writing
178 
179  //- Total time
180  scalar totalTime_;
181 
182  //- Mass storage
184 
185  //- Mass total storage
187 
188  //- Mass flow rate storage
190 
191  //- Flag to indicate whether data should be written to file
192  Switch log_;
193 
194  //- Output file pointer
196 
197  //- Last calculation time
198  scalar timeOld_;
199 
200  //- Work list to store which faces are hit
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
222  (
223  const point& p1,
224  const point& p2
225  ) const;
226 
227  //- Collect parcels in concentric circle collectors
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 label cellI,
291  const scalar dt,
292  const point& position0,
293  bool& keepParticle
294  );
295 };
296 
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 } // End namespace Foam
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 #include "ParticleCollectorI.H"
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 #ifdef NoRepository
309 # include "ParticleCollector.C"
310 #endif
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 #endif
315 
316 // ************************************************************************* //
Foam::ParticleCollector::totalTime_
scalar totalTime_
Total time.
Definition: ParticleCollector.H:179
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::ParticleCollector::parcelType_
const label parcelType_
Index of parcel types to collect (-1 by default = all particles)
Definition: ParticleCollector.H:134
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::ParticleCollector::~ParticleCollector
virtual ~ParticleCollector()
Destructor.
Definition: ParticleCollector.C:639
Foam::ParticleCollector::ParticleCollector
ParticleCollector(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: ParticleCollector.C:519
Foam::DynamicList< label >
Foam::ParticleCollector::write
void write()
Write post-processing info.
Definition: ParticleCollector.C:389
Foam::ParticleCollector::radius_
List< scalar > radius_
List of radii.
Definition: ParticleCollector.H:157
ParticleCollector.C
face.H
Foam::ParticleCollector::parcelType
CloudType::parcelType parcelType
Convenience typedef for parcel type.
Definition: ParticleCollector.H:128
Foam::cylindricalCS
Cylindrical coordinate system.
Definition: cylindricalCS.H:48
Foam::CloudSubModelBase::owner
const CloudType & owner() const
Return const access to the owner cloud.
Definition: CloudSubModelBase.C:103
Foam::ParticleCollector::initConcentricCircles
void initConcentricCircles()
Initialise concentric circle collectors.
Definition: ParticleCollector.C:154
Foam::ParticleCollector::mtPolygon
@ mtPolygon
Definition: ParticleCollector.H:115
Foam::ParticleCollector::mtUnknown
@ mtUnknown
Definition: ParticleCollector.H:117
Foam::ParticleCollector::area_
Field< scalar > area_
Face areas.
Definition: ParticleCollector.H:164
Foam::subModelBase::modelName
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:104
CloudFunctionObject.H
Foam::ParticleCollector::resetOnWrite
const Switch & resetOnWrite() const
Return const access to the reset on write flag.
Definition: ParticleCollectorI.H:28
OFstream.H
Foam::ParticleCollector::massFlowRate_
List< scalar > massFlowRate_
Mass flow rate storage.
Definition: ParticleCollector.H:188
Foam::ParticleCollector::nSector_
label nSector_
Number of sectors per circle.
Definition: ParticleCollector.H:154
Foam::ParticleCollector::TypeName
TypeName("particleCollector")
Runtime type information.
Foam::ParticleCollector::surfaceFormat_
const word surfaceFormat_
Surface output format.
Definition: ParticleCollector.H:173
Foam::label
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
Foam::ParticleCollector::makeLogFile
void makeLogFile(const faceList &faces, const Field< point > &points, const Field< scalar > &area)
Helper function to create log files.
Definition: ParticleCollector.C:38
Foam::Field< point >
Foam::subModelBase::dict
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
Foam::ParticleCollector::coordSys_
cylindricalCS coordSys_
Cylindrical co-ordinate system.
Definition: ParticleCollector.H:160
Foam::ParticleCollector::log_
Switch log_
Flag to indicate whether data should be written to file.
Definition: ParticleCollector.H:191
Switch.H
cylindricalCS.H
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
Foam::ParticleCollector::hitFaceIDs_
DynamicList< label > hitFaceIDs_
Work list to store which faces are hit.
Definition: ParticleCollector.H:200
Foam::ParticleCollector::negateParcelsOppositeNormal_
bool negateParcelsOppositeNormal_
Remove mass of parcel travelling in opposite direction to normal_.
Definition: ParticleCollector.H:170
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::ParticleCollector::massTotal_
List< scalar > massTotal_
Mass total storage.
Definition: ParticleCollector.H:185
Foam::ParticleCollector::resetOnWrite_
Switch resetOnWrite_
Flag to indicate whether data should be reset/cleared on writing.
Definition: ParticleCollector.H:176
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
ParticleCollectorI.H
Foam::ParticleCollector::mtConcentricCircle
@ mtConcentricCircle
Definition: ParticleCollector.H:116
Foam::ParticleCollector::outputFilePtr_
autoPtr< OFstream > outputFilePtr_
Output file pointer.
Definition: ParticleCollector.H:194
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::ParticleCollector::mode_
modeType mode_
Collector mode type.
Definition: ParticleCollector.H:131
Foam::Vector< scalar >
Foam::List< face >
Foam::ParticleCollector::points_
Field< point > points_
List of points.
Definition: ParticleCollector.H:140
Foam::CloudFunctionObject
Templated cloud function object base class.
Definition: CloudFunctionObject.H:56
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::ParticleCollector::initPolygons
void initPolygons(const List< Field< point > > &polygons)
Initialise polygon collectors.
Definition: ParticleCollector.C:110
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:217
Foam::ParticleCollector
Function object to collect the parcel mass- and mass flow rate over a set of polygons....
Definition: ParticleCollector.H:107
Foam::ParticleCollector::collectParcelPolygon
void collectParcelPolygon(const point &p1, const point &p2) const
Collect parcels in polygon collectors.
Definition: ParticleCollector.C:288
Foam::ParticleCollector::postMove
virtual void postMove(parcelType &p, const label cellI, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
Definition: ParticleCollector.C:647
Foam::ParticleCollector::faceTris_
List< List< face > > faceTris_
Triangulation of faces.
Definition: ParticleCollector.H:149
Foam::ParticleCollector::modeType
modeType
Definition: ParticleCollector.H:113
Foam::ParticleCollector::timeOld_
scalar timeOld_
Last calculation time.
Definition: ParticleCollector.H:197
Foam::ParticleCollector::mass_
List< scalar > mass_
Mass storage.
Definition: ParticleCollector.H:182
Foam::ParticleCollector::collectParcelConcentricCircles
void collectParcelConcentricCircles(const point &p1, const point &p2) const
Collect parcels in concentric circle collectors.
Definition: ParticleCollector.C:338
Foam::ParticleCollector::normal_
Field< vector > normal_
Polygon normal vector per face.
Definition: ParticleCollector.H:167
Foam::ParticleCollector::removeCollected_
Switch removeCollected_
Flag to remove collected particles.
Definition: ParticleCollector.H:137
Foam::ParticleCollector::faces_
List< face > faces_
List of faces.
Definition: ParticleCollector.H:143
Foam::ParticleCollector::clone
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
Definition: ParticleCollector.H:262