1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 A subset of mesh faces organised as a primitive patch.
30 For quick check whether a face belongs to the zone use the lookup
31 mechanism in faceZoneMesh, where all the zoned faces are registered
32 with their zone number.
38 \*---------------------------------------------------------------------------*/
44 #include "dictionary.H"
45 #include "labelList.H"
46 #include "faceZoneMeshFwd.H"
48 #include "primitiveFacePatch.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 // Forward declaration of friend functions and operators
61 Ostream& operator<<(Ostream&, const faceZone&);
64 /*---------------------------------------------------------------------------*\
65 Class faceZone Declaration
66 \*---------------------------------------------------------------------------*/
77 //- Flip map for all faces in the zone. Set to true if the
78 // face needs to be flipped to achieve the correct orientation.
84 //- Reference to zone list
85 const faceZoneMesh& zoneMesh_;
88 // Demand-driven private data
90 //- Primitive patch made out of correctly flipped faces
91 mutable primitiveFacePatch* patchPtr_;
94 mutable labelList* masterCellsPtr_;
97 mutable labelList* slaveCellsPtr_;
99 //- Global edge addressing
100 mutable labelList* mePtr_;
102 //- Map of face labels in zone for fast location lookup
103 mutable Map<label>* faceLookupMapPtr_;
106 // Private Member Functions
108 //- Disallow default bitwise copy construct
109 faceZone(const faceZone&);
111 //- Disallow default bitwise assignment
112 void operator=(const faceZone&);
114 //- Build primitive patch
115 void calcFaceZonePatch() const;
117 //- Return map of local face indices
118 const Map<label>& faceLookupMap() const;
120 //- Build map of local face indices
121 void calcFaceLookupMap() const;
123 //- Calculate master and slave face layer
124 void calcCellLayers() const;
127 void checkAddressing() const;
132 //- Runtime type information
133 TypeName("faceZone");
136 // Declare run-time constructor selection tables
138 declareRunTimeSelectionTable
145 const dictionary& dict,
147 const faceZoneMesh& zm
149 (name, dict, index, zm)
155 //- Construct from components
159 const labelList& addr,
162 const faceZoneMesh& zm
165 //- Construct from components, transferring contents
169 const Xfer<labelList>& addr,
170 const Xfer<boolList>& fm,
175 //- Construct from dictionary
184 //- Construct given the original zone and resetting the
185 // face list and zone mesh information
189 const labelList& addr,
195 //- Construct given the original zone, resetting the
196 // face list and zone mesh information
200 const Xfer<labelList>& addr,
201 const Xfer<boolList>& fm,
206 //- Construct and return a clone, resetting the zone mesh
207 virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
209 return autoPtr<faceZone>
211 new faceZone(*this, *this, flipMap(), index(), zm)
215 //- Construct and return a clone, resetting the face list
217 virtual autoPtr<faceZone> clone
219 const labelList& addr,
222 const faceZoneMesh& zm
225 return autoPtr<faceZone>
227 new faceZone(*this, addr, fm, index, zm)
234 //- Return a pointer to a new face zone
235 // created on freestore from dictionary
236 static autoPtr<faceZone> New
253 const word& name() const
258 //- Return face flip map
259 const boolList& flipMap() const
264 //- Map storing the local face index for every global face index.
265 // Used to find out the index of face in the zone from the known
266 // global face index. If the face is not in the zone, returns -1
267 label whichFace(const label globalFaceID) const;
269 //- Return reference to primitive patch
270 const primitiveFacePatch& operator()() const;
272 //- Return the index of this zone in zone list
278 //- Return zoneMesh reference
279 const faceZoneMesh& zoneMesh() const;
282 // Addressing into mesh
284 //- Return labels of master cells (cells next to the master face
285 // zone in the prescribed direction)
286 const labelList& masterCells() const;
288 //- Return labels of slave cells
289 const labelList& slaveCells() const;
291 //- Return global edge index for local edges
292 const labelList& meshEdges() const;
296 void clearAddressing();
298 //- Reset addressing and flip map (clearing demand-driven data)
299 void resetAddressing(const labelList&, const boolList&);
301 //- Check zone definition. Return true if in error.
302 bool checkDefinition(const bool report = false) const;
304 //- Check whether all procs have faces synchronised. Return
306 bool checkParallelSync(const bool report = false) const;
308 //- Correct patch after moving points
309 virtual void movePoints(const pointField&);
311 //- Update for changes in topology Note: Zone has been rebuilt
312 // and no mapping is required. HJ, 1/Mar/2009
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 // ************************************************************************* //