Cloud.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) 2011-2012 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::Cloud
26 
27 Description
28  Base cloud calls templated on particle type
29 
30 SourceFiles
31  Cloud.C
32  CloudIO.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef Cloud_H
37 #define Cloud_H
38 
39 #include "cloud.H"
40 #include "IDLList.H"
41 #include "IOField.H"
42 #include "CompactIOField.H"
43 #include "polyMesh.H"
44 #include "PackedBoolList.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of functions
52 template<class ParticleType>
53 class Cloud;
54 
55 template<class ParticleType>
56 class IOPosition;
57 
58 template<class ParticleType>
59 Ostream& operator<<
60 (
61  Ostream&,
62  const Cloud<ParticleType>&
63 );
64 
65 
66 /*---------------------------------------------------------------------------*\
67  Class Cloud Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 template<class ParticleType>
71 class Cloud
72 :
73  public cloud,
74  public IDLList<ParticleType>
75 {
76  // Private data
77 
78  const polyMesh& polyMesh_;
79 
80  //- Temporary storage for addressing. Used in findTris.
82 
83  //- Count of how many tracking rescue corrections have been
84  // applied
85  mutable label nTrackingRescues_;
86 
87  //- Does the cell have wall faces
89 
90 
91  // Private Member Functions
92 
93  //- Check patches
94  void checkPatches() const;
95 
96  //- Initialise cloud on IO constructor
97  void initCloud(const bool checkClass);
98 
99  //- Find all cells which have wall faces
100  void calcCellWallFaces() const;
101 
102  //- Read cloud properties dictionary
104 
105  //- Write cloud properties dictionary
106  void writeCloudUniformProperties() const;
107 
108 
109 public:
110 
111  friend class particle;
112  template<class ParticleT>
113  friend class IOPosition;
114 
115  typedef ParticleType particleType;
116 
119 
120  //-Runtime type information
121  TypeName("Cloud");
122 
123 
124  // Static data
125 
126  //- Name of cloud properties dictionary
127  static word cloudPropertiesName;
128 
129 
130  // Constructors
131 
132  //- Construct from mesh and a list of particles
133  Cloud
134  (
135  const polyMesh& mesh,
136  const IDLList<ParticleType>& particles
137  );
138 
139  //- Construct from mesh, cloud name, and a list of particles
140  Cloud
141  (
142  const polyMesh& mesh,
143  const word& cloudName,
144  const IDLList<ParticleType>& particles
145  );
146 
147  //- Construct from mesh by reading from file
148  // Optionally disable checking of class name for post-processing
149  Cloud
150  (
151  const polyMesh& mesh,
152  const bool checkClass = true
153  );
154 
155 
156  //- Construct from mesh by reading from file with given cloud instance
157  // Optionally disable checking of class name for post-processing
158  Cloud
159  (
160  const polyMesh& pMesh,
161  const word& cloudName,
162  const bool checkClass = true
163  );
164 
165 
166  // Member Functions
167 
168  // Access
169 
170  //- Return the polyMesh reference
171  const polyMesh& pMesh() const
172  {
173  return polyMesh_;
174  }
175 
176  label size() const
177  {
179  };
180 
182  {
183  return labels_;
184  }
185 
186  //- Return nTrackingRescues
187  label nTrackingRescues() const
188  {
189  return nTrackingRescues_;
190  }
191 
192  //- Increment the nTrackingRescues counter
193  void trackingRescue() const
194  {
196  if (cloud::debug && size() && (nTrackingRescues_ % size() == 0))
197  {
198  Pout<< " " << nTrackingRescues_
199  << " tracking rescues " << endl;
200  }
201  }
202 
203  //- Whether each cell has any wall faces (demand driven data)
204  const PackedBoolList& cellHasWallFaces() const;
205 
206  //- Switch to specify if particles of the cloud can return
207  // non-zero wall distance values. By default, assume
208  // that they can't (default for wallImpactDistance in
209  // particle is 0.0).
210  virtual bool hasWallImpactDistance() const
211  {
212  return false;
213  }
214 
215 
216  // Iterators
217 
218  const const_iterator begin() const
219  {
221  };
222 
223  const const_iterator cbegin() const
224  {
226  };
227 
228  const const_iterator end() const
229  {
231  };
232 
233  const const_iterator cend() const
234  {
236  };
237 
238  iterator begin()
239  {
241  };
242 
243  iterator end()
244  {
246  };
247 
248 
249  // Edit
250 
251  void clear()
252  {
254  };
255 
256  //- Transfer particle to cloud
257  void addParticle(ParticleType* pPtr);
258 
259  //- Remove particle from cloud and delete
260  void deleteParticle(ParticleType&);
261 
262  //- Reset the particles
263  void cloudReset(const Cloud<ParticleType>& c);
264 
265  //- Move the particles
266  // passing the TrackingData to the track function
267  template<class TrackData>
268  void move(TrackData& td, const scalar trackTime);
269 
270  //- Remap the cells of particles corresponding to the
271  // mesh topology change
272  template<class TrackData>
273  void autoMap(TrackData& td, const mapPolyMesh&);
274 
275 
276  // Read
277 
278  //- Helper to construct IOobject for field and current time.
280  (
281  const word& fieldName,
282  const IOobject::readOption r
283  ) const;
284 
285  //- Check lagrangian data field
286  template<class DataType>
287  void checkFieldIOobject
288  (
289  const Cloud<ParticleType>& c,
290  const IOField<DataType>& data
291  ) const;
292 
293  //- Check lagrangian data fieldfield
294  template<class DataType>
296  (
297  const Cloud<ParticleType>& c,
298  const CompactIOField<Field<DataType>, DataType>& data
299  ) const;
300 
301  //- Read the field data for the cloud of particles. Dummy at
302  // this level.
303  virtual void readFields();
304 
305 
306  // Write
307 
308  //- Write the field data for the cloud of particles Dummy at
309  // this level.
310  virtual void writeFields() const;
311 
312  //- Write using given format, version and compression.
313  // Only writes the cloud file if the Cloud isn't empty
314  virtual bool writeObject
315  (
319  ) const;
320 
321  //- Write positions to <cloudName>_positions.obj file
322  void writePositions() const;
323 
324 
325  // Ostream Operator
326 
327  friend Ostream& operator<< <ParticleType>
328  (
329  Ostream&,
330  const Cloud<ParticleType>&
331  );
332 };
333 
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 } // End namespace Foam
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 #ifdef NoRepository
342 # include "Cloud.C"
343 #endif
344 
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346 
347 #endif
348 
349 // ************************************************************************* //
Foam::Cloud::addParticle
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
Definition: Cloud.C:162
Foam::Cloud::calcCellWallFaces
void calcCellWallFaces() const
Find all cells which have wall faces.
Definition: Cloud.C:68
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::Cloud::initCloud
void initCloud(const bool checkClass)
Initialise cloud on IO constructor.
Definition: CloudIO.C:110
Foam::PackedBoolList
A bit-packed bool list.
Definition: PackedBoolList.H:63
Foam::Cloud::writeFields
virtual void writeFields() const
Write the field data for the cloud of particles Dummy at.
Definition: CloudIO.C:256
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition: IOField.H:50
Foam::Cloud::end
iterator end()
Definition: Cloud.H:242
Foam::Cloud::TypeName
TypeName("Cloud")
Runtime type information.
Foam::DynamicList< label >
Foam::Cloud::writePositions
void writePositions() const
Write positions to <cloudName>_positions.obj file.
Definition: Cloud.C:471
Foam::IOstream::compressionType
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
Foam::Cloud::checkFieldIOobject
void checkFieldIOobject(const Cloud< ParticleType > &c, const IOField< DataType > &data) const
Check lagrangian data field.
Definition: CloudIO.C:215
Foam::Cloud::cellWallFacesPtr_
autoPtr< PackedBoolList > cellWallFacesPtr_
Does the cell have wall faces.
Definition: Cloud.H:87
cloud.H
Foam::Cloud::iterator
IDLList< ParticleType >::iterator iterator
Definition: Cloud.H:116
Foam::Cloud::begin
iterator begin()
Definition: Cloud.H:237
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::CompactIOField
A Field of objects of type <T> with automated input and output using a compact storage....
Definition: CompactIOField.H:50
Foam::Cloud::clear
void clear()
Definition: Cloud.H:250
Foam::Cloud::trackingRescue
void trackingRescue() const
Increment the nTrackingRescues counter.
Definition: Cloud.H:192
Foam::Cloud::labels
DynamicList< label > & labels()
Definition: Cloud.H:180
polyMesh.H
Foam::Cloud::fieldIOobject
IOobject fieldIOobject(const word &fieldName, const IOobject::readOption r) const
Helper to construct IOobject for field and current time.
Definition: CloudIO.C:195
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::Cloud::labels_
DynamicList< label > labels_
Temporary storage for addressing. Used in findTris.
Definition: Cloud.H:80
Foam::IOstream::versionNumber
Version number type.
Definition: IOstream.H:96
Foam::Cloud::hasWallImpactDistance
virtual bool hasWallImpactDistance() const
Switch to specify if particles of the cloud can return.
Definition: Cloud.H:209
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::IDLList
Intrusive doubly-linked list.
Definition: IDLList.H:47
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Cloud::writeCloudUniformProperties
void writeCloudUniformProperties() const
Write cloud properties dictionary.
Definition: CloudIO.C:71
Foam::Cloud::begin
const const_iterator begin() const
Definition: Cloud.H:217
Foam::Cloud::deleteParticle
void deleteParticle(ParticleType &)
Remove particle from cloud and delete.
Definition: Cloud.C:169
PackedBoolList.H
Foam::Cloud::size
label size() const
Definition: Cloud.H:175
Foam::Cloud::cellHasWallFaces
const PackedBoolList & cellHasWallFaces() const
Whether each cell has any wall faces (demand driven data)
Definition: Cloud.C:149
Foam::Cloud::end
const const_iterator end() const
Definition: Cloud.H:227
Foam::Cloud::cloudPropertiesName
static word cloudPropertiesName
Name of cloud properties dictionary.
Definition: Cloud.H:126
Foam::Cloud::readFields
virtual void readFields()
Read the field data for the cloud of particles. Dummy at.
Definition: CloudIO.C:251
Foam::IOPosition
Helper IO class to read and write particle positions.
Definition: Cloud.H:55
Foam::ILList< DLListBase, T >::clear
void clear()
Clear the contents of the list.
Definition: ILList.C:112
Foam::Cloud::nTrackingRescues
label nTrackingRescues() const
Return nTrackingRescues.
Definition: Cloud.H:186
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::Cloud::particleType
ParticleType particleType
Definition: Cloud.H:114
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Cloud::cloudReset
void cloudReset(const Cloud< ParticleType > &c)
Reset the particles.
Definition: Cloud.C:176
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::cloud
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
Foam::Cloud::pMesh
const polyMesh & pMesh() const
Return the polyMesh reference.
Definition: Cloud.H:170
Foam::Cloud::const_iterator
IDLList< ParticleType >::const_iterator const_iterator
Definition: Cloud.H:117
Foam::Cloud::polyMesh_
const polyMesh & polyMesh_
Definition: Cloud.H:77
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
IOField.H
Foam::particle
Base particle class.
Definition: particle.H:78
Foam::Cloud
Base cloud calls templated on particle type.
Definition: Cloud.H:52
Foam::Cloud::Cloud
Cloud(const polyMesh &mesh, const IDLList< ParticleType > &particles)
Construct from mesh and a list of particles.
cloudName
const word cloudName(propsDict.lookup("cloudName"))
Foam::Cloud::autoMap
void autoMap(TrackData &td, const mapPolyMesh &)
Remap the cells of particles corresponding to the.
Definition: Cloud.C:398
Foam::Cloud::cbegin
const const_iterator cbegin() const
Definition: Cloud.H:222
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Cloud.C
Foam::IOobject::readOption
readOption
Enumeration defining the read options.
Definition: IOobject.H:106
Foam::Cloud::nTrackingRescues_
label nTrackingRescues_
Count of how many tracking rescue corrections have been.
Definition: Cloud.H:84
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::Cloud::writeObject
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write using given format, version and compression.
Definition: CloudIO.C:267
Foam::Cloud::readCloudUniformProperties
void readCloudUniformProperties()
Read cloud properties dictionary.
Definition: CloudIO.C:39
Foam::Cloud::checkPatches
void checkPatches() const
Check patches.
Definition: Cloud.C:39
CompactIOField.H
Foam::Cloud::cend
const const_iterator cend() const
Definition: Cloud.H:232
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:52
IDLList.H
Foam::Cloud::move
void move(TrackData &td, const scalar trackTime)
Move the particles.
Definition: Cloud.C:187
Foam::Cloud::checkFieldFieldIOobject
void checkFieldFieldIOobject(const Cloud< ParticleType > &c, const CompactIOField< Field< DataType >, DataType > &data) const
Check lagrangian data fieldfield.
Definition: CloudIO.C:234
Foam::IOstream::streamFormat
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86