initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / meshes / polyMesh / zones / pointZone / pointZone.H
blob18370e2672bf37b77b2e060855e948489447aec2
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::pointZone
28 Description
29     A subset of mesh points.
30     The labels of points in the zone can be obtained from the addressing()
31     list.
33     For quick check whether a point belongs to the zone use the lookup
34     mechanism in pointZoneMesh, where all the zoned points are registered
35     with their zone number.
37 SourceFiles
38     pointZone.C
39     newPointZone.C
41 \*---------------------------------------------------------------------------*/
43 #ifndef pointZone_H
44 #define pointZone_H
46 #include "labelList.H"
47 #include "typeInfo.H"
48 #include "dictionary.H"
49 #include "pointZoneMeshFwd.H"
50 #include "Map.H"
51 #include "pointField.H"
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 namespace Foam
58 // Forward declaration of friend functions and operators
60 class pointZone;
61 Ostream& operator<<(Ostream&, const pointZone&);
64 /*---------------------------------------------------------------------------*\
65                            Class pointZone Declaration
66 \*---------------------------------------------------------------------------*/
68 class pointZone
70     public labelList
72     // Private data
74         //- Name of zone
75         word name_;
77         //- Index of zone
78         label index_;
80         //- Reference to zone list
81         const pointZoneMesh& zoneMesh_;
84         // Demand-driven private data
86             //- Map of point labels in zone for fast location lookup
87             mutable Map<label>* pointLookupMapPtr_;
90     // Private Member Functions
92         //- Disallow default bitwise copy construct
93         pointZone(const pointZone&);
95         //- Return map of local point indices
96         const Map<label>& pointLookupMap() const;
98         //- Build map of local point indices
99         void calcPointLookupMap() const;
102 public:
104     //- Runtime type information
105     TypeName("pointZone");
108     // Declare run-time constructor selection tables
110         declareRunTimeSelectionTable
111         (
112             autoPtr,
113             pointZone,
114             dictionary,
115             (
116                 const word& name,
117                 const dictionary& dict,
118                 const label index,
119                 const pointZoneMesh& zm
120             ),
121             (name, dict, index, zm)
122         );
125     // Constructors
127         //- Construct from components
128         pointZone
129         (
130             const word& name,
131             const labelList& addr,
132             const label index,
133             const pointZoneMesh& zm
134         );
136         //- Construct from dictionary
137         pointZone
138         (
139             const word& name,
140             const dictionary& dict,
141             const label index,
142             const pointZoneMesh& zm
143         );
145         //- Construct given the original zone and resetting the
146         //  point list and zone mesh information
147         pointZone
148         (
149             const pointZone& pz,
150             const labelList& addr,
151             const label index,
152             const pointZoneMesh& zm
153         );
155         //- Construct and return a clone, resetting the zone mesh
156         virtual autoPtr<pointZone> clone(const pointZoneMesh& zm) const
157         {
158             return autoPtr<pointZone>
159             (
160                 new pointZone(*this, *this, index(), zm)
161             );
162         }
164         //- Construct and return a clone, resetting the point list
165         //  and zone mesh
166         virtual autoPtr<pointZone> clone
167         (
168             const pointZoneMesh& zm,
169             const label index,
170             const labelList& addr
171         ) const
172         {
173             return autoPtr<pointZone>
174             (
175                 new pointZone(*this, addr, index, zm)
176             );
177         }
180     // Selectors
182         //- Return a pointer to a new point zone
183         //  created on freestore from dictionary
184         static autoPtr<pointZone> New
185         (
186             const word& name,
187             const dictionary& dict,
188             const label index,
189             const pointZoneMesh&
190         );
193     //- Destructor
195         virtual ~pointZone();
198     // Member Functions
200         //- Return name
201         const word& name() const
202         {
203             return name_;
204         }
206         //- Map storing the local point index for every global point
207         //  index.  Used to find out the index of point in the zone from
208         //  the known global point index.  If the point is not in the
209         //  zone, returns -1
210         label whichPoint(const label globalPointID) const;
212         //- Return the index of this zone in zone list
213         label index() const
214         {
215             return index_;
216         }
218         //- Return zoneMesh reference
219         const pointZoneMesh& zoneMesh() const;
221         //- Clear addressing
222         void clearAddressing();
224         //- Check zone definition. Return true if in error.
225         bool checkDefinition(const bool report = false) const;
227         //- Correct patch after moving points
228         virtual void movePoints(const pointField&)
229         {}
231         //- Write
232         virtual void write(Ostream&) const;
234         //- Write dictionary
235         virtual void writeDict(Ostream&) const;
238     // Member Operators
240         //- Assign to zone clearing demand-driven data
241         void operator=(const pointZone&);
243         //- Assign addressing clearing demand-driven data
244         void operator=(const labelList&);
247     // Ostream Operator
249         friend Ostream& operator<<(Ostream&, const pointZone&);
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 } // End namespace Foam
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 #endif
261 // ************************************************************************* //