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,
45 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
49 const labelList& pFaces,
50 const label startFaceI,
51 const label startEdgeI,
55 label index = findIndex(pFaces, startFaceI);
57 if (!pFacesHad[index])
59 // Mark face as been visited.
60 pFacesHad[index] = true;
62 // Step to next edge on face which is still using pointI
63 const labelList& fEdges = faceEdges()[startFaceI];
69 label edgeI = fEdges[i];
71 const edge& e = edges()[edgeI];
73 if (edgeI != startEdgeI && (e[0] == pointI || e[1] == pointI))
85 "PrimitivePatch<Face, FaceList, PointField, PointType>::"
87 ) << "Problem: cannot find edge out of " << fEdges
88 << "on face " << startFaceI << " that uses point " << pointI
89 << " and is not edge " << startEdgeI << abort(FatalError);
92 // Walk to next face(s) across edge.
93 const labelList& eFaces = edgeFaces()[nextEdgeI];
97 if (eFaces[i] != startFaceI)
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118 template<class> class FaceList,
122 typename Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo
123 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
128 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
130 "calculating patch topology"
134 const labelListList& edgeFcs = edgeFaces();
136 surfaceTopo pType = MANIFOLD;
138 forAll(edgeFcs, edgeI)
140 label nNbrs = edgeFcs[edgeI].size();
142 if (nNbrs < 1 || nNbrs > 2)
146 // Can exit now. Surface is illegal.
151 // Surface might be open or illegal so keep looping.
158 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
160 "finished calculating patch topology"
171 template<class> class FaceList,
176 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
185 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
186 "checkTopology(const bool, labelHashSet&) : "
187 "checking patch topology"
193 const labelListList& edgeFcs = edgeFaces();
195 surfaceTopo surfaceType = MANIFOLD;
197 forAll(edgeFcs, edgeI)
199 label nNbrs = edgeFcs[edgeI].size();
201 if (nNbrs < 1 || nNbrs > 2)
203 surfaceType = ILLEGAL;
207 Info<< "Edge " << edgeI << " with vertices:" << edges()[edgeI]
208 << " has " << nNbrs << " face neighbours"
214 const edge& e = edges()[edgeI];
216 setPtr->insert(meshPoints()[e.start()]);
217 setPtr->insert(meshPoints()[e.end()]);
228 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
229 "checkTopology(const bool, labelHashSet&) : "
230 "finished checking patch topology"
234 return surfaceType == ILLEGAL;
241 template<class> class FaceList,
246 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
253 const labelListList& pf = pointFaces();
254 const labelListList& pe = pointEdges();
255 const labelListList& ef = edgeFaces();
256 const labelList& mp = meshPoints();
258 bool foundError = false;
262 const labelList& pFaces = pf[pointI];
264 // Visited faces (as indices into pFaces)
265 boolList pFacesHad(pFaces.size(), false);
268 const labelList& pEdges = pe[pointI];
269 label startEdgeI = pEdges[0];
271 const labelList& eFaces = ef[startEdgeI];
275 // Visit all faces using pointI, starting from eFaces[i] and
276 // startEdgeI. Mark off all faces visited in pFacesHad.
277 this->visitPointRegion
281 eFaces[i], // starting face for walk
282 startEdgeI, // starting edge for walk
287 // After this all faces using pointI should have been visited and
288 // marked off in pFacesHad.
290 label unset = findIndex(pFacesHad, false);
296 label meshPointI = mp[pointI];
300 setPtr->insert(meshPointI);
305 Info<< "Point " << meshPointI
306 << " uses faces which are not connected through an edge"
308 << "This means that the surface formed by this patched"
309 << " is multiply connected at this point" << nl
310 << "Connected (patch) faces:" << nl;
316 Info<< " " << pFaces[i] << endl;
320 Info<< nl << "Unconnected (patch) faces:" << nl;
325 Info<< " " << pFaces[i] << endl;
336 // ************************************************************************* //