OpenFOAM logo
Open Source CFD Toolkit

cellZone.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     cellZone
00027 
00028 Description
00029     A subset of mesh cells.  Currently set us as an indirect list but
00030     will be extended to use a primitive mesh.  
00031     For quick check whether a cell belongs to the zone use the lookup mechanism
00032     in cellZoneMesh, where all the zoned cells are registered with their zone
00033     number.
00034 
00035 SourceFiles
00036     cellZone.C
00037     newCellZone.C
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef cellZone_H
00042 #define cellZone_H
00043 
00044 #include "labelList.H"
00045 #include "typeInfo.H"
00046 #include "dictionary.H"
00047 #include "cellZoneMeshFwd.H"
00048 #include "pointFieldFwd.H"
00049 #include "Map.H"
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 // * * * * * * * * Forward declaration of friend functions * * * * * * * * * //
00057 
00058 class cellZone;
00059 Ostream& operator<<(Ostream&, const cellZone&);
00060 
00061 
00062 /*---------------------------------------------------------------------------*\
00063                            Class cellZone Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 class cellZone
00067 :
00068     public labelList
00069 {
00070     // Private data
00071 
00072         //- Name of zone
00073         word name_;
00074 
00075         //- Index of zone
00076         label index_;
00077 
00078         //- Reference to zone list
00079         const cellZoneMesh& zoneMesh_;
00080 
00081         // Demand-driven private data
00082 
00083             //- Map of cell labels in zone for fast location lookup
00084             mutable Map<label>* cellLookupMapPtr_;
00085 
00086 
00087     // Private Member Functions
00088 
00089         //- Disallow default bitwise copy construct
00090         cellZone(const cellZone&);
00091 
00092         //- Return map of local cell indices
00093         const Map<label>& cellLookupMap() const;
00094 
00095         //- Build map of local cell indices
00096         void calcCellLookupMap() const;
00097 
00098 
00099 public:
00100 
00101     //- Runtime type information
00102     TypeName("cellZone");
00103 
00104 
00105     // Declare run-time constructor selection tables
00106 
00107         declareRunTimeSelectionTable
00108         (
00109             autoPtr,
00110             cellZone,
00111             dictionary,
00112             (
00113                 const word& name,
00114                 const dictionary& dict,
00115                 const label index,
00116                 const cellZoneMesh& zm
00117             ),
00118             (name, dict, index, zm)
00119         );
00120 
00121 
00122     // Constructors
00123 
00124         //- Construct from components
00125         cellZone
00126         (
00127             const word& name,
00128             const labelList& addr,
00129             const label index,
00130             const cellZoneMesh& zm
00131         );
00132 
00133         //- Construct from dictionary
00134         cellZone
00135         (
00136             const word& name,
00137             const dictionary& dict,
00138             const label index,
00139             const cellZoneMesh& zm
00140         );
00141 
00142         //- Construct given the original zone and resetting the
00143         //  cell list and zone mesh information
00144         cellZone
00145         (
00146             const cellZone& cz,
00147             const labelList& addr,
00148             const label index,
00149             const cellZoneMesh& zm
00150         );
00151 
00152         //- Construct and return a clone, resetting the zone mesh
00153         virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
00154         {
00155             return autoPtr<cellZone>
00156             (
00157                 new cellZone(*this, *this, index(), zm)
00158             );
00159         }
00160 
00161         //- Construct and return a clone, resetting the cell list
00162         //  and zone mesh
00163         virtual autoPtr<cellZone> clone
00164         (
00165             const labelList& addr,
00166             const label index,
00167             const cellZoneMesh& zm
00168         ) const
00169         {
00170             return autoPtr<cellZone>
00171             (
00172                 new cellZone(*this, addr, index, zm)
00173             );
00174         }
00175 
00176 
00177     // Selectors
00178 
00179         //- Return a pointer to a new cell zone
00180         //  created on freestore from dictionary
00181         static autoPtr<cellZone> New
00182         (
00183             const word& name,
00184             const dictionary& dict,
00185             const label index,
00186             const cellZoneMesh&
00187         );
00188 
00189 
00190     //- Destructor
00191 
00192         virtual ~cellZone();
00193 
00194 
00195     // Member Functions
00196 
00197         //- Return name
00198         const word& name() const
00199         {
00200             return name_;
00201         }
00202 
00203         //- Map storing the local cell index for every global cell
00204         //  index.  Used to find out the index of cell in the zone from
00205         //  the known global cell index.  If the cell is not in the
00206         //  zone, returns -1
00207         label whichCell(const label globalCellID) const;
00208 
00209         //- Return the index of this zone in zone list
00210         label index() const
00211         {
00212             return index_;
00213         }
00214 
00215         //- Return zoneMesh reference
00216         const cellZoneMesh& zoneMesh() const;
00217 
00218         //- Clear addressing
00219         void clearAddressing();
00220 
00221         //- Correct patch after moving points
00222         virtual void movePoints(const pointField&)
00223         {}
00224 
00225         //- Write
00226         virtual void write(Ostream&) const;
00227 
00228         //- Write dictionary
00229         virtual void writeDict(Ostream&) const;
00230 
00231 
00232     // Member Operators
00233 
00234         //- Assign to zone clearing demand-driven data
00235         void operator=(const cellZone&);
00236 
00237         //- Assign addressing clearing demand-driven data
00238         void operator=(const labelList&);
00239 
00240 
00241     // Ostream Operator
00242 
00243         friend Ostream& operator<<(Ostream&, const cellZone&);
00244 };
00245 
00246 
00247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00248 
00249 } // End namespace Foam
00250 
00251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00252 
00253 #endif
00254 
00255 // ************************************************************************* //
For further information go to www.openfoam.org