Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / foam / meshes / primitiveMesh / PatchTools / PatchTools.H
blob8475b25a71e4fef0a94f3e79845d88675959bc4a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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/>.
24 Class
25     Foam::PatchTools
27 Description
28     A collection of tools for searching, sorting PrimitivePatch information.
30     The class could also be extended to include more that just static methods.
32 SourceFiles
33     PatchTools.C
34     PatchToolsCheck.C
35     PatchToolsEdgeOwner.C
36     PatchToolsSearch.C
37     PatchToolsSortEdges.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef PatchTools_H
42 #define PatchTools_H
44 #include "PrimitivePatchTemplate.H"
45 #include "HashSet.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 /*---------------------------------------------------------------------------*\
53                          Class PatchTools Declaration
54 \*---------------------------------------------------------------------------*/
56 class PatchTools
58 public:
60     //- Check for orientation issues.
61     //  Returns true if problems were found.
62     //  If a normal flips across an edge, places it in the HashSet
63     template
64     <
65         class Face,
66         template<class> class FaceList,
67         class PointField,
68         class PointType
69     >
70     static bool checkOrientation
71     (
72         const PrimitivePatch<Face, FaceList, PointField, PointType>&,
73         const bool report = false,
74         labelHashSet* marked = 0
75     );
78     //- Fill faceZone with currentZone for every face reachable
79     //  from faceI without crossing edge marked in borderEdge.
80     //  Note: faceZone has to be sized nFaces before calling.
81     template
82     <
83         class BoolListType,
84         class Face,
85         template<class> class FaceList,
86         class PointField,
87         class PointType
88     >
89     static void markZone
90     (
91         const PrimitivePatch<Face, FaceList, PointField, PointType>&,
92         const BoolListType& borderEdge,
93         const label faceI,
94         const label currentZone,
95         labelList& faceZone
96     );
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
102     <
103         class BoolListType,
104         class Face,
105         template<class> class FaceList,
106         class PointField,
107         class PointType
108     >
109     static label markZones
110     (
111         const PrimitivePatch<Face, FaceList, PointField, PointType>&,
112         const BoolListType& borderEdge,
113         labelList& faceZone
114     );
116     //- Determine the mapping for a sub-patch.
117     //  Only include faces for which bool-list entry is true.
118     //  @param[in]  includeFaces faces to include
119     //  @param[out] pointMap mapping new to old localPoints
120     //  @param[out] faceMap  mapping new to old faces
121     template
122     <
123         class BoolListType,
124         class Face,
125         template<class> class FaceList,
126         class PointField,
127         class PointType
128     >
129     static void subsetMap
130     (
131         const PrimitivePatch<Face, FaceList, PointField, PointType>&,
132         const BoolListType& includeFaces,
133         labelList& pointMap,
134         labelList& faceMap
135     );
137     //- Return edge-face addressing sorted by angle around the edge.
138     //  Orientation is anticlockwise looking from edge.vec(localPoints())
139     template
140     <
141         class Face,
142         template<class> class FaceList,
143         class PointField,
144         class PointType
145     >
146     static labelListList sortedEdgeFaces
147     (
148         const PrimitivePatch<Face, FaceList, PointField, PointType>&
149     );
152     //- If 2 face neighbours: label of face where ordering of edge
153     //  is consistent with righthand walk.
154     //  If 1 neighbour: label of only face.
155     //  If >2 neighbours: undetermined.
156     template
157     <
158         class Face,
159         template<class> class FaceList,
160         class PointField,
161         class PointType
162     >
163     static labelList edgeOwner
164     (
165         const PrimitivePatch<Face, FaceList, PointField, PointType>&
166     );
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 } // End namespace Foam
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 #ifdef NoRepository
179 #   include "PatchTools.C"
180 #endif
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 #endif
186 // ************************************************************************* //