initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / meshes / polyMesh / zones / faceZone / faceZone.H
blobc299361cf69b9827aacdb6629f370d1be2b12fe9
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::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 dictionary
167         faceZone
168         (
169             const word& name,
170             const dictionary& dict,
171             const label index,
172             const faceZoneMesh& zm
173         );
175         //- Construct given the original zone and resetting the
176         //  face list and zone mesh information
177         faceZone
178         (
179             const faceZone& fz,
180             const labelList& addr,
181             const boolList& fm,
182             const label index,
183             const faceZoneMesh& zm
184         );
186         //- Construct and return a clone, resetting the zone mesh
187         virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
188         {
189             return autoPtr<faceZone>
190             (
191                 new faceZone(*this, *this, flipMap(), index(), zm)
192             );
193         }
195         //- Construct and return a clone, resetting the face list
196         //  and zone mesh
197         virtual autoPtr<faceZone> clone
198         (
199             const labelList& addr,
200             const boolList& fm,
201             const label index,
202             const faceZoneMesh& zm
203         ) const
204         {
205             return autoPtr<faceZone>
206             (
207                 new faceZone(*this, addr, fm, index, zm)
208             );
209         }
212     // Selectors
214         //- Return a pointer to a new face zone
215         //  created on freestore from dictionary
216         static autoPtr<faceZone> New
217         (
218             const word& name,
219             const dictionary& dict,
220             const label index,
221             const faceZoneMesh& zm
222         );
225     //- Destructor
227         virtual ~faceZone();
230     // Member Functions
232         //- Return name
233         const word& name() const
234         {
235             return name_;
236         }
238         //- Return face flip map
239         const boolList& flipMap() const
240         {
241             return flipMap_;
242         }
244         //- Map storing the local face index for every global face index.
245         //  Used to find out the index of face in the zone from the known global
246         //  face index.  If the face is not in the zone, returns -1
247         label whichFace(const label globalFaceID) const;
249         //- Return reference to primitive patch
250         const primitiveFacePatch& operator()() const;
252         //- Return the index of this zone in zone list
253         label index() const
254         {
255             return index_;
256         }
258         //- Return zoneMesh reference
259         const faceZoneMesh& zoneMesh() const;
262         // Addressing into mesh
264             //- Return labels of master cells (cells next to the master face
265             //  zone in the prescribed direction)
266             const labelList& masterCells() const;
268             //- Return labels of slave cells
269             const labelList& slaveCells() const;
271             //- Return global edge index for local edges
272             const labelList& meshEdges() const;
275         //- Clear addressing
276         void clearAddressing();
278         //- Reset addressing and flip map (clearing demand-driven data)
279         void resetAddressing(const labelList&, const boolList&);
281         //- Check zone definition. Return true if in error.
282         bool checkDefinition(const bool report = false) const;
284         //- Correct patch after moving points
285         virtual void movePoints(const pointField&);
287         //- Update for changes in topology
288         void updateMesh(const mapPolyMesh& mpm);
290         //- Write
291         virtual void write(Ostream&) const;
293         //- Write dictionary
294         virtual void writeDict(Ostream&) const;
297     // Ostream Operator
299         friend Ostream& operator<<(Ostream&, const faceZone&);
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 } // End namespace Foam
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 #endif
311 // ************************************************************************* //