1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Searching and marking zones of the patch.
28 \*---------------------------------------------------------------------------*/
30 #include "PatchTools.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // Finds area, starting at faceI, delimited by borderEdge.
35 // Marks all visited faces (from face-edge-face walk) with currentZone.
40 template<class> class FaceList,
46 Foam::PatchTools::markZone
48 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
49 const BoolListType& borderEdge,
51 const label currentZone,
55 const labelListList& faceEdges = p.faceEdges();
56 const labelListList& edgeFaces = p.edgeFaces();
58 // List of faces whose faceZone has been set.
59 labelList changedFaces(1, faceI);
63 // Pick up neighbours of changedFaces
64 DynamicList<label> newChangedFaces(2*changedFaces.size());
66 forAll(changedFaces, i)
68 label faceI = changedFaces[i];
70 const labelList& fEdges = faceEdges[faceI];
72 forAll(fEdges, fEdgeI)
74 label edgeI = fEdges[fEdgeI];
76 if (!borderEdge[edgeI])
78 const labelList& eFaceLst = edgeFaces[edgeI];
82 label nbrFaceI = eFaceLst[j];
84 if (faceZone[nbrFaceI] == -1)
86 faceZone[nbrFaceI] = currentZone;
87 newChangedFaces.append(nbrFaceI);
89 else if (faceZone[nbrFaceI] != currentZone)
93 "PatchTools::markZone"
94 "(const boolList&, const label, const label, labelList&)"
96 << "Zones " << faceZone[nbrFaceI]
97 << " at face " << nbrFaceI
98 << " connects to zone " << currentZone
99 << " at face " << faceI
100 << abort(FatalError);
107 if (newChangedFaces.empty())
112 // transfer from dynamic to normal list
113 changedFaces.transfer(newChangedFaces);
118 // Finds areas delimited by borderEdge (or 'real' edges).
119 // Fills faceZone accordingly
124 template<class> class FaceList,
130 Foam::PatchTools::markZones
132 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
133 const BoolListType& borderEdge,
137 faceZone.setSize(p.size());
141 for (label startFaceI = 0; startFaceI < faceZone.size();)
143 // Find next non-visited face
144 for (; startFaceI < faceZone.size(); ++startFaceI)
146 if (faceZone[startFaceI] == -1)
148 faceZone[startFaceI] = zoneI;
149 markZone(p, borderEdge, startFaceI, zoneI, faceZone);
161 // Finds areas delimited by borderEdge (or 'real' edges).
162 // Fills faceZone accordingly
167 template<class> class FaceList,
173 Foam::PatchTools::subsetMap
175 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
176 const BoolListType& includeFaces,
184 const List<Face>& localFaces = p.localFaces();
186 faceMap.setSize(localFaces.size());
187 pointMap.setSize(p.nPoints());
189 boolList pointHad(pointMap.size(), false);
193 if (includeFaces[oldFaceI])
195 // Store new faces compact
196 faceMap[faceI++] = oldFaceI;
198 // Renumber labels for face
199 const Face& f = localFaces[oldFaceI];
203 const label ptLabel = f[fp];
204 if (!pointHad[ptLabel])
206 pointHad[ptLabel] = true;
207 pointMap[pointI++] = ptLabel;
214 faceMap.setSize(faceI);
215 pointMap.setSize(pointI);
219 // ************************************************************************* //