1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
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.
39 \*---------------------------------------------------------------------------*/
44 #include <OpenFOAM/typeInfo.H>
45 #include <OpenFOAM/dictionary.H>
46 #include <OpenFOAM/labelList.H>
47 #include <OpenFOAM/faceZoneMeshFwd.H>
48 #include <OpenFOAM/boolList.H>
49 #include <OpenFOAM/primitiveFacePatch.H>
50 #include <OpenFOAM/Map.H>
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 // Forward declaration of friend functions and operators
62 Ostream& operator<<(Ostream&, const faceZone&);
65 /*---------------------------------------------------------------------------*\
66 Class faceZone Declaration
67 \*---------------------------------------------------------------------------*/
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.
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_;
95 mutable labelList* masterCellsPtr_;
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;
128 void checkAddressing() const;
133 //- Runtime type information
134 TypeName("faceZone");
137 // Declare run-time constructor selection tables
139 declareRunTimeSelectionTable
146 const dictionary& dict,
148 const faceZoneMesh& zm
150 (name, dict, index, zm)
156 //- Construct from components
160 const labelList& addr,
163 const faceZoneMesh& zm
166 //- Construct from components, transferring contents
170 const Xfer<labelList>& addr,
171 const Xfer<boolList>& fm,
176 //- Construct from dictionary
185 //- Construct given the original zone and resetting the
186 // face list and zone mesh information
190 const labelList& addr,
196 //- Construct given the original zone, resetting the
197 // face list and zone mesh information
201 const Xfer<labelList>& addr,
202 const Xfer<boolList>& fm,
207 //- Construct and return a clone, resetting the zone mesh
208 virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
210 return autoPtr<faceZone>
212 new faceZone(*this, *this, flipMap(), index(), zm)
216 //- Construct and return a clone, resetting the face list
218 virtual autoPtr<faceZone> clone
220 const labelList& addr,
223 const faceZoneMesh& zm
226 return autoPtr<faceZone>
228 new faceZone(*this, addr, fm, index, zm)
235 //- Return a pointer to a new face zone
236 // created on freestore from dictionary
237 static autoPtr<faceZone> New
254 const word& name() const
259 //- Return face flip map
260 const boolList& flipMap() const
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
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;
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
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);
316 virtual void write(Ostream&) const;
319 virtual void writeDict(Ostream&) const;
324 friend Ostream& operator<<(Ostream&, const faceZone&);
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 } // End namespace Foam
332 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 // ************************ vim: set sw=4 sts=4 et: ************************ //