All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Cloud.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) 2011-2019 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  //- Reference to the mesh
79  const polyMesh& polyMesh_;
80 
81  //- Temporary storage for the global particle positions
82  mutable autoPtr<vectorField> globalPositionsPtr_;
83 
84 
85  // Private Member Functions
86 
87  //- Check patches
88  void checkPatches() const;
89 
90  //- Initialise cloud on IO constructor
91  void initCloud(const bool checkClass);
92 
93  //- Read cloud properties dictionary
94  void readCloudUniformProperties();
95 
96  //- Write cloud properties dictionary
97  void writeCloudUniformProperties() const;
98 
99 
100 public:
102  friend class particle;
103  template<class ParticleT>
104  friend class IOPosition;
106  typedef ParticleType particleType;
110 
111  //-Runtime type information
112  TypeName("Cloud");
113 
114 
115  // Static data
116 
117  //- Name of cloud properties dictionary
118  static word cloudPropertiesName;
119 
120 
121  // Constructors
122 
123  //- Construct from mesh and a list of particles
124  Cloud
125  (
126  const polyMesh& mesh,
127  const word& cloudName,
128  const IDLList<ParticleType>& particles
129  );
130 
131  //- Construct from mesh by reading from file with given cloud instance
132  // Optionally disable checking of class name for post-processing
133  Cloud
134  (
135  const polyMesh& pMesh,
136  const word& cloudName,
137  const bool checkClass = true
138  );
139 
140 
141  // Member Functions
142 
143  // Access
144 
145  //- Return the polyMesh reference
146  const polyMesh& pMesh() const
147  {
148  return polyMesh_;
149  }
150 
151  //- Return the number of particles in the cloud
152  label size() const
153  {
155  };
156 
157 
158  // Iterators
160  const const_iterator begin() const
161  {
163  };
165  const const_iterator cbegin() const
166  {
168  };
170  const const_iterator end() const
171  {
173  };
175  const const_iterator cend() const
176  {
178  };
180  iterator begin()
181  {
183  };
185  iterator end()
186  {
188  };
189 
190 
191  // Edit
193  void clear()
194  {
196  };
197 
198  //- Transfer particle to cloud
199  void addParticle(ParticleType* pPtr);
200 
201  //- Remove particle from cloud and delete
202  void deleteParticle(ParticleType&);
203 
204  //- Remove lost particles from cloud and delete
205  void deleteLostParticles();
206 
207  //- Reset the particles
208  void cloudReset(const Cloud<ParticleType>& c);
209 
210  //- Move the particles
211  template<class TrackCloudType>
212  void move
213  (
214  TrackCloudType& cloud,
215  typename ParticleType::trackingData& td,
216  const scalar trackTime
217  );
218 
219  //- Remap the cells of particles corresponding to the
220  // mesh topology change
221  void autoMap(const mapPolyMesh&);
222 
223 
224  // Read
225 
226  //- Helper to construct IOobject for field and current time.
228  (
229  const word& fieldName,
230  const IOobject::readOption r
231  ) const;
232 
233  //- Check lagrangian data field
234  template<class DataType>
235  void checkFieldIOobject
236  (
237  const Cloud<ParticleType>& c,
238  const IOField<DataType>& data
239  ) const;
240 
241  //- Check lagrangian data fieldfield
242  template<class DataType>
244  (
245  const Cloud<ParticleType>& c,
246  const CompactIOField<Field<DataType>, DataType>& data
247  ) const;
248 
249 
250  // Write
251 
252  //- Write the field data for the cloud of particles Dummy at
253  // this level.
254  virtual void writeFields() const;
255 
256  //- Write using given format, version and compression.
257  // Only writes the cloud file if the Cloud isn't empty
258  virtual bool writeObject
259  (
263  const bool write = true
264  ) const;
265 
266  //- Write positions to <cloudName>_positions.obj file
267  void writePositions() const;
268 
269  //- Call this before a topology change. Stores the particles global
270  // positions in the database for use during mapping.
271  void storeGlobalPositions() const;
272 
273 
274  // Ostream Operator
275 
276  friend Ostream& operator<< <ParticleType>
277  (
278  Ostream&,
279  const Cloud<ParticleType>&
280  );
281 };
282 
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 } // End namespace Foam
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 #ifdef NoRepository
291  #include "Cloud.C"
292 #endif
293 
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 
296 #endif
297 
298 // ************************************************************************* //
ParticleType particleType
Definition: Cloud.H:105
Template class for intrusive linked lists.
Definition: ILList.H:50
const const_iterator & cend() const
Definition: UILList.H:280
void cloudReset(const Cloud< ParticleType > &c)
Reset the particles.
Definition: Cloud.C:130
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
void deleteParticle(ParticleType &)
Remove particle from cloud and delete.
Definition: Cloud.C:104
void checkFieldFieldIOobject(const Cloud< ParticleType > &c, const CompactIOField< Field< DataType >, DataType > &data) const
Check lagrangian data fieldfield.
Definition: CloudIO.C:206
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp, const bool write=true) const
Write using given format, version and compression.
Definition: CloudIO.C:231
Cloud(const polyMesh &mesh, const word &cloudName, const IDLList< ParticleType > &particles)
Construct from mesh and a list of particles.
Definition: Cloud.C:68
label size() const
Return the number of particles in the cloud.
Definition: Cloud.H:151
const dimensionedScalar & c
Speed of light in a vacuum.
readOption
Enumeration defining the read options.
Definition: IOobject.H:110
const const_iterator end() const
Definition: Cloud.H:169
void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
Definition: Cloud.C:341
An STL-conforming const_iterator.
Definition: UILList.H:234
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
static word cloudPropertiesName
Name of cloud properties dictionary.
Definition: Cloud.H:117
Base particle class.
Definition: particle.H:84
const const_iterator cbegin() const
Definition: Cloud.H:164
IDLList< ParticleType >::iterator iterator
Definition: Cloud.H:107
const_iterator cbegin() const
Definition: UILList.H:275
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
Definition: Cloud.C:97
dynamicFvMesh & mesh
Pre-declare SubField and related Field type.
Definition: Field.H:56
void storeGlobalPositions() const
Call this before a topology change. Stores the particles global.
Definition: Cloud.C:388
Intrusive doubly-linked list.
A class for handling words, derived from string.
Definition: word.H:59
void clear()
Clear the contents of the list.
Definition: ILList.C:121
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
An STL-conforming iterator.
Definition: UILList.H:185
const const_iterator cend() const
Definition: Cloud.H:174
const iterator & end()
Definition: UILList.H:223
Base cloud calls templated on particle type.
Definition: Cloud.H:52
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void clear()
Definition: Cloud.H:192
Database for solution and other reduced data.
Definition: data.H:51
const const_iterator begin() const
Definition: Cloud.H:159
void deleteLostParticles()
Remove lost particles from cloud and delete.
Definition: Cloud.C:111
virtual void writeFields() const
Write the field data for the cloud of particles Dummy at.
Definition: CloudIO.C:223
IDLList< ParticleType >::const_iterator const_iterator
Definition: Cloud.H:108
TypeName("Cloud")
Runtime type information.
void move(TrackCloudType &cloud, typename ParticleType::trackingData &td, const scalar trackTime)
Move the particles.
Definition: Cloud.C:142
A Field of objects of type <T> with automated input and output using a compact storage. Behaves like IOField except when binary output in case it writes a CompactListList.
Version number type.
Definition: IOstream.H:96
void checkFieldIOobject(const Cloud< ParticleType > &c, const IOField< DataType > &data) const
Check lagrangian data field.
Definition: CloudIO.C:187
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const word cloudName(propsDict.lookup("cloudName"))
virtual bool write(const bool write=true) const
Write using setting from DB.
Helper IO class to read and write particle positions.
Definition: Cloud.H:55
iterator begin()
Definition: UILList.H:218
const polyMesh & pMesh() const
Return the polyMesh reference.
Definition: Cloud.H:145
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
IOobject fieldIOobject(const word &fieldName, const IOobject::readOption r) const
Helper to construct IOobject for field and current time.
Definition: CloudIO.C:167
A primitive field of type <T> with automated input and output.
Definition: IOField.H:50
void writePositions() const
Write positions to <cloudName>_positions.obj file.
Definition: Cloud.C:369
Namespace for OpenFOAM.