FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::cellZone
00026 
00027 Description
00028     A subset of mesh cells.
00029 
00030     Currently set up as an indirect list but will be extended to use a
00031     primitive mesh.  For quick check whether a cell belongs to the zone use
00032     the lookup mechanism in cellZoneMesh, where all the zoned cells are
00033     registered with their zone number.
00034 
00035 SourceFiles
00036     cellZone.C
00037     newCellZone.C
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef cellZone_H
00042 #define cellZone_H
00043 
00044 #include <OpenFOAM/labelList.H>
00045 #include <OpenFOAM/typeInfo.H>
00046 #include <OpenFOAM/dictionary.H>
00047 #include <OpenFOAM/cellZoneMeshFwd.H>
00048 #include <OpenFOAM/pointFieldFwd.H>
00049 #include <OpenFOAM/Map.H>
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 // Forward declaration of friend functions and operators
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&
00131         );
00132 
00133         //- Construct from components, transferring contents
00134         cellZone
00135         (
00136             const word& name,
00137             const Xfer<labelList>& addr,
00138             const label index,
00139             const cellZoneMesh&
00140         );
00141 
00142         //- Construct from dictionary
00143         cellZone
00144         (
00145             const word& name,
00146             const dictionary&,
00147             const label index,
00148             const cellZoneMesh&
00149         );
00150 
00151         //- Construct given the original zone and resetting the
00152         //  cell list and zone mesh information
00153         cellZone
00154         (
00155             const cellZone&,
00156             const labelList& addr,
00157             const label index,
00158             const cellZoneMesh&
00159         );
00160 
00161         //- Construct given the original zone, resetting the
00162         //  cell list and zone mesh information
00163         cellZone
00164         (
00165             const cellZone&,
00166             const Xfer<labelList>& addr,
00167             const label index,
00168             const cellZoneMesh&
00169         );
00170 
00171         //- Construct and return a clone, resetting the zone mesh
00172         virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
00173         {
00174             return autoPtr<cellZone>
00175             (
00176                 new cellZone(*this, *this, index(), zm)
00177             );
00178         }
00179 
00180         //- Construct and return a clone, resetting the cell list
00181         //  and zone mesh
00182         virtual autoPtr<cellZone> clone
00183         (
00184             const labelList& addr,
00185             const label index,
00186             const cellZoneMesh& zm
00187         ) const
00188         {
00189             return autoPtr<cellZone>
00190             (
00191                 new cellZone(*this, addr, index, zm)
00192             );
00193         }
00194 
00195 
00196     // Selectors
00197 
00198         //- Return a pointer to a new cell zone
00199         //  created on freestore from dictionary
00200         static autoPtr<cellZone> New
00201         (
00202             const word& name,
00203             const dictionary&,
00204             const label index,
00205             const cellZoneMesh&
00206         );
00207 
00208 
00209     //- Destructor
00210 
00211         virtual ~cellZone();
00212 
00213 
00214     // Member Functions
00215 
00216         //- Return name
00217         const word& name() const
00218         {
00219             return name_;
00220         }
00221 
00222         //- Map storing the local cell index for every global cell
00223         //  index.  Used to find out the index of cell in the zone from
00224         //  the known global cell index.  If the cell is not in the
00225         //  zone, returns -1
00226         label whichCell(const label globalCellID) const;
00227 
00228         //- Return the index of this zone in zone list
00229         label index() const
00230         {
00231             return index_;
00232         }
00233 
00234         //- Return zoneMesh reference
00235         const cellZoneMesh& zoneMesh() const;
00236 
00237         //- Clear addressing
00238         void clearAddressing();
00239 
00240         //- Check zone definition. Return true if in error.
00241         bool checkDefinition(const bool report = false) const;
00242 
00243         //- Correct patch after moving points
00244         virtual void movePoints(const pointField&)
00245         {}
00246 
00247         //- Write
00248         virtual void write(Ostream&) const;
00249 
00250         //- Write dictionary
00251         virtual void writeDict(Ostream&) const;
00252 
00253 
00254     // Member Operators
00255 
00256         //- Assign to zone clearing demand-driven data
00257         void operator=(const cellZone&);
00258 
00259         //- Assign addressing clearing demand-driven data
00260         void operator=(const labelList&);
00261 
00262 
00263     // Ostream Operator
00264 
00265         friend Ostream& operator<<(Ostream&, const cellZone&);
00266 };
00267 
00268 
00269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00270 
00271 } // End namespace Foam
00272 
00273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00274 
00275 #endif
00276 
00277 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines