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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::ParticleCollector
29 
30 Group
31  grpLagrangianIntermediateFunctionObjects
32 
33 Description
34  Function object to collect the parcel mass- and mass flow rate over a
35  set of polygons. The polygons can either be specified by sets of user-
36  supplied points, or in a concentric circles arrangement. If a
37  parcel is 'collected', it can be flagged to be removed from the
38  domain using the removeCollected entry.
39 
40  Example usage:
41  \verbatim
42  particleCollector1
43  {
44  type particleCollector;
45 
46  mode concentricCircle;
47  origin (0.05 0.025 0.005);
48  radius (0.01 0.025 0.05);
49  nSector 10;
50  refDir (1 0 0);
51  normal (0 0 1);
52 
53  negateParcelsOppositeNormal no;
54  removeCollected no;
55  surfaceFormat vtk;
56  resetOnWrite no;
57  log yes;
58  }
59 
60  particleCollector2
61  {
62  type particleCollector;
63 
64  mode polygon;
65  polygons
66  (
67  (
68  (0 0 0)
69  (1 0 0)
70  (1 1 0)
71  (0 1 0)
72  )
73  (
74  (0 0 1)
75  (1 0 1)
76  (1 1 1)
77  (0 1 1)
78  )
79  );
80  normal (0 0 1);
81 
82  negateParcelsOppositeNormal no;
83  removeCollected no;
84  surfaceFormat vtk;
85  resetOnWrite no;
86  log yes;
87  }
88  \endverbatim
89 
90 SourceFiles
91  ParticleCollector.C
92 
93 \*---------------------------------------------------------------------------*/
94 
95 #ifndef ParticleCollector_H
96 #define ParticleCollector_H
97 
98 #include "CloudFunctionObject.H"
99 #include "cylindricalCS.H"
100 #include "face.H"
101 #include "OFstream.H"
102 
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 
105 namespace Foam
106 {
107 
108 /*---------------------------------------------------------------------------*\
109  Class ParticleCollector Declaration
110 \*---------------------------------------------------------------------------*/
111 
112 template<class CloudType>
113 class ParticleCollector
114 :
115  public CloudFunctionObject<CloudType>
116 {
117 public:
118 
119  enum modeType
120  {
123  mtUnknown
124  };
125 
126 
127 private:
128 
129  //- Convenience typedef for parcel type
130  typedef typename CloudType::parcelType parcelType;
131 
132  // Private Data
133 
134  //- Collector mode type
135  modeType mode_;
136 
137  //- Index of parcel types to collect (-1 by default = all particles)
138  const label parcelType_;
139 
140  //- Flag to remove collected particles
141  bool removeCollected_;
142 
143  //- Should data be reset/cleared on writing?
144  bool resetOnWrite_;
145 
146  //- Flag to indicate whether data should be written to file
147  bool log_;
148 
149  //- List of points
150  Field<point> points_;
151 
152  //- List of faces
153  List<face> faces_;
154 
155 
156  // Polygon collector
157 
158  //- Triangulation of faces
159  List<List<face>> faceTris_;
160 
161  // Concentric circles collector
162 
163  //- Number of sectors per circle
164  label nSector_;
165 
166  //- List of radii
167  List<scalar> radius_;
168 
169  //- Cylindrical coordinate system
170  coordSystem::cylindrical coordSys_;
171 
172 
173  //- Face areas
174  Field<scalar> area_;
175 
176  //- Polygon normal vector per face
177  Field<vector> normal_;
178 
179  //- Remove mass of parcel travelling in opposite direction to normal_
180  bool negateParcelsOppositeNormal_;
181 
182  //- Surface output format
183  const word surfaceFormat_;
184 
185  //- Total time
186  scalar totalTime_;
187 
188  //- Mass storage
189  List<scalar> mass_;
190 
191  //- Mass total storage
192  List<scalar> massTotal_;
193 
194  //- Mass flow rate storage
195  List<scalar> massFlowRate_;
196 
197  //- Output file pointer
198  autoPtr<OFstream> outputFilePtr_;
199 
200  //- Last calculation time
201  scalar timeOld_;
202 
203  //- Work list to store which faces are hit
204  mutable DynamicList<label> hitFaceIDs_;
205 
206 
207  // Private Member Functions
208 
209  //- Helper function to create log files
210  void makeLogFile
211  (
212  const faceList& faces,
213  const Field<point>& points,
214  const Field<scalar>& area
215  );
216 
217  //- Initialise polygon collectors
218  void initPolygons(const List<Field<point>>& polygons);
219 
220  //- Initialise concentric circle collectors
221  void initConcentricCircles();
222 
223  //- Collect parcels in polygon collectors
224  void collectParcelPolygon
225  (
226  const point& p1,
227  const point& p2
228  ) const;
229 
230  //- Collect parcels in concentric circle collectors
231  void collectParcelConcentricCircles
232  (
233  const point& p1,
234  const point& p2
235  ) const;
236 
237 
238 protected:
239 
240  // Protected Member Functions
241 
242  //- Write post-processing info
243  void write();
244 
245 
246 public:
247 
248  //- Runtime type information
249  TypeName("particleCollector");
250 
251 
252  // Constructors
253 
254  //- Construct from dictionary
256  (
257  const dictionary& dict,
258  CloudType& owner,
259  const word& modelName
260  );
261 
262  //- Construct copy
264 
265  //- Construct and return a clone
267  {
269  (
271  );
272  }
273 
274 
275  //- Destructor
276  virtual ~ParticleCollector() = default;
277 
278 
279  // Member Functions
280 
281  //- Should data be reset on write?
282  inline bool resetOnWrite() const;
283 
284  //- Post-move hook
285  virtual void postMove
286  (
287  parcelType& p,
288  const scalar dt,
289  const point& position0,
290  bool& keepParticle
291  );
292 };
293 
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 } // End namespace Foam
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 #include "ParticleCollectorI.H"
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #ifdef NoRepository
306  #include "ParticleCollector.C"
307 #endif
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 #endif
312 
313 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::ParticleCollector::ParticleCollector
ParticleCollector(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: ParticleCollector.C:516
Foam::DynamicList< label >
Foam::ParticleCollector::write
void write()
Write post-processing info.
Definition: ParticleCollector.C:403
ParticleCollector.C
face.H
Foam::ParticleCollector::mtPolygon
Definition: ParticleCollector.H:120
Foam::ParticleCollector::mtUnknown
Definition: ParticleCollector.H:122
Foam::subModelBase::modelName
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:107
CloudFunctionObject.H
OFstream.H
Foam::ParticleCollector::TypeName
TypeName("particleCollector")
Runtime type information.
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::subModelBase::dict
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:113
Foam::ParticleCollector::postMove
virtual void postMove(parcelType &p, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
Definition: ParticleCollector.C:637
Foam::CloudSubModelBase::owner
const CloudType & owner() const
Return const access to the owner cloud.
Definition: CloudSubModelBase.C:106
cylindricalCS.H
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::coordSystem::cylindrical
A cylindrical coordinate system (r-theta-z). The coordinate system angle theta is always in radians.
Definition: cylindricalCS.H:71
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
ParticleCollectorI.H
Foam::ParticleCollector::mtConcentricCircle
Definition: ParticleCollector.H:121
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::Vector< scalar >
Foam::List< face >
Foam::CloudFunctionObject
Templated cloud function object base class.
Definition: CloudFunctionObject.H:62
Foam::ParticleCollector::resetOnWrite
bool resetOnWrite() const
Should data be reset on write?
Definition: ParticleCollectorI.H:30
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::ParticleCollector::~ParticleCollector
virtual ~ParticleCollector()=default
Destructor.
Foam::fieldTypes::area
const wordList area
Standard area field types (scalar, vector, tensor, etc)
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:220
Foam::ParticleCollector
Function object to collect the parcel mass- and mass flow rate over a set of polygons....
Definition: ParticleCollector.H:112
Foam::ParticleCollector::modeType
modeType
Definition: ParticleCollector.H:118
Foam::ParticleCollector::clone
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
Definition: ParticleCollector.H:265