PatchTools.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2020-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::PatchTools
29
30Description
31 A collection of tools for searching, sorting PrimitivePatch information.
32
33 The class could also be extended to include more that just static methods.
34
35SourceFiles
36 PatchTools.C
37 PatchToolsCheck.C
38 PatchToolsEdgeOwner.C
39 PatchToolsGatherAndMerge.C
40 PatchToolsMatch.C
41 PatchToolsNormals.C
42 PatchToolsSearch.C
43 PatchToolsSortEdges.C
44 PatchToolsSortPoints.C
45
46\*---------------------------------------------------------------------------*/
47
48#ifndef Foam_PatchTools_H
49#define Foam_PatchTools_H
50
51#include "PrimitivePatch.H"
52#include "globalIndex.H"
53#include "autoPtr.H"
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57namespace Foam
58{
59
60// Forward Declarations
61class polyMesh;
62class bitSet;
63class boundBox;
64
65/*---------------------------------------------------------------------------*\
66 Class PatchTools Declaration
67\*---------------------------------------------------------------------------*/
69class PatchTools
70{
71public:
72
73 //- Check for orientation issues.
74 // Returns true if problems were found.
75 // If a normal flips across an edge, places it in the HashSet
76 template<class FaceList, class PointField>
77 static bool checkOrientation
78 (
80 const bool report = false,
81 labelHashSet* marked = 0
82 );
83
84
85 //- Fill faceZone with currentZone for every face reachable
86 // from facei without crossing edge marked in borderEdge.
87 // Note: faceZone has to be sized nFaces before calling.
88 template<class BoolListType, class FaceList, class PointField>
89 static void markZone
90 (
92 const BoolListType& borderEdge,
93 const label facei,
94 const label currentZone,
96 );
97
98 //- Size and fills faceZone with zone of face.
99 // Zone is area reachable by edge crossing without crossing borderEdge.
100 // Returns number of zones.
101 template<class BoolListType, class FaceList, class PointField>
102 static label markZones
103 (
105 const BoolListType& borderEdge,
107 );
108
109 //- Determine the mapping for a sub-patch.
110 // Only include faces for which bool-list entry is true.
111 // \param[in] p patch to be searched on
112 // \param[in] includeFaces faces to include
113 // \param[out] pointMap mapping new to old localPoints
114 // \param[out] faceMap mapping new to old faces
115 template<class BoolListType, class FaceList, class PointField>
116 static void subsetMap
117 (
119 const BoolListType& includeFaces,
120 labelList& pointMap,
122 );
123
124 //-
125 template<class FaceList, class PointField>
126 static void calcBounds
127 (
129 boundBox& bb,
130 label& nPoints
131 );
132
133 //- Return edge-face addressing sorted by angle around the edge.
134 // Orientation is anticlockwise looking from edge.vec(localPoints())
135 template<class FaceList, class PointField>
137 (
139 );
140
141 //- Return point-edge addressing sorted by order around the point.
142 template<class FaceList, class PointField>
144 (
146 );
147
148 //- If 2 face neighbours: label of face where ordering of edge
149 // is consistent with righthand walk.
150 // If 1 neighbour: label of only face.
151 // If >2 neighbours: undetermined.
152 template<class FaceList, class PointField>
153 static labelList edgeOwner
154 (
156 );
157
158
159 //- Find corresponding points on patches sharing the same points
160 // p1PointLabels : points on p1 that were matched
161 // p2PointLabels : corresponding points on p2
162 template
163 <
164 class FaceList1, class PointField1,
165 class FaceList2, class PointField2
166 >
167 static void matchPoints
168 (
171
172 labelList& p1PointLabels,
173 labelList& p2PointLabels
174 );
175
176 //- Find corresponding edges on patches sharing the same points
177 // p1EdgeLabels : edges on p1 that were matched
178 // p2EdgeLabels : corresponding edges on p2
179 // sameOrientation : same orientation?
180 template
181 <
182 class FaceList1, class PointField1,
183 class FaceList2, class PointField2
184 >
185 static void matchEdges
186 (
189
190 labelList& p1EdgeLabels,
191 labelList& p2EdgeLabels,
192 bitSet& sameOrientation
193 );
194
195
196 //- Return parallel consistent point normals for patches using mesh points.
197 template<class FaceList, class PointField>
199 (
200 const polyMesh&,
202 const bitSet& flipMap = bitSet::null()
203 );
204
205
206 //- Return parallel consistent edge normals for patches using mesh points.
207 // Supply with patch matching info from matchEdges.
208 template<class FaceList, class PointField>
210 (
211 const polyMesh&,
213 const labelList& patchEdges,
214 const labelList& coupledEdges,
215 const bitSet& flipMap = bitSet::null()
216 );
217
218
219 //- Gather points and faces onto master and merge into single patch.
220 // Note: Normally uses faces/points (not localFaces/localPoints)
221 //
222 // \param[in] mergeDist Geometric merge tolerance for Foam::mergePoints
223 // \param[in] pp The patch to merge
224 // \param[out] mergedPoints
225 // \param[out] mergedFaces
226 // \param[out] pointMergeMap
227 // \param[in] useLocal gather/merge patch localFaces/localPoints
228 // instead of faces/points
229 //
230 // \note
231 // - OpenFOAM-v2112 and earlier: geometric merge on all patch points.
232 // - OpenFOAM-v2206 and later: geometric merge on patch boundary points.
233 template<class FaceList, class PointField>
234 static void gatherAndMerge
235 (
236 const scalar mergeDist,
238 Field
239 <
241 >& mergedPoints,
242 List
243 <
245 >& mergedFaces,
246 labelList& pointMergeMap,
247 const bool useLocal = false
248 );
249
250 //- Gather (mesh!) points and faces onto master and merge collocated
251 // points into a single patch. Uses coupled point mesh
252 // structure so does not need tolerances.
253 // On master and slave returns:
254 // - pointToGlobal : for every local point index the global point index
255 // - uniqueMeshPointLabels : my local mesh points
256 // - globalPoints : global numbering for the global points
257 // - globalFaces : global numbering for the faces
258 // On master only:
259 // - mergedFaces : the merged faces
260 // - mergedPoints : the merged points
261 template<class FaceList>
262 static void gatherAndMerge
263 (
264 const polyMesh& mesh,
265 const FaceList& faces,
266 const labelList& meshPoints,
267 const Map<label>& meshPointMap,
268
269 labelList& pointToGlobal,
270 labelList& uniqueMeshPointLabels,
272 autoPtr<globalIndex>& globalFaces,
274 pointField& mergedPoints
275 );
276};
277
278
279// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280
281} // End namespace Foam
282
283// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284
285#ifdef NoRepository
286 #include "PatchTools.C"
287#endif
288
289// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290
291#endif
292
293// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
A collection of tools for searching, sorting PrimitivePatch information.
Definition: PatchTools.H:69
static labelList edgeOwner(const PrimitivePatch< FaceList, PointField > &)
If 2 face neighbours: label of face where ordering of edge.
static void subsetMap(const PrimitivePatch< FaceList, PointField > &p, const BoolListType &includeFaces, labelList &pointMap, labelList &faceMap)
Determine the mapping for a sub-patch.
static tmp< pointField > edgeNormals(const polyMesh &, const PrimitivePatch< FaceList, PointField > &, const labelList &patchEdges, const labelList &coupledEdges, const bitSet &flipMap=bitSet::null())
Return parallel consistent edge normals for patches using mesh points.
static void gatherAndMerge(const scalar mergeDist, const PrimitivePatch< FaceList, PointField > &pp, Field< typename PrimitivePatch< FaceList, PointField >::point_type > &mergedPoints, List< typename PrimitivePatch< FaceList, PointField >::face_type > &mergedFaces, labelList &pointMergeMap, const bool useLocal=false)
Gather points and faces onto master and merge into single patch.
static void matchEdges(const PrimitivePatch< FaceList1, PointField1 > &p1, const PrimitivePatch< FaceList2, PointField2 > &p2, labelList &p1EdgeLabels, labelList &p2EdgeLabels, bitSet &sameOrientation)
Find corresponding edges on patches sharing the same points.
static void markZone(const PrimitivePatch< FaceList, PointField > &, const BoolListType &borderEdge, const label facei, const label currentZone, labelList &faceZone)
Fill faceZone with currentZone for every face reachable.
static labelListList sortedPointEdges(const PrimitivePatch< FaceList, PointField > &)
Return point-edge addressing sorted by order around the point.
static labelListList sortedEdgeFaces(const PrimitivePatch< FaceList, PointField > &)
Return edge-face addressing sorted by angle around the edge.
static bool checkOrientation(const PrimitivePatch< FaceList, PointField > &, const bool report=false, labelHashSet *marked=0)
Check for orientation issues.
static void matchPoints(const PrimitivePatch< FaceList1, PointField1 > &p1, const PrimitivePatch< FaceList2, PointField2 > &p2, labelList &p1PointLabels, labelList &p2PointLabels)
Find corresponding points on patches sharing the same points.
static label markZones(const PrimitivePatch< FaceList, PointField > &, const BoolListType &borderEdge, labelList &faceZone)
Size and fills faceZone with zone of face.
static void calcBounds(const PrimitivePatch< FaceList, PointField > &p, boundBox &bb, label &nPoints)
static tmp< pointField > pointNormals(const polyMesh &, const PrimitivePatch< FaceList, PointField > &, const bitSet &flipMap=bitSet::null())
Return parallel consistent point normals for patches using mesh points.
A list of faces which address into the list of points.
std::remove_reference< PointField >::type::value_type point_type
The point type.
std::remove_reference< FaceList >::type::value_type face_type
The face type.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:67
Calculates points shared by more than two processor patches or cyclic patches.
Definition: globalPoints.H:103
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for managing temporary objects.
Definition: tmp.H:65
volScalarField & p
dynamicFvMesh & mesh
label nPoints
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)