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 | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::PatchTools
26 
27 Description
28  A collection of tools for searching, sorting PrimitivePatch information.
29 
30  The class could also be extended to include more that just static methods.
31 
32 SourceFiles
33  PatchTools.C
34  PatchToolsCheck.C
35  PatchToolsEdgeOwner.C
36  PatchToolsGatherAndMerge.C
37  PatchToolsMatch.C
38  PatchToolsNormals.C
39  PatchToolsSearch.C
40  PatchToolsSortEdges.C
41  PatchToolsSortPoints.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef PatchTools_H
46 #define PatchTools_H
47 
48 #include "PrimitivePatch.H"
49 #include "HashSet.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 class polyMesh;
57 class PackedBoolList;
58 class boundBox;
59 
60 /*---------------------------------------------------------------------------*\
61  Class PatchTools Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class PatchTools
65 {
66 public:
67 
68  //- Check for orientation issues.
69  // Returns true if problems were found.
70  // If a normal flips across an edge, places it in the HashSet
71  template
72  <
73  class Face,
74  template<class> class FaceList,
75  class PointField,
76  class PointType
77  >
78  static bool checkOrientation
79  (
80  const PrimitivePatch<Face, FaceList, PointField, PointType>&,
81  const bool report = false,
82  labelHashSet* marked = 0
83  );
84 
85 
86  //- Fill faceZone with currentZone for every face reachable
87  // from faceI without crossing edge marked in borderEdge.
88  // Note: faceZone has to be sized nFaces before calling.
89  template
90  <
91  class BoolListType,
92  class Face,
93  template<class> class FaceList,
94  class PointField,
95  class PointType
96  >
97  static void markZone
98  (
99  const PrimitivePatch<Face, FaceList, PointField, PointType>&,
100  const BoolListType& borderEdge,
101  const label faceI,
102  const label currentZone,
103  labelList& faceZone
104  );
105 
106  //- Size and fills faceZone with zone of face.
107  // Zone is area reachable by edge crossing without crossing borderEdge.
108  // Returns number of zones.
109  template
110  <
111  class BoolListType,
112  class Face,
113  template<class> class FaceList,
114  class PointField,
115  class PointType
116  >
117  static label markZones
118  (
119  const PrimitivePatch<Face, FaceList, PointField, PointType>&,
120  const BoolListType& borderEdge,
121  labelList& faceZone
122  );
123 
124  //- Determine the mapping for a sub-patch.
125  // Only include faces for which bool-list entry is true.
126  // \param[in] includeFaces faces to include
127  // \param[out] pointMap mapping new to old localPoints
128  // \param[out] faceMap mapping new to old faces
129  template
130  <
131  class BoolListType,
132  class Face,
133  template<class> class FaceList,
134  class PointField,
135  class PointType
136  >
137  static void subsetMap
138  (
139  const PrimitivePatch<Face, FaceList, PointField, PointType>&,
140  const BoolListType& includeFaces,
141  labelList& pointMap,
143  );
144 
145  //-
146  template
147  <
148  class Face,
149  template<class> class FaceList,
150  class PointField,
151  class PointType
152  >
153  static void calcBounds
154  (
155  const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
156  boundBox& bb,
157  label& nPoints
158  );
159 
160  //- Return edge-face addressing sorted by angle around the edge.
161  // Orientation is anticlockwise looking from edge.vec(localPoints())
162  template
163  <
164  class Face,
165  template<class> class FaceList,
166  class PointField,
167  class PointType
168  >
170  (
171  const PrimitivePatch<Face, FaceList, PointField, PointType>&
172  );
173 
174  //- Return point-edge addressing sorted by order around the point.
175  template
176  <
177  class Face,
178  template<class> class FaceList,
179  class PointField,
180  class PointType
181  >
183  (
184  const PrimitivePatch<Face, FaceList, PointField, PointType>&
185  );
186 
187  //- If 2 face neighbours: label of face where ordering of edge
188  // is consistent with righthand walk.
189  // If 1 neighbour: label of only face.
190  // If >2 neighbours: undetermined.
191  template
192  <
193  class Face,
194  template<class> class FaceList,
195  class PointField,
196  class PointType
197  >
198  static labelList edgeOwner
199  (
200  const PrimitivePatch<Face, FaceList, PointField, PointType>&
201  );
202 
203 
204  //- Find corresponding points on patches sharing the same points
205  // p1PointLabels : points on p1 that were matched
206  // p2PointLabels : corresponding points on p2
207  template
208  <
209  class Face1,
210  template<class> class FaceList1,
211  class PointField1,
212  class PointType1,
213  class Face2,
214  template<class> class FaceList2,
215  class PointField2,
216  class PointType2
217  >
218  static void matchPoints
219  (
220  const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
221  const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
222 
223  labelList& p1PointLabels,
224  labelList& p2PointLabels
225  );
226 
227  //- Find corresponding edges on patches sharing the same points
228  // p1EdgeLabels : edges on p1 that were matched
229  // p2EdgeLabels : corresponding edges on p2
230  // sameOrientation : same orientation?
231  template
232  <
233  class Face1,
234  template<class> class FaceList1,
235  class PointField1,
236  class PointType1,
237  class Face2,
238  template<class> class FaceList2,
239  class PointField2,
240  class PointType2
241  >
242  static void matchEdges
243  (
244  const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
245  const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
246 
247  labelList& p1EdgeLabels,
248  labelList& p2EdgeLabels,
249  PackedBoolList& sameOrientation
250  );
251 
252 
253  //- Return parallel consistent point normals for patches using mesh points.
254  template
255  <
256  class Face,
257  template<class> class FaceList,
258  class PointField,
259  class PointType
260  >
261  static tmp<pointField> pointNormals
262  (
263  const polyMesh&,
264  const PrimitivePatch<Face, FaceList, PointField, PointType>&
265  );
266 
267 
268  //- Return parallel consistent edge normals for patches using mesh points.
269  // Supply with patch matching info from matchEdges.
270  template
271  <
272  class Face,
273  template<class> class FaceList,
274  class PointField,
275  class PointType
276  >
277  static tmp<pointField> edgeNormals
278  (
279  const polyMesh&,
280  const PrimitivePatch<Face, FaceList, PointField, PointType>&,
281  const labelList& patchEdges,
282  const labelList& coupledEdges
283  );
284 
285 
286  //- Gather points and faces onto master and merge into single patch.
287  // Note: uses faces/points, not localFaces/localPoints.
288  template
289  <
290  class Face,
291  template<class> class FaceList,
292  class PointField,
293  class PointType
294  >
295  static void gatherAndMerge
296  (
297  const scalar mergeDist,
298  const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
299  Field<PointType>& mergedPoints,
300  List<Face>& mergedFaces,
301  labelList& pointMergeMap
302  );
303 };
304 
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 } // End namespace Foam
309 
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 #ifdef NoRepository
313 # include "PatchTools.C"
314 #endif
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 #endif
319 
320 // ************************************************************************* //
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
p
p
Definition: pEqn.H:62
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
Foam::PatchTools::calcBounds
static void calcBounds(const PrimitivePatch< Face, FaceList, PointField, PointType > &p, boundBox &bb, label &nPoints)
Definition: PatchToolsSearch.C:224
Foam::PatchTools::matchPoints
static void matchPoints(const PrimitivePatch< Face1, FaceList1, PointField1, PointType1 > &p1, const PrimitivePatch< Face2, FaceList2, PointField2, PointType2 > &p2, labelList &p1PointLabels, labelList &p2PointLabels)
Find corresponding points on patches sharing the same points.
Definition: PatchToolsMatch.C:42
Foam::PatchTools::subsetMap
static void subsetMap(const PrimitivePatch< Face, FaceList, PointField, PointType > &, const BoolListType &includeFaces, labelList &pointMap, labelList &faceMap)
Determine the mapping for a sub-patch.
Definition: PatchToolsSearch.C:173
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
PrimitivePatch.H
Foam::PatchTools::markZone
static void markZone(const PrimitivePatch< Face, FaceList, PointField, PointType > &, const BoolListType &borderEdge, const label faceI, const label currentZone, labelList &faceZone)
Fill faceZone with currentZone for every face reachable.
Definition: PatchToolsSearch.C:46
HashSet.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::PatchTools::sortedEdgeFaces
static labelListList sortedEdgeFaces(const PrimitivePatch< Face, FaceList, PointField, PointType > &)
Return edge-face addressing sorted by angle around the edge.
Foam::PatchTools::sortedPointEdges
static labelListList sortedPointEdges(const PrimitivePatch< Face, FaceList, PointField, PointType > &)
Return point-edge addressing sorted by order around the point.
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
Foam::PatchTools::pointNormals
static tmp< pointField > pointNormals(const polyMesh &, const PrimitivePatch< Face, FaceList, PointField, PointType > &)
Return parallel consistent point normals for patches using mesh points.
Foam::PatchTools::edgeOwner
static labelList edgeOwner(const PrimitivePatch< Face, FaceList, PointField, PointType > &)
If 2 face neighbours: label of face where ordering of edge.
Foam::PatchTools::markZones
static label markZones(const PrimitivePatch< Face, FaceList, PointField, PointType > &, const BoolListType &borderEdge, labelList &faceZone)
Size and fills faceZone with zone of face.
List
Definition: Test.C:19
Foam::PatchTools::gatherAndMerge
static void gatherAndMerge(const scalar mergeDist, const PrimitivePatch< Face, FaceList, PointField, PointType > &p, Field< PointType > &mergedPoints, List< Face > &mergedFaces, labelList &pointMergeMap)
Gather points and faces onto master and merge into single patch.
Definition: PatchToolsGatherAndMerge.C:43
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
Definition: HashSet.H:210
Foam::PatchTools::edgeNormals
static tmp< pointField > edgeNormals(const polyMesh &, const PrimitivePatch< Face, FaceList, PointField, PointType > &, const labelList &patchEdges, const labelList &coupledEdges)
Return parallel consistent edge normals for patches using mesh points.
Foam::PatchTools::checkOrientation
static bool checkOrientation(const PrimitivePatch< Face, FaceList, PointField, PointType > &, const bool report=false, labelHashSet *marked=0)
Check for orientation issues.
Definition: PatchToolsCheck.C:40
Foam::PatchTools::matchEdges
static void matchEdges(const PrimitivePatch< Face1, FaceList1, PointField1, PointType1 > &p1, const PrimitivePatch< Face2, FaceList2, PointField2, PointType2 > &p2, labelList &p1EdgeLabels, labelList &p2EdgeLabels, PackedBoolList &sameOrientation)
Find corresponding edges on patches sharing the same points.
Definition: PatchToolsMatch.C:88