1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 \*---------------------------------------------------------------------------*/
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 // Forward declaration of functions
50 template<class ParticleType>
53 template<class ParticleType>
56 template<class ParticleType>
60 const Cloud<ParticleType>&
64 /*---------------------------------------------------------------------------*\
65 Class Cloud Declaration
66 \*---------------------------------------------------------------------------*/
68 template<class ParticleType>
72 public IDLList<ParticleType>
76 const polyMesh& polyMesh_;
78 //- Overall count of particles ever created. Never decreases.
79 mutable label particleCount_;
81 //- Temporary storage for addressing. Used in findFaces.
82 mutable DynamicList<label> labels_;
85 // Private member functions
87 //- Initialise cloud on IO constructor
88 void initCloud(const bool checkClass);
93 template<class ParticleT>
94 friend class Particle;
95 template<class ParticleT>
96 friend class IOPosition;
98 typedef ParticleType particleType;
100 typedef typename IDLList<ParticleType>::iterator iterator;
101 typedef typename IDLList<ParticleType>::const_iterator const_iterator;
103 //-Runtime type information
109 //- Construct from mesh and a list of particles
112 const polyMesh& mesh,
113 const IDLList<ParticleType>& particles
116 //- Construct from mesh, cloud name, and a list of particles
119 const polyMesh& mesh,
120 const word& cloudName,
121 const IDLList<ParticleType>& particles
124 //- Construct from mesh by reading from file
125 // Optionally disable checking of class name for post-processing
128 const polyMesh& mesh,
129 const bool checkClass = true
133 //- Construct from mesh by reading from file with given cloud instance
134 // Optionally disable checking of class name for post-processing
137 const polyMesh& pMesh,
138 const word& cloudName,
139 const bool checkClass = true
147 //- Return the polyMesh reference
148 const polyMesh& pMesh() const
153 //- Is this global face an internal face?
154 bool internalFace(const label facei) const
156 return polyMesh_.isInternalFace(facei);
159 //- Is this global face a boundary face?
160 bool boundaryFace(const label facei) const
162 return !internalFace(facei);
165 //- Which patch is this global face on
166 label facePatch(const label facei) const
168 return polyMesh_.boundaryMesh().whichPatch(facei);
171 //- Which face of this patch is this global face
172 label patchFace(const label patchi, const label facei) const
174 return polyMesh_.boundaryMesh()[patchi].whichFace(facei);
179 return IDLList<ParticleType>::size();
185 const const_iterator begin() const
187 return IDLList<ParticleType>::begin();
190 const const_iterator cbegin() const
192 return IDLList<ParticleType>::cbegin();
195 const const_iterator end() const
197 return IDLList<ParticleType>::end();
200 const const_iterator cend() const
202 return IDLList<ParticleType>::cend();
207 return IDLList<ParticleType>::begin();
212 return IDLList<ParticleType>::end();
220 return IDLList<ParticleType>::clear();
223 //- Get unique particle creation id
224 label getNewParticleID() const;
226 //- Transfer particle to cloud
227 void addParticle(ParticleType* pPtr);
229 //- Remove particle from cloud and delete
230 void deleteParticle(ParticleType&);
232 //- Move the particles
233 // passing the TrackingData to the track function
234 template<class TrackingData>
235 void move(TrackingData& td);
237 //- Remap the cells of particles corresponding to the
238 // mesh topology change
239 virtual void autoMap(const mapPolyMesh&);
244 //- Helper to construct IOobject for field and current time.
245 IOobject fieldIOobject
247 const word& fieldName,
248 const IOobject::readOption r
251 //- Check lagrangian data field
252 template<class DataType>
253 void checkFieldIOobject
255 const Cloud<ParticleType>& c,
256 const IOField<DataType>& data
259 //- Read the field data for the cloud of particles. Dummy at
261 virtual void readFields();
266 //- Write the field data for the cloud of particles Dummy at
268 virtual void writeFields() const;
270 //- Write using given format, version and compression.
271 // Only writes the cloud file if the Cloud isn't empty
272 virtual bool writeObject
274 IOstream::streamFormat fmt,
275 IOstream::versionNumber ver,
276 IOstream::compressionType cmp
279 //- Write positions to <cloudName>_positions.obj file
280 void writePositions() const;
285 friend Ostream& operator<< <ParticleType>
288 const Cloud<ParticleType>&
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 } // End namespace Foam
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 // ************************************************************************* //