1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Checks topology of the patch.
27 \*---------------------------------------------------------------------------*/
29 #include "PrimitivePatch.H"
34 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
39 template<class> class FaceList,
44 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
48 const labelList& pFaces,
49 const label startFaceI,
50 const label startEdgeI,
54 label index = findIndex(pFaces, startFaceI);
56 if (!pFacesHad[index])
58 // Mark face as been visited.
59 pFacesHad[index] = true;
61 // Step to next edge on face which is still using pointI
62 const labelList& fEdges = faceEdges()[startFaceI];
68 label edgeI = fEdges[i];
70 const edge& e = edges()[edgeI];
72 if (edgeI != startEdgeI && (e[0] == pointI || e[1] == pointI))
84 "PrimitivePatch<Face, FaceList, PointField, PointType>::"
86 ) << "Problem: cannot find edge out of " << fEdges
87 << "on face " << startFaceI << " that uses point " << pointI
88 << " and is not edge " << startEdgeI << abort(FatalError);
91 // Walk to next face(s) across edge.
92 const labelList& eFaces = edgeFaces()[nextEdgeI];
96 if (eFaces[i] != startFaceI)
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117 template<class> class FaceList,
122 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 // ************************************************************************* //