initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / zones / faceZone / faceZone.H
blob16c7e82b09c0ad272d99d1f9d60ecd552afcf3f9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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::faceZone
28 Description
29     A subset of mesh faces organised as a primitive patch.
31     For quick check whether a face belongs to the zone use the lookup
32     mechanism in faceZoneMesh, where all the zoned faces are registered
33     with their zone number.
35 SourceFiles
36     faceZone.C
37     newFaceZone.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef faceZone_H
42 #define faceZone_H
44 #include "typeInfo.H"
45 #include "dictionary.H"
46 #include "labelList.H"
47 #include "faceZoneMeshFwd.H"
48 #include "boolList.H"
49 #include "primitiveFacePatch.H"
50 #include "Map.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 namespace Foam
57 class mapPolyMesh;
59 // Forward declaration of friend functions and operators
61 class faceZone;
62 Ostream& operator<<(Ostream&, const faceZone&);
65 /*---------------------------------------------------------------------------*\
66                            Class faceZone Declaration
67 \*---------------------------------------------------------------------------*/
69 class faceZone
71     public labelList
73     // Private data
75         //- Name of zone
76         word name_;
78         //- Flip map for all faces in the zone.  Set to true if the
79         //  face needs to be flipped to achieve the correct orientation.
80         boolList flipMap_;
82         //- Index of zone
83         label index_;
85         //- Reference to zone list
86         const faceZoneMesh& zoneMesh_;
89         // Demand-driven private data
91             //- Primitive patch made out of correctly flipped faces
92             mutable primitiveFacePatch* patchPtr_;
94             //- Master cell layer
95             mutable labelList* masterCellsPtr_;
97             //- Slave cell layer
98             mutable labelList* slaveCellsPtr_;
100             //- Global edge addressing
101             mutable labelList* mePtr_;
103             //- Map of face labels in zone for fast location lookup
104             mutable Map<label>* faceLookupMapPtr_;
107     // Private Member Functions
109         //- Disallow default bitwise copy construct
110         faceZone(const faceZone&);
112         //- Disallow default bitwise assignment
113         void operator=(const faceZone&);
115         //- Build primitive patch
116         void calcFaceZonePatch() const;
118         //- Return map of local face indices
119         const Map<label>& faceLookupMap() const;
121         //- Build map of local face indices
122         void calcFaceLookupMap() const;
124         //- Calculate master and slave face layer
125         void calcCellLayers() const;
127         //- Check addressing
128         void checkAddressing() const;
131 public:
133     //- Runtime type information
134     TypeName("faceZone");
137     // Declare run-time constructor selection tables
139         declareRunTimeSelectionTable
140         (
141             autoPtr,
142             faceZone,
143             dictionary,
144             (
145                 const word& name,
146                 const dictionary& dict,
147                 const label index,
148                 const faceZoneMesh& zm
149             ),
150             (name, dict, index, zm)
151         );
154     // Constructors
156         //- Construct from components
157         faceZone
158         (
159             const word& name,
160             const labelList& addr,
161             const boolList& fm,
162             const label index,
163             const faceZoneMesh& zm
164         );
166         //- Construct from components, transferring contents
167         faceZone
168         (
169             const word& name,
170             const Xfer<labelList>& addr,
171             const Xfer<boolList>& fm,
172             const label index,
173             const faceZoneMesh&
174         );
176         //- Construct from dictionary
177         faceZone
178         (
179             const word& name,
180             const dictionary&,
181             const label index,
182             const faceZoneMesh&
183         );
185         //- Construct given the original zone and resetting the
186         //  face list and zone mesh information
187         faceZone
188         (
189             const faceZone&,
190             const labelList& addr,
191             const boolList& fm,
192             const label index,
193             const faceZoneMesh&
194         );
196         //- Construct given the original zone, resetting the
197         //  face list and zone mesh information
198         faceZone
199         (
200             const faceZone&,
201             const Xfer<labelList>& addr,
202             const Xfer<boolList>& fm,
203             const label index,
204             const faceZoneMesh&
205         );
207         //- Construct and return a clone, resetting the zone mesh
208         virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
209         {
210             return autoPtr<faceZone>
211             (
212                 new faceZone(*this, *this, flipMap(), index(), zm)
213             );
214         }
216         //- Construct and return a clone, resetting the face list
217         //  and zone mesh
218         virtual autoPtr<faceZone> clone
219         (
220             const labelList& addr,
221             const boolList& fm,
222             const label index,
223             const faceZoneMesh& zm
224         ) const
225         {
226             return autoPtr<faceZone>
227             (
228                 new faceZone(*this, addr, fm, index, zm)
229             );
230         }
233     // Selectors
235         //- Return a pointer to a new face zone
236         //  created on freestore from dictionary
237         static autoPtr<faceZone> New
238         (
239             const word& name,
240             const dictionary&,
241             const label index,
242             const faceZoneMesh&
243         );
246     //- Destructor
248         virtual ~faceZone();
251     // Member Functions
253         //- Return name
254         const word& name() const
255         {
256             return name_;
257         }
259         //- Return face flip map
260         const boolList& flipMap() const
261         {
262             return flipMap_;
263         }
265         //- Map storing the local face index for every global face index.
266         //  Used to find out the index of face in the zone from the known global
267         //  face index.  If the face is not in the zone, returns -1
268         label whichFace(const label globalFaceID) const;
270         //- Return reference to primitive patch
271         const primitiveFacePatch& operator()() const;
273         //- Return the index of this zone in zone list
274         label index() const
275         {
276             return index_;
277         }
279         //- Return zoneMesh reference
280         const faceZoneMesh& zoneMesh() const;
283         // Addressing into mesh
285             //- Return labels of master cells (cells next to the master face
286             //  zone in the prescribed direction)
287             const labelList& masterCells() const;
289             //- Return labels of slave cells
290             const labelList& slaveCells() const;
292             //- Return global edge index for local edges
293             const labelList& meshEdges() const;
296         //- Clear addressing
297         void clearAddressing();
299         //- Reset addressing and flip map (clearing demand-driven data)
300         void resetAddressing(const labelList&, const boolList&);
302         //- Check zone definition. Return true if in error.
303         bool checkDefinition(const bool report = false) const;
305         //- Check whether all procs have faces synchronised. Return
306         //  true if in error.
307         bool checkParallelSync(const bool report = false) const;
309         //- Correct patch after moving points
310         virtual void movePoints(const pointField&);
312         //- Update for changes in topology
313         void updateMesh(const mapPolyMesh& mpm);
315         //- Write
316         virtual void write(Ostream&) const;
318         //- Write dictionary
319         virtual void writeDict(Ostream&) const;
322     // Ostream Operator
324         friend Ostream& operator<<(Ostream&, const faceZone&);
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 } // End namespace Foam
332 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 #endif
336 // ************************************************************************* //