1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 \*---------------------------------------------------------------------------*/
40 #include "pointMesh.H"
44 #include "polyMeshInfo.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 template<class ParticleType>
54 template<class ParticleType>
58 const Cloud<ParticleType>&
62 /*---------------------------------------------------------------------------*\
63 Class Cloud Declaration
64 \*---------------------------------------------------------------------------*/
66 template<class ParticleType>
70 public IDLList<ParticleType>
75 const polyMesh& polyMesh_;
76 const faceList& allFaces_;
77 const vectorField& points_;
78 const cellList& cellFaces_;
79 const vectorField& allFaceCentres_;
80 const unallocLabelList& owner_;
81 const unallocLabelList& neighbour_;
83 //- Mesh information object
84 const polyMeshInfo meshInfo_;
87 // Private member functions
89 //- Initialise cloud on IO constructor
90 void initCloud(const bool checkClass);
95 template<class ParticleT>
96 friend class Particle;
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);
177 //- Return reference to the mesh information object
178 const polyMeshInfo& meshInfo() const
185 return IDLList<ParticleType>::size();
188 const const_iterator begin() const
190 return IDLList<ParticleType>::begin();
193 const const_iterator end() const
195 return IDLList<ParticleType>::end();
200 return IDLList<ParticleType>::begin();
205 return IDLList<ParticleType>::end();
210 return IDLList<ParticleType>::clear();
216 //- Transfer particle to cloud
217 void addParticle(ParticleType* pPtr);
219 //- Remove particle from cloud and delete
220 void deleteParticle(ParticleType&);
222 //- Move the particles
223 // passing the TrackingData to the track function
224 template<class TrackingData>
225 void move(TrackingData& td);
227 //- Remap the cells of particles corresponding to the
228 // mesh topology change
229 virtual void autoMap(const mapPolyMesh&);
234 //- Read and return a lagrangian data field
235 // Checks that data is valid
236 template<class DataType>
237 void checkFieldIOobject
239 const Cloud<ParticleType>& c,
240 const IOField<DataType>& data
243 //- Read and return a lagrangian data field
244 IOobject fieldIOobject(const word& fieldName) const;
246 //- Read and return a lagrangian data field
248 tmp<IOField<Type> > readField(const word& fieldName) const;
250 //- Read the field data for the cloud of particles
256 //- Write the field data for the cloud of particles
257 virtual void writeFields() const;
259 //- Write using given format, version and compression.
260 // Only writes the cloud file if the Cloud isn't empty
261 virtual bool writeObject
263 IOstream::streamFormat fmt,
264 IOstream::versionNumber ver,
265 IOstream::compressionType cmp
271 friend Ostream& operator<< <ParticleType>
274 const Cloud<ParticleType>&
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 } // End namespace Foam
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 // ************************************************************************* //