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 Checks topology of the patch.
28 \*---------------------------------------------------------------------------*/
30 #include "PrimitivePatch.H"
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 template<class> class FaceList,
46 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
50 const labelList& pFaces,
51 const label startFaceI,
52 const label startEdgeI,
56 label index = findIndex(pFaces, startFaceI);
58 if (!pFacesHad[index])
60 // Mark face as been visited.
61 pFacesHad[index] = true;
63 // Step to next edge on face which is still using pointI
64 const labelList& fEdges = faceEdges()[startFaceI];
70 label edgeI = fEdges[i];
72 const edge& e = edges()[edgeI];
74 if (edgeI != startEdgeI && (e[0] == pointI || e[1] == pointI))
86 "PrimitivePatch<Face, FaceList, PointField, PointType>::"
88 ) << "Problem: cannot find edge out of " << fEdges
89 << "on face " << startFaceI << " that uses point " << pointI
90 << " and is not edge " << startEdgeI << abort(FatalError);
93 // Walk to next face(s) across edge.
94 const labelList& eFaces = edgeFaces()[nextEdgeI];
98 if (eFaces[i] != startFaceI)
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 template<class> class FaceList,
124 typename Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo
125 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
130 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
132 "calculating patch topology"
136 const labelListList& edgeFcs = edgeFaces();
138 surfaceTopo pType = MANIFOLD;
140 forAll(edgeFcs, edgeI)
142 label nNbrs = edgeFcs[edgeI].size();
144 if (nNbrs < 1 || nNbrs > 2)
148 // Can exit now. Surface is illegal.
153 // Surface might be open or illegal so keep looping.
160 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
162 "finished calculating patch topology"
173 template<class> class FaceList,
179 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
188 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
189 "checkTopology(const bool, labelHashSet&) : "
190 "checking patch topology"
196 const labelListList& edgeFcs = edgeFaces();
198 surfaceTopo surfaceType = MANIFOLD;
200 forAll(edgeFcs, edgeI)
202 label nNbrs = edgeFcs[edgeI].size();
204 if (nNbrs < 1 || nNbrs > 2)
206 surfaceType = ILLEGAL;
210 Info<< "Edge " << edgeI << " with vertices:" << edges()[edgeI]
211 << " has " << nNbrs << " face neighbours"
217 const edge& e = edges()[edgeI];
219 setPtr->insert(meshPoints()[e.start()]);
220 setPtr->insert(meshPoints()[e.end()]);
231 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
232 "checkTopology(const bool, labelHashSet&) : "
233 "finished checking patch topology"
237 return surfaceType == ILLEGAL;
244 template<class> class FaceList,
250 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
257 const labelListList& pf = pointFaces();
258 const labelListList& pe = pointEdges();
259 const labelListList& ef = edgeFaces();
260 const labelList& mp = meshPoints();
262 bool foundError = false;
266 const labelList& pFaces = pf[pointI];
268 // Visited faces (as indices into pFaces)
269 boolList pFacesHad(pFaces.size(), false);
272 const labelList& pEdges = pe[pointI];
273 label startEdgeI = pEdges[0];
275 const labelList& eFaces = ef[startEdgeI];
279 // Visit all faces using pointI, starting from eFaces[i] and
280 // startEdgeI. Mark off all faces visited in pFacesHad.
281 this->visitPointRegion
285 eFaces[i], // starting face for walk
286 startEdgeI, // starting edge for walk
291 // After this all faces using pointI should have been visited and
292 // marked off in pFacesHad.
294 label unset = findIndex(pFacesHad, false);
300 label meshPointI = mp[pointI];
304 setPtr->insert(meshPointI);
309 Info<< "Point " << meshPointI
310 << " uses faces which are not connected through an edge"
312 << "This means that the surface formed by this patched"
313 << " is multiply connected at this point" << nl
314 << "Connected (patch) faces:" << nl;
320 Info<< " " << pFaces[i] << endl;
324 Info<< nl << "Unconnected (patch) faces:" << nl;
329 Info<< " " << pFaces[i] << endl;
340 // ************************************************************************* //