1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
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/>.
25 Searching and marking zones of the patch.
27 \*---------------------------------------------------------------------------*/
29 #include "PatchTools.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 // Finds area, starting at faceI, delimited by borderEdge.
34 // Marks all visited faces (from face-edge-face walk) with currentZone.
39 template<class> class FaceList,
45 Foam::PatchTools::markZone
47 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
48 const BoolListType& borderEdge,
50 const label currentZone,
54 const labelListList& faceEdges = p.faceEdges();
55 const labelListList& edgeFaces = p.edgeFaces();
57 // List of faces whose faceZone has been set.
58 labelList changedFaces(1, faceI);
62 // Pick up neighbours of changedFaces
63 dynamicLabelList newChangedFaces(2*changedFaces.size());
65 forAll(changedFaces, i)
67 label faceI = changedFaces[i];
69 const labelList& fEdges = faceEdges[faceI];
71 forAll(fEdges, fEdgeI)
73 label edgeI = fEdges[fEdgeI];
75 if (!borderEdge[edgeI])
77 const labelList& eFaceLst = edgeFaces[edgeI];
81 label nbrFaceI = eFaceLst[j];
83 if (faceZone[nbrFaceI] == -1)
85 faceZone[nbrFaceI] = currentZone;
86 newChangedFaces.append(nbrFaceI);
88 else if (faceZone[nbrFaceI] != currentZone)
92 "PatchTools::markZone"
93 "(const boolList&, const label, const label, labelList&)"
95 << "Zones " << faceZone[nbrFaceI]
96 << " at face " << nbrFaceI
97 << " connects to zone " << currentZone
98 << " at face " << faceI
106 if (newChangedFaces.empty())
111 // transfer from dynamic to normal list
112 changedFaces.transfer(newChangedFaces);
117 // Finds areas delimited by borderEdge (or 'real' edges).
118 // Fills faceZone accordingly
123 template<class> class FaceList,
129 Foam::PatchTools::markZones
131 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
132 const BoolListType& borderEdge,
136 faceZone.setSize(p.size());
140 for (label startFaceI = 0; startFaceI < faceZone.size();)
142 // Find next non-visited face
143 for (; startFaceI < faceZone.size(); ++startFaceI)
145 if (faceZone[startFaceI] == -1)
147 faceZone[startFaceI] = zoneI;
148 markZone(p, borderEdge, startFaceI, zoneI, faceZone);
160 // Finds areas delimited by borderEdge (or 'real' edges).
161 // Fills faceZone accordingly
166 template<class> class FaceList,
172 Foam::PatchTools::subsetMap
174 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
175 const BoolListType& includeFaces,
183 const List<Face>& localFaces = p.localFaces();
185 faceMap.setSize(localFaces.size());
186 pointMap.setSize(p.nPoints());
188 boolList pointHad(pointMap.size(), false);
192 if (includeFaces[oldFaceI])
194 // Store new faces compact
195 faceMap[faceI++] = oldFaceI;
197 // Renumber labels for face
198 const Face& f = localFaces[oldFaceI];
202 const label ptLabel = f[fp];
203 if (!pointHad[ptLabel])
205 pointHad[ptLabel] = true;
206 pointMap[pointI++] = ptLabel;
213 faceMap.setSize(faceI);
214 pointMap.setSize(pointI);
218 // ************************************************************************* //