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

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