1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
33 \*---------------------------------------------------------------------------*/
35 #ifndef CloudTemplate_H
36 #define CloudTemplate_H
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 // Forward declaration of functions
49 template<class ParticleType>
52 template<class ParticleType>
55 template<class ParticleType>
59 const Cloud<ParticleType>&
63 /*---------------------------------------------------------------------------*\
64 Class Cloud Declaration
65 \*---------------------------------------------------------------------------*/
67 template<class ParticleType>
71 public IDLList<ParticleType>
75 const polyMesh& polyMesh_;
77 //- Overall count of particles ever created. Never decreases.
78 mutable label particleCount_;
80 //- Temporary storage for addressing. Used in findFaces.
81 mutable dynamicLabelList labels_;
84 // Private member functions
86 //- Initialise cloud on IO constructor
87 void initCloud(const bool checkClass);
89 //- Read cloud properties dictionary
90 void readCloudUniformProperties();
92 //- Write cloud properties dictionary
93 void writeCloudUniformProperties() const;
98 template<class ParticleT>
99 friend class Particle;
100 template<class ParticleT>
101 friend class IOPosition;
103 typedef ParticleType particleType;
105 typedef typename IDLList<ParticleType>::iterator iterator;
106 typedef typename IDLList<ParticleType>::const_iterator const_iterator;
108 //-Runtime type information
114 //- Name of cloud properties dictionary
115 static word cloudPropertiesName;
120 //- Construct from mesh and a list of particles
123 const polyMesh& mesh,
124 const IDLList<ParticleType>& particles
127 //- Construct from mesh, cloud name, and a list of particles
130 const polyMesh& mesh,
131 const word& cloudName,
132 const IDLList<ParticleType>& particles
135 //- Construct from mesh by reading from file
136 // Optionally disable checking of class name for post-processing
139 const polyMesh& mesh,
140 const bool checkClass = true
144 //- Construct from mesh by reading from file with given cloud instance
145 // Optionally disable checking of class name for post-processing
148 const polyMesh& pMesh,
149 const word& cloudName,
150 const bool checkClass = true
158 //- Return the polyMesh reference
159 const polyMesh& pMesh() const
164 //- Is this global face an internal face?
165 bool internalFace(const label facei) const
167 return polyMesh_.isInternalFace(facei);
170 //- Is this global face a boundary face?
171 bool boundaryFace(const label facei) const
173 return !internalFace(facei);
176 //- Which patch is this global face on
177 label facePatch(const label facei) const
179 return polyMesh_.boundaryMesh().whichPatch(facei);
182 //- Which face of this patch is this global face
183 label patchFace(const label patchi, const label facei) const
185 return polyMesh_.boundaryMesh()[patchi].whichFace(facei);
190 return IDLList<ParticleType>::size();
196 const const_iterator begin() const
198 return IDLList<ParticleType>::begin();
201 const const_iterator cbegin() const
203 return IDLList<ParticleType>::cbegin();
206 const const_iterator end() const
208 return IDLList<ParticleType>::end();
211 const const_iterator cend() const
213 return IDLList<ParticleType>::cend();
218 return IDLList<ParticleType>::begin();
223 return IDLList<ParticleType>::end();
231 return IDLList<ParticleType>::clear();
234 //- Get unique particle creation id
235 label getNewParticleID() const;
237 //- Transfer particle to cloud
238 void addParticle(ParticleType* pPtr);
240 //- Remove particle from cloud and delete
241 void deleteParticle(ParticleType&);
243 //- Move the particles
244 // passing the TrackingData to the track function
245 template<class TrackingData>
246 void move(TrackingData& td);
248 //- Remap the cells of particles corresponding to the
249 // mesh topology change
250 virtual void autoMap(const mapPolyMesh&);
255 //- Helper to construct IOobject for field and current time.
256 IOobject fieldIOobject
258 const word& fieldName,
259 const IOobject::readOption r
262 //- Check lagrangian data field
263 template<class DataType>
264 void checkFieldIOobject
266 const Cloud<ParticleType>& c,
267 const IOField<DataType>& data
270 //- Read the field data for the cloud of particles. Dummy at
272 virtual void readFields();
277 //- Write the field data for the cloud of particles Dummy at
279 virtual void writeFields() const;
281 //- Write using given format, version and compression.
282 // Only writes the cloud file if the Cloud isn't empty
283 virtual bool writeObject
285 IOstream::streamFormat fmt,
286 IOstream::versionNumber ver,
287 IOstream::compressionType cmp
290 //- Write positions to <cloudName>_positions.obj file
291 void writePositions() const;
296 friend Ostream& operator<< <ParticleType>
299 const Cloud<ParticleType>&
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 } // End namespace Foam
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 # include "CloudTemplate.C"
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 // ************************************************************************* //