1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, 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 "faceZoneMeshFwd.H"
46 #include "primitiveFacePatch.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 // Forward declaration of friend functions and operators
58 Ostream& operator<<(Ostream&, const faceZone&);
61 /*---------------------------------------------------------------------------*\
62 Class faceZone Declaration
63 \*---------------------------------------------------------------------------*/
71 //- The name associated with the zone-labels dictionary entry
72 static const word labelsName_;
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.
82 //- Reference to zone list
83 const faceZoneMesh& zoneMesh_;
86 // Demand-driven private data
88 //- Primitive patch made out of correctly flipped faces
89 mutable primitiveFacePatch* patchPtr_;
92 mutable labelList* masterCellsPtr_;
95 mutable labelList* slaveCellsPtr_;
97 //- Global edge addressing
98 mutable labelList* mePtr_;
101 // Private Member Functions
103 //- Disallow default bitwise copy construct
104 faceZone(const faceZone&);
106 //- Disallow default bitwise assignment
107 void operator=(const faceZone&);
109 //- Build primitive patch
110 void calcFaceZonePatch() const;
112 //- Return map of local face indices
113 const Map<label>& faceLookupMap() const;
115 //- Calculate master and slave face layer
116 void calcCellLayers() const;
119 void checkAddressing() const;
124 // Static data members
126 //- The name associated with the zone-labels dictionary entry
127 static const char * const labelsName;
130 //- Runtime type information
131 TypeName("faceZone");
134 // Declare run-time constructor selection tables
136 declareRunTimeSelectionTable
143 const dictionary& dict,
145 const faceZoneMesh& zm
147 (name, dict, index, zm)
153 //- Construct from components
157 const labelUList& addr,
160 const faceZoneMesh& zm
163 //- Construct from components, transferring contents
167 const Xfer<labelList>& addr,
168 const Xfer<boolList>& fm,
173 //- Construct from dictionary
182 //- Construct given the original zone and resetting the
183 // face list and zone mesh information
187 const labelUList& addr,
193 //- Construct given the original zone, resetting the
194 // face list and zone mesh information
198 const Xfer<labelList>& addr,
199 const Xfer<boolList>& fm,
204 //- Construct and return a clone, resetting the zone mesh
205 virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
207 return autoPtr<faceZone>
209 new faceZone(*this, *this, flipMap(), index(), zm)
213 //- Construct and return a clone, resetting the face list
215 virtual autoPtr<faceZone> clone
217 const labelUList& addr,
220 const faceZoneMesh& zm
223 return autoPtr<faceZone>
225 new faceZone(*this, addr, fm, index, zm)
232 //- Return a pointer to a new face zone
233 // created on freestore from dictionary
234 static autoPtr<faceZone> New
249 //- Return face flip map
250 const boolList& flipMap() const
255 //- Helper function to re-direct to zone::localID(...)
256 label whichFace(const label globalCellID) const;
258 //- Return reference to primitive patch
259 const primitiveFacePatch& operator()() const;
261 //- Return zoneMesh reference
262 const faceZoneMesh& zoneMesh() const;
265 // Addressing into mesh
267 //- Return labels of master cells (cells next to the master face
268 // zone in the prescribed direction)
269 const labelList& masterCells() const;
271 //- Return labels of slave cells
272 const labelList& slaveCells() const;
274 //- Return global edge index for local edges
275 const labelList& meshEdges() const;
279 virtual void clearAddressing();
281 //- Reset addressing and flip map (clearing demand-driven data)
282 virtual void resetAddressing(const labelUList&, const boolList&);
284 //- Check zone definition. Return true if in error.
285 virtual bool checkDefinition(const bool report = false) const;
287 //- Check whether all procs have faces synchronised. Return
289 virtual bool checkParallelSync(const bool report = false) const;
291 //- Correct patch after moving points
292 virtual void movePoints(const pointField&);
294 //- Update for changes in topology
295 virtual void updateMesh(const mapPolyMesh&);
298 virtual void write(Ostream&) const;
301 virtual void writeDict(Ostream&) const;
306 friend Ostream& operator<<(Ostream&, const faceZone&);
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 } // End namespace Foam
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 // ************************************************************************* //