1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 \*---------------------------------------------------------------------------*/
45 #include "dictionary.H"
46 #include "labelList.H"
47 #include "faceZoneMeshFwd.H"
49 #include "primitiveFacePatch.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 dictionary
170 const dictionary& dict,
172 const faceZoneMesh& zm
175 //- Construct given the original zone and resetting the
176 // face list and zone mesh information
180 const labelList& addr,
183 const faceZoneMesh& zm
186 //- Construct and return a clone, resetting the zone mesh
187 virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
189 return autoPtr<faceZone>
191 new faceZone(*this, *this, flipMap(), index(), zm)
195 //- Construct and return a clone, resetting the face list
197 virtual autoPtr<faceZone> clone
199 const labelList& addr,
202 const faceZoneMesh& zm
205 return autoPtr<faceZone>
207 new faceZone(*this, addr, fm, index, zm)
214 //- Return a pointer to a new face zone
215 // created on freestore from dictionary
216 static autoPtr<faceZone> New
219 const dictionary& dict,
221 const faceZoneMesh& zm
233 const word& name() const
238 //- Return face flip map
239 const boolList& flipMap() const
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
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;
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);
291 virtual void write(Ostream&) const;
294 virtual void writeDict(Ostream&) const;
299 friend Ostream& operator<<(Ostream&, const faceZone&);
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 } // End namespace Foam
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 // ************************************************************************* //