1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 Base cloud calls templated on particle type
34 \*---------------------------------------------------------------------------*/
42 #include "CompactIOField.H"
44 #include "indexedOctree.H"
45 #include "treeDataCell.H"
46 #include "tetPointRef.H"
47 #include "PackedBoolList.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 // Forward declaration of functions
55 template<class ParticleType>
58 template<class ParticleType>
61 template<class ParticleType>
65 const Cloud<ParticleType>&
69 /*---------------------------------------------------------------------------*\
70 Class Cloud Declaration
71 \*---------------------------------------------------------------------------*/
73 template<class ParticleType>
77 public IDLList<ParticleType>
81 const polyMesh& polyMesh_;
83 //- Temporary storage for addressing. Used in findTris.
84 mutable DynamicList<label> labels_;
86 //- Count of how many tracking rescue corrections have been
88 mutable label nTrackingRescues_;
90 //- Does the cell have wall faces
91 mutable autoPtr<PackedBoolList> cellWallFacesPtr_;
94 // Private Member Functions
96 //- Initialise cloud on IO constructor
97 void initCloud(const bool checkClass);
99 //- Find all cells which have wall faces
100 void calcCellWallFaces() const;
102 //- Read cloud properties dictionary
103 void readCloudUniformProperties();
105 //- Write cloud properties dictionary
106 void writeCloudUniformProperties() const;
111 friend class particle;
112 template<class ParticleT>
113 friend class IOPosition;
115 typedef ParticleType particleType;
117 typedef typename IDLList<ParticleType>::iterator iterator;
118 typedef typename IDLList<ParticleType>::const_iterator const_iterator;
120 //-Runtime type information
126 //- Name of cloud properties dictionary
127 static word cloudPropertiesName;
132 //- Construct from mesh and a list of particles
135 const polyMesh& mesh,
136 const IDLList<ParticleType>& particles
139 //- Construct from mesh, cloud name, and a list of particles
142 const polyMesh& mesh,
143 const word& cloudName,
144 const IDLList<ParticleType>& particles
147 //- Construct from mesh by reading from file
148 // Optionally disable checking of class name for post-processing
151 const polyMesh& mesh,
152 const bool checkClass = true
156 //- Construct from mesh by reading from file with given cloud instance
157 // Optionally disable checking of class name for post-processing
160 const polyMesh& pMesh,
161 const word& cloudName,
162 const bool checkClass = true
170 //- Return the polyMesh reference
171 const polyMesh& pMesh() const
178 return IDLList<ParticleType>::size();
181 DynamicList<label>& labels()
186 //- Return nTrackingRescues
187 label nTrackingRescues() const
189 return nTrackingRescues_;
192 //- Increment the nTrackingRescues counter
193 void trackingRescue() const
196 if (cloud::debug && size() && (nTrackingRescues_ % size() == 0))
198 Pout<< " " << nTrackingRescues_
199 << " tracking rescues " << endl;
203 //- Whether each cell has any wall faces (demand driven data)
204 const PackedBoolList& cellHasWallFaces() const;
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
210 virtual bool hasWallImpactDistance() const
218 const const_iterator begin() const
220 return IDLList<ParticleType>::begin();
223 const const_iterator cbegin() const
225 return IDLList<ParticleType>::cbegin();
228 const const_iterator end() const
230 return IDLList<ParticleType>::end();
233 const const_iterator cend() const
235 return IDLList<ParticleType>::cend();
240 return IDLList<ParticleType>::begin();
245 return IDLList<ParticleType>::end();
253 return IDLList<ParticleType>::clear();
256 //- Transfer particle to cloud
257 void addParticle(ParticleType* pPtr);
259 //- Remove particle from cloud and delete
260 void deleteParticle(ParticleType&);
262 //- Reset the particles
263 void cloudReset(const Cloud<ParticleType>& c);
265 //- Move the particles
266 // passing the TrackingData to the track function
267 template<class TrackData>
268 void move(TrackData& td, const scalar trackTime);
270 //- Remap the cells of particles corresponding to the
271 // mesh topology change
272 template<class TrackData>
273 void autoMap(TrackData& td, const mapPolyMesh&);
278 //- Helper to construct IOobject for field and current time.
279 IOobject fieldIOobject
281 const word& fieldName,
282 const IOobject::readOption r
285 //- Check lagrangian data field
286 template<class DataType>
287 void checkFieldIOobject
289 const Cloud<ParticleType>& c,
290 const IOField<DataType>& data
293 //- Check lagrangian data fieldfield
294 template<class DataType>
295 void checkFieldFieldIOobject
297 const Cloud<ParticleType>& c,
298 const CompactIOField<Field<DataType>, DataType>& data
301 //- Read the field data for the cloud of particles. Dummy at
303 virtual void readFields();
308 //- Write the field data for the cloud of particles Dummy at
310 virtual void writeFields() const;
312 //- Write using given format, version and compression.
313 // Only writes the cloud file if the Cloud isn't empty
314 virtual bool writeObject
316 IOstream::streamFormat fmt,
317 IOstream::versionNumber ver,
318 IOstream::compressionType cmp
321 //- Write positions to \<cloudName\>_positions.obj file
322 void writePositions() const;
327 friend Ostream& operator<< <ParticleType>
330 const Cloud<ParticleType>&
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
337 } // End namespace Foam
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 // ************************************************************************* //