initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / meshes / polyMesh / zones / cellZone / cellZone.H
blob799e810e2a3454520721e3f26da7c14acd8e1091
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::cellZone
28 Description
29     A subset of mesh cells.
31     Currently set up as an indirect list but will be extended to use a
32     primitive mesh.  For quick check whether a cell belongs to the zone use
33     the lookup mechanism in cellZoneMesh, where all the zoned cells are
34     registered with their zone number.
36 SourceFiles
37     cellZone.C
38     newCellZone.C
40 \*---------------------------------------------------------------------------*/
42 #ifndef cellZone_H
43 #define cellZone_H
45 #include "labelList.H"
46 #include "typeInfo.H"
47 #include "dictionary.H"
48 #include "cellZoneMeshFwd.H"
49 #include "pointFieldFwd.H"
50 #include "Map.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 namespace Foam
57 // Forward declaration of friend functions and operators
59 class cellZone;
60 Ostream& operator<<(Ostream&, const cellZone&);
63 /*---------------------------------------------------------------------------*\
64                            Class cellZone Declaration
65 \*---------------------------------------------------------------------------*/
67 class cellZone
69     public labelList
71     // Private data
73         //- Name of zone
74         word name_;
76         //- Index of zone
77         label index_;
79         //- Reference to zone list
80         const cellZoneMesh& zoneMesh_;
82         // Demand-driven private data
84             //- Map of cell labels in zone for fast location lookup
85             mutable Map<label>* cellLookupMapPtr_;
88     // Private Member Functions
90         //- Disallow default bitwise copy construct
91         cellZone(const cellZone&);
93         //- Return map of local cell indices
94         const Map<label>& cellLookupMap() const;
96         //- Build map of local cell indices
97         void calcCellLookupMap() const;
100 public:
102     //- Runtime type information
103     TypeName("cellZone");
106     // Declare run-time constructor selection tables
108         declareRunTimeSelectionTable
109         (
110             autoPtr,
111             cellZone,
112             dictionary,
113             (
114                 const word& name,
115                 const dictionary& dict,
116                 const label index,
117                 const cellZoneMesh& zm
118             ),
119             (name, dict, index, zm)
120         );
123     // Constructors
125         //- Construct from components
126         cellZone
127         (
128             const word& name,
129             const labelList& addr,
130             const label index,
131             const cellZoneMesh& zm
132         );
134         //- Construct from dictionary
135         cellZone
136         (
137             const word& name,
138             const dictionary& dict,
139             const label index,
140             const cellZoneMesh& zm
141         );
143         //- Construct given the original zone and resetting the
144         //  cell list and zone mesh information
145         cellZone
146         (
147             const cellZone& cz,
148             const labelList& addr,
149             const label index,
150             const cellZoneMesh& zm
151         );
153         //- Construct and return a clone, resetting the zone mesh
154         virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
155         {
156             return autoPtr<cellZone>
157             (
158                 new cellZone(*this, *this, index(), zm)
159             );
160         }
162         //- Construct and return a clone, resetting the cell list
163         //  and zone mesh
164         virtual autoPtr<cellZone> clone
165         (
166             const labelList& addr,
167             const label index,
168             const cellZoneMesh& zm
169         ) const
170         {
171             return autoPtr<cellZone>
172             (
173                 new cellZone(*this, addr, index, zm)
174             );
175         }
178     // Selectors
180         //- Return a pointer to a new cell zone
181         //  created on freestore from dictionary
182         static autoPtr<cellZone> New
183         (
184             const word& name,
185             const dictionary& dict,
186             const label index,
187             const cellZoneMesh&
188         );
191     //- Destructor
193         virtual ~cellZone();
196     // Member Functions
198         //- Return name
199         const word& name() const
200         {
201             return name_;
202         }
204         //- Map storing the local cell index for every global cell
205         //  index.  Used to find out the index of cell in the zone from
206         //  the known global cell index.  If the cell is not in the
207         //  zone, returns -1
208         label whichCell(const label globalCellID) const;
210         //- Return the index of this zone in zone list
211         label index() const
212         {
213             return index_;
214         }
216         //- Return zoneMesh reference
217         const cellZoneMesh& zoneMesh() const;
219         //- Clear addressing
220         void clearAddressing();
222         //- Check zone definition. Return true if in error.
223         bool checkDefinition(const bool report = false) const;
225         //- Correct patch after moving points
226         virtual void movePoints(const pointField&)
227         {}
229         //- Write
230         virtual void write(Ostream&) const;
232         //- Write dictionary
233         virtual void writeDict(Ostream&) const;
236     // Member Operators
238         //- Assign to zone clearing demand-driven data
239         void operator=(const cellZone&);
241         //- Assign addressing clearing demand-driven data
242         void operator=(const labelList&);
245     // Ostream Operator
247         friend Ostream& operator<<(Ostream&, const cellZone&);
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 } // End namespace Foam
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 #endif
259 // ************************************************************************* //