OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

Cloud.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::Cloud
00027 
00028 Description
00029 
00030 SourceFiles
00031     Cloud.C
00032     CloudIO.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef Cloud_H
00037 #define Cloud_H
00038 
00039 #include "cloud.H"
00040 #include "IDLList.H"
00041 #include "IOField.H"
00042 #include "polyMesh.H"
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 // Forward declaration of functions
00050 template<class ParticleType>
00051 class Cloud;
00052 
00053 template<class ParticleType>
00054 class IOPosition;
00055 
00056 template<class ParticleType>
00057 Ostream& operator<<
00058 (
00059     Ostream&,
00060     const Cloud<ParticleType>&
00061 );
00062 
00063 
00064 /*---------------------------------------------------------------------------*\
00065                            Class Cloud Declaration
00066 \*---------------------------------------------------------------------------*/
00067 
00068 template<class ParticleType>
00069 class Cloud
00070 :
00071     public cloud,
00072     public IDLList<ParticleType>
00073 {
00074     // Private data
00075 
00076         const polyMesh& polyMesh_;
00077 
00078         //- Overall count of particles ever created. Never decreases.
00079         mutable label particleCount_;
00080 
00081         //- Temporary storage for addressing. Used in findFaces.
00082         mutable DynamicList<label> labels_;
00083 
00084 
00085     // Private member functions
00086 
00087         //- Initialise cloud on IO constructor
00088         void initCloud(const bool checkClass);
00089 
00090 
00091 public:
00092 
00093     template<class ParticleT>
00094     friend class Particle;
00095     template<class ParticleT>
00096     friend class IOPosition;
00097 
00098     typedef ParticleType particleType;
00099 
00100     typedef typename IDLList<ParticleType>::iterator iterator;
00101     typedef typename IDLList<ParticleType>::const_iterator const_iterator;
00102 
00103     //-Runtime type information
00104     TypeName("Cloud");
00105 
00106 
00107     // Constructors
00108 
00109         //- Construct from mesh and a list of particles
00110         Cloud
00111         (
00112             const polyMesh& mesh,
00113             const IDLList<ParticleType>& particles
00114         );
00115 
00116         //- Construct from mesh, cloud name, and a list of particles
00117         Cloud
00118         (
00119             const polyMesh& mesh,
00120             const word& cloudName,
00121             const IDLList<ParticleType>& particles
00122         );
00123 
00124         //- Construct from mesh by reading from file
00125         //  Optionally disable checking of class name for post-processing
00126         Cloud
00127         (
00128             const polyMesh& mesh,
00129             const bool checkClass = true
00130         );
00131 
00132 
00133         //- Construct from mesh by reading from file with given cloud instance
00134         //  Optionally disable checking of class name for post-processing
00135         Cloud
00136         (
00137             const polyMesh& pMesh,
00138             const word& cloudName,
00139             const bool checkClass = true
00140         );
00141 
00142 
00143     // Member Functions
00144 
00145         // Access
00146 
00147             //- Return the polyMesh reference
00148             const polyMesh& pMesh() const
00149             {
00150                 return polyMesh_;
00151             }
00152 
00153             //- Is this global face an internal face?
00154             bool internalFace(const label facei) const
00155             {
00156                 return polyMesh_.isInternalFace(facei);
00157             }
00158 
00159             //- Is this global face a boundary face?
00160             bool boundaryFace(const label facei) const
00161             {
00162                 return !internalFace(facei);
00163             }
00164 
00165             //- Which patch is this global face on
00166             label facePatch(const label facei) const
00167             {
00168                 return polyMesh_.boundaryMesh().whichPatch(facei);
00169             }
00170 
00171             //- Which face of this patch is this global face
00172             label patchFace(const label patchi, const label facei) const
00173             {
00174                 return polyMesh_.boundaryMesh()[patchi].whichFace(facei);
00175             }
00176 
00177             label size() const
00178             {
00179                 return IDLList<ParticleType>::size();
00180             };
00181 
00182 
00183             // Iterators
00184 
00185                 const const_iterator begin() const
00186                 {
00187                     return IDLList<ParticleType>::begin();
00188                 };
00189 
00190                 const const_iterator cbegin() const
00191                 {
00192                     return IDLList<ParticleType>::cbegin();
00193                 };
00194 
00195                 const const_iterator end() const
00196                 {
00197                     return IDLList<ParticleType>::end();
00198                 };
00199 
00200                 const const_iterator cend() const
00201                 {
00202                     return IDLList<ParticleType>::cend();
00203                 };
00204 
00205                 iterator begin()
00206                 {
00207                     return IDLList<ParticleType>::begin();
00208                 };
00209 
00210                 iterator end()
00211                 {
00212                     return IDLList<ParticleType>::end();
00213                 };
00214 
00215 
00216         // Edit
00217 
00218             void clear()
00219             {
00220                 return IDLList<ParticleType>::clear();
00221             };
00222 
00223             //- Get unique particle creation id
00224             label getNewParticleID() const;
00225 
00226             //- Transfer particle to cloud
00227             void addParticle(ParticleType* pPtr);
00228 
00229             //- Remove particle from cloud and delete
00230             void deleteParticle(ParticleType&);
00231 
00232             //- Move the particles
00233             //  passing the TrackingData to the track function
00234             template<class TrackingData>
00235             void move(TrackingData& td);
00236 
00237             //- Remap the cells of particles corresponding to the
00238             //  mesh topology change
00239             virtual void autoMap(const mapPolyMesh&);
00240 
00241 
00242         // Read
00243 
00244             //- Helper to construct IOobject for field and current time.
00245             IOobject fieldIOobject
00246             (
00247                 const word& fieldName,
00248                 const IOobject::readOption r
00249             ) const;
00250 
00251             //- Check lagrangian data field
00252             template<class DataType>
00253             void checkFieldIOobject
00254             (
00255                 const Cloud<ParticleType>& c,
00256                 const IOField<DataType>& data
00257             ) const;
00258 
00259             //- Read the field data for the cloud of particles. Dummy at
00260             //  this level.
00261             virtual void readFields();
00262 
00263 
00264         // Write
00265 
00266             //- Write the field data for the cloud of particles Dummy at
00267             //  this level.
00268             virtual void writeFields() const;
00269 
00270             //- Write using given format, version and compression.
00271             //  Only writes the cloud file if the Cloud isn't empty
00272             virtual bool writeObject
00273             (
00274                 IOstream::streamFormat fmt,
00275                 IOstream::versionNumber ver,
00276                 IOstream::compressionType cmp
00277             ) const;
00278 
00279             //- Write positions to <cloudName>_positions.obj file
00280             void writePositions() const;
00281 
00282 
00283     // Ostream Operator
00284 
00285         friend Ostream& operator<< <ParticleType>
00286         (
00287             Ostream&,
00288             const Cloud<ParticleType>&
00289         );
00290 };
00291 
00292 
00293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00294 
00295 } // End namespace Foam
00296 
00297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00298 
00299 #ifdef NoRepository
00300 #   include "Cloud.C"
00301 #endif
00302 
00303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00304 
00305 #endif
00306 
00307 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd