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 list of faces which address into the list of points.
30 The class is templated on the face type (e.g. triangle, polygon etc.)
31 and on the list type of faces and points so that it can refer to
32 existing lists using UList and const pointField& or hold the storage
33 using List and pointField.
36 PrimitivePatchAddressing.C
37 PrimitivePatchBdryPoints.C
41 PrimitivePatchEdgeLoops.C
42 PrimitivePatchLocalPointOrder.C
43 PrimitivePatchMeshData.C
44 PrimitivePatchMeshEdges.C
46 PrimitivePatchPointAddressing.C
47 PrimitivePatchProjectPoints.C
49 \*---------------------------------------------------------------------------*/
51 #ifndef PrimitivePatch_H
52 #define PrimitivePatch_H
55 #include "labelList.H"
58 #include "intersection.H"
60 #include "objectHit.H"
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 template<class T> class Map;
70 /*---------------------------------------------------------------------------*\
71 Class PrimitivePatchName Declaration
72 \*---------------------------------------------------------------------------*/
74 TemplateName(PrimitivePatch);
77 /*---------------------------------------------------------------------------*\
78 Class PrimitivePatch Declaration
79 \*---------------------------------------------------------------------------*/
84 template<class> class FaceList,
90 public PrimitivePatchName,
98 typedef Face FaceType;
99 typedef FaceList<Face> FaceListType;
100 typedef PointField PointFieldType;
105 //- Enumeration defining the surface type. Used in check routines.
117 //- Reference to global list of points
121 // Demand driven private data
123 //- Edges of the patch; address into local point list;
124 // sorted with internal edges first in upper-triangular order
125 // and external edges last.
126 mutable edgeList* edgesPtr_;
128 //- Which part of edgesPtr_ is internal edges.
129 mutable label nInternalEdges_;
131 //- Boundary point labels, addressing into local point list
132 mutable labelList* boundaryPointsPtr_;
134 //- Face-face addressing
135 mutable labelListList* faceFacesPtr_;
137 //- Edge-face addressing
138 mutable labelListList* edgeFacesPtr_;
140 //- Face-edge addressing
141 mutable labelListList* faceEdgesPtr_;
143 //- Point-edge addressing
144 mutable labelListList* pointEdgesPtr_;
146 //- Point-face addressing
147 mutable labelListList* pointFacesPtr_;
149 //- Faces addressing into local point list
150 mutable List<Face>* localFacesPtr_;
152 //- Labels of mesh points
153 mutable labelList* meshPointsPtr_;
155 //- Mesh point map. Given the global point index find its
156 //location in the patch
157 mutable Map<label>* meshPointMapPtr_;
159 //- Outside edge loops
160 mutable labelListList* edgeLoopsPtr_;
162 //- Points local to patch
163 mutable Field<PointType>* localPointsPtr_;
165 //- Local point order for most efficient search
166 mutable labelList* localPointOrderPtr_;
169 mutable Field<PointType>* faceCentresPtr_;
171 //- Face unit normals
172 mutable Field<PointType>* faceNormalsPtr_;
174 //- Point unit normals
175 mutable Field<PointType>* pointNormalsPtr_;
178 // Private Member Functions
180 //- Calculate edges of the patch
181 void calcIntBdryEdges() const;
183 //- Calculated boundary points on a patch
184 void calcBdryPoints() const;
186 //- Calculate addressing
187 void calcAddressing() const;
189 //- Calculate point-edge addressing
190 void calcPointEdges() const;
192 //- Calculate point-face addressing
193 void calcPointFaces() const;
195 //- Calculate mesh addressing
196 void calcMeshData() const;
198 //- Calculate mesh point map
199 void calcMeshPointMap() const;
201 //- Calculate outside edge loops
202 void calcEdgeLoops() const;
204 //- Calculate local points
205 void calcLocalPoints() const;
207 //- Calculate local point order
208 void calcLocalPointOrder() const;
210 //- Calculate face centres
211 void calcFaceCentres() const;
213 //- Calculate unit face normals
214 void calcFaceNormals() const;
216 //- Calculate unit point normals
217 void calcPointNormals() const;
219 //- Calculate edge owner
220 void calcEdgeOwner() const;
223 //- Face-edge-face walk while remaining on a patch point.
224 // Used to determine if surface multiply connected through point.
225 void visitPointRegion
228 const labelList& pFaces,
229 const label startFaceI,
230 const label startEdgeI,
239 //- Construct from components
242 const FaceList<Face>& faces,
243 const Field<PointType>& points
246 //- Construct from components, reuse storage
249 FaceList<Face>& faces,
250 Field<PointType>& points,
254 //- Construct as copy
257 const PrimitivePatch<Face, FaceList, PointField, PointType>&
262 virtual ~PrimitivePatch();
268 void clearTopology();
270 void clearPatchMeshAddr();
277 //- Return reference to global points
278 const Field<PointType>& points() const
284 // Access functions for demand driven data
286 // Topological data; no mesh required.
288 //- Return number of points supporting patch faces
289 label nPoints() const
291 return meshPoints().size();
294 //- Return number of edges in patch
297 return edges().size();
300 //- Return list of edges, address into LOCAL point list
301 const edgeList& edges() const;
303 //- Number of internal edges
304 label nInternalEdges() const;
306 //- Is internal edge?
307 bool isInternalEdge(const label edgeI) const
309 return edgeI < nInternalEdges();
312 //- Return list of boundary points,
313 // address into LOCAL point list
314 const labelList& boundaryPoints() const;
316 //- Return face-face addressing
317 const labelListList& faceFaces() const;
319 //- Return edge-face addressing
320 const labelListList& edgeFaces() const;
322 //- Return face-edge addressing
323 const labelListList& faceEdges() const;
325 //- Return point-edge addressing
326 const labelListList& pointEdges() const;
328 //- Return point-face addressing
329 const labelListList& pointFaces() const;
331 //- Return patch faces addressing into local point list
332 const List<Face>& localFaces() const;
335 // Addressing into mesh
337 //- Return labelList of mesh points in patch. They are constructed
338 // walking through the faces in incremental order and not sorted
340 const labelList& meshPoints() const;
342 //- Mesh point map. Given the global point index find its
343 // location in the patch
344 const Map<label>& meshPointMap() const;
346 //- Return pointField of points in patch
347 const Field<PointType>& localPoints() const;
349 //- Return orders the local points for most efficient search
350 const labelList& localPointOrder() const;
352 //- Given a global point index, return the local point index.
353 // If the point is not found, return -1
354 label whichPoint(const label gp) const;
356 //- Given an edge in local point labels, return its
357 // index in the edge list. If the edge is not found, return -1
358 label whichEdge(const edge&) const;
360 //- Return labels of patch edges in the global edge list using
364 const edgeList& allEdges,
365 const labelListList& cellEdges,
366 const labelList& faceCells
369 //- Return labels of patch edges in the global edge list using
370 // basic edge addressing.
373 const edgeList& allEdges,
374 const labelListList& pointEdges
377 //- Return face centres for patch
378 const Field<PointType>& faceCentres() const;
380 //- Return face normals for patch
381 const Field<PointType>& faceNormals() const;
383 //- Return point normals for patch
384 const Field<PointType>& pointNormals() const;
387 // Other patch operations
389 //- Project vertices of patch onto another patch
390 template <class ToPatch>
391 List<objectHit> projectPoints
393 const ToPatch& targetPatch,
394 const Field<PointType>& projectionDirection,
395 const intersection::algorithm = intersection::FULL_RAY,
396 const intersection::direction = intersection::VECTOR
399 //- Project vertices of patch onto another patch
400 template <class ToPatch>
401 List<objectHit> projectFaceCentres
403 const ToPatch& targetPatch,
404 const Field<PointType>& projectionDirection,
405 const intersection::algorithm = intersection::FULL_RAY,
406 const intersection::direction = intersection::VECTOR
409 //- Return list of closed loops of boundary vertices.
410 // Edge loops are given as ordered lists of vertices
411 // in local addressing
412 const labelListList& edgeLoops() const;
417 //- Calculate surface type formed by patch.
419 // - all edges have two neighbours (manifold)
420 // - some edges have more than two neighbours (illegal)
422 surfaceTopo surfaceType() const;
424 //- Check surface formed by patch for manifoldness (see above).
425 // Return true if any incorrect edges are found.
426 // Insert vertices of incorrect edges into set.
429 const bool report = false,
430 labelHashSet* setPtr = NULL
433 //- Checks primitivePatch for faces sharing point but not edge.
434 // This denotes a surface that is pinched at a single point
435 // (test for pinched at single edge is already in PrimitivePatch)
436 // Returns true if this situation found and puts conflicting
437 // (mesh)point in set. Based on all the checking routines in
439 bool checkPointManifold
441 const bool report = false,
442 labelHashSet* setPtr = NULL
448 //- Correct patch after moving points
449 virtual void movePoints(const Field<PointType>&);
457 const PrimitivePatch<Face, FaceList, PointField, PointType>&
462 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
464 } // End namespace Foam
466 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
469 # include "PrimitivePatch.C"
472 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
476 // ************************************************************************* //