OpenFOAM logo
Open Source CFD Toolkit

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-2005 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     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 "pointMesh.H"
00041 #include "IDLList.H"
00042 #include "IOField.H"
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 template<class particleType>
00050 class Cloud;
00051 
00052 template<class particleType>
00053 Ostream& operator<<
00054 (
00055     Ostream&,
00056     const Cloud<particleType>&
00057 );
00058 
00059 
00060 /*---------------------------------------------------------------------------*\
00061                            Class Cloud Declaration
00062 \*---------------------------------------------------------------------------*/
00063 
00064 template<class particleType>
00065 class Cloud
00066 :
00067     public cloud,
00068     public IDLList<particleType>
00069 {
00070     // Private data
00071 
00072         const polyMesh& polyMesh_;
00073 
00074         const faceList& allFaces_;
00075         const vectorField& points_;
00076         const cellList& cellFaces_;
00077         const vectorField& allFaceCentres_;
00078         const unallocLabelList& owner_;
00079         const unallocLabelList& neighbour_;
00080 
00081 
00082 public:
00083 
00084     template<class particleT>
00085     friend class particle;
00086 
00087     typedef typename IDLList<particleType>::iterator iterator;
00088     typedef typename IDLList<particleType>::const_iterator const_iterator;
00089 
00090 
00091     // Constructors
00092 
00093         //- Construct from mesh and a list of particles
00094         Cloud
00095         (
00096             const polyMesh& mesh,
00097             const IDLList<particleType>& particles
00098         );
00099 
00100         //- Construct from mesh by reading from file
00101         Cloud
00102         (
00103             const polyMesh& mesh
00104         );
00105 
00106 
00107     // Member Functions
00108 
00109         // Access
00110 
00111             //- Return the polyMesh reference
00112             const polyMesh& pMesh() const
00113             {
00114                 return polyMesh_;
00115             }
00116 
00117             //- Is this global face an internal face?
00118             bool internalFace(const label facei) const
00119             {
00120                 return polyMesh_.isInternalFace(facei);
00121             }
00122 
00123             //- Is this global face a boundary face?
00124             bool boundaryFace(const label facei) const
00125             {
00126                 return !internalFace(facei);
00127             }
00128 
00129             //- Which patch is this global face on
00130             label facePatch(const label facei) const
00131             {
00132                 return polyMesh_.boundaryMesh().whichPatch(facei);
00133             }
00134 
00135             //- Which face of this patch is this global face
00136             label patchFace(const label patchi, const label facei) const
00137             {
00138                 return polyMesh_.boundaryMesh()[patchi].whichFace(facei);
00139             }
00140 
00141 
00142         // Edit
00143 
00144             //- Transfer particle to cloud
00145             void addParticle(particleType* pPtr);
00146 
00147             //- Remove particle from cloud and delete
00148             void deleteParticle(particleType&);
00149 
00150             //- Track the particles
00151             template<class TrackingData>
00152             void track(TrackingData& td);
00153 
00154             //- Remap the cells of particles corresponding to the
00155             //  mesh topology change
00156             virtual void autoMap(const mapPolyMesh&);
00157 
00158 
00159         // Read
00160 
00161             //- Read and return a lagrangian data field
00162             IOobject fieldIOobject(const word& fieldName) const;
00163 
00164             //- Read and return a lagrangian data field
00165             template<class Type>
00166             tmp<IOField<Type> > readField(const word& fieldName) const;
00167 
00168             //- Read the field data for the cloud of particles
00169             void readFields();
00170 
00171 
00172         // Write
00173 
00174             virtual bool writeData(Ostream&) const;
00175 
00176             //- Write the field data for the cloud of particles
00177             virtual void writeFields() const;
00178 
00179 
00180     // Ostream Operator
00181 
00182         friend Ostream& operator<< <particleType>
00183         (
00184             Ostream&,
00185             const Cloud<particleType>&
00186         );
00187 };
00188 
00189 
00190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00191 
00192 } // End namespace Foam
00193 
00194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00195 
00196 #ifdef NoRepository
00197 #   include "Cloud.C"
00198 #endif
00199 
00200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00201 
00202 #endif
00203 
00204 // ************************************************************************* //
For further information go to www.openfoam.org