initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / lagrangian / basic / Cloud / Cloud.H
blob270a30ce7b59ef1e1be5e6e47ea24f38e623d334
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::Cloud
28 Description
30 SourceFiles
31     Cloud.C
32     CloudIO.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef Cloud_H
37 #define Cloud_H
39 #include "cloud.H"
40 #include "pointMesh.H"
41 #include "IDLList.H"
42 #include "IOField.H"
44 #include "polyMeshInfo.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 template<class ParticleType>
52 class Cloud;
54 template<class ParticleType>
55 Ostream& operator<<
57     Ostream&,
58     const Cloud<ParticleType>&
62 /*---------------------------------------------------------------------------*\
63                            Class Cloud Declaration
64 \*---------------------------------------------------------------------------*/
66 template<class ParticleType>
67 class Cloud
69     public cloud,
70     public IDLList<ParticleType>
73     // Private data
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);
93 public:
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
104     TypeName("Cloud");
107     // Constructors
109         //- Construct from mesh and a list of particles
110         Cloud
111         (
112             const polyMesh& mesh,
113             const IDLList<ParticleType>& particles
114         );
116         //- Construct from mesh, cloud name, and a list of particles
117         Cloud
118         (
119             const polyMesh& mesh,
120             const word& cloudName,
121             const IDLList<ParticleType>& particles
122         );
124         //- Construct from mesh by reading from file
125         //  Optionally disable checking of class name for post-processing
126         Cloud
127         (
128             const polyMesh& mesh,
129             const bool checkClass = true
130         );
133         //- Construct from mesh by reading from file with given cloud instance
134         //  Optionally disable checking of class name for post-processing
135         Cloud
136         (
137             const polyMesh& pMesh,
138             const word& cloudName,
139             const bool checkClass = true
140         );
143     // Member Functions
145         // Access
147             //- Return the polyMesh reference
148             const polyMesh& pMesh() const
149             {
150                 return polyMesh_;
151             }
153             //- Is this global face an internal face?
154             bool internalFace(const label facei) const
155             {
156                 return polyMesh_.isInternalFace(facei);
157             }
159             //- Is this global face a boundary face?
160             bool boundaryFace(const label facei) const
161             {
162                 return !internalFace(facei);
163             }
165             //- Which patch is this global face on
166             label facePatch(const label facei) const
167             {
168                 return polyMesh_.boundaryMesh().whichPatch(facei);
169             }
171             //- Which face of this patch is this global face
172             label patchFace(const label patchi, const label facei) const
173             {
174                 return polyMesh_.boundaryMesh()[patchi].whichFace(facei);
175             }
177             //- Return reference to the mesh information object
178             const polyMeshInfo& meshInfo() const
179             {
180                 return meshInfo_;
181             }
183             label size() const
184             {
185                 return IDLList<ParticleType>::size();
186             };
188             const const_iterator begin() const
189             {
190                 return IDLList<ParticleType>::begin();
191             };
193             const const_iterator end() const
194             {
195                 return IDLList<ParticleType>::end();
196             };
198             iterator begin()
199             {
200                 return IDLList<ParticleType>::begin();
201             };
203             iterator end()
204             {
205                 return IDLList<ParticleType>::end();
206             };
208             void clear()
209             {
210                 return IDLList<ParticleType>::clear();
211             };
214         // Edit
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&);
232         // Read
234             //- Read and return a lagrangian data field
235             //  Checks that data is valid
236             template<class DataType>
237             void checkFieldIOobject
238             (
239                 const Cloud<ParticleType>& c,
240                 const IOField<DataType>& data
241             ) const;
243             //- Read and return a lagrangian data field
244             IOobject fieldIOobject(const word& fieldName) const;
246             //- Read and return a lagrangian data field
247             template<class Type>
248             tmp<IOField<Type> > readField(const word& fieldName) const;
250             //- Read the field data for the cloud of particles
251             void readFields();
254         // Write
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
262             (
263                 IOstream::streamFormat fmt,
264                 IOstream::versionNumber ver,
265                 IOstream::compressionType cmp
266             ) const;
269     // Ostream Operator
271         friend Ostream& operator<< <ParticleType>
272         (
273             Ostream&,
274             const Cloud<ParticleType>&
275         );
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 } // End namespace Foam
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 #ifdef NoRepository
286 #   include "Cloud.C"
287 #endif
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 #endif
293 // ************************************************************************* //