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 Create the list of loops of outside vertices. Goes wrong on multiply
27 connected edges (loops will be unclosed).
29 \*---------------------------------------------------------------------------*/
31 #include "PrimitivePatch.H"
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39 template<class> class FaceList,
44 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
49 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
50 << "calcEdgeLoops() : "
51 << "calculating boundary edge loops"
57 // it is considered an error to attempt to recalculate
58 // if already allocated
61 "PrimitivePatch<Face, FaceList, PointField, PointType>::"
63 ) << "edge loops already calculated"
67 const edgeList& patchEdges = edges();
68 label nIntEdges = nInternalEdges();
69 label nBdryEdges = patchEdges.size() - nIntEdges;
73 edgeLoopsPtr_ = new labelListList(0);
77 const labelListList& patchPointEdges = pointEdges();
81 // Walk point-edge-point and assign loop number
84 // Loop per (boundary) edge.
85 labelList loopNumber(nBdryEdges, -1);
87 // Size return list plenty big
88 edgeLoopsPtr_ = new labelListList(nBdryEdges);
89 labelListList& edgeLoops = *edgeLoopsPtr_;
92 // Current loop number.
97 // Find edge not yet given a loop number.
98 label currentEdgeI = -1;
100 for (label edgeI = nIntEdges; edgeI < patchEdges.size(); edgeI++)
102 if (loopNumber[edgeI-nIntEdges] == -1)
104 currentEdgeI = edgeI;
109 if (currentEdgeI == -1)
111 // Did not find edge not yet assigned a loop number so done all.
115 // Temporary storage for vertices of current loop
116 DynamicList<label> loop(nBdryEdges);
118 // Walk from first all the way round, assigning loops
119 label currentVertI = patchEdges[currentEdgeI].start();
123 loop.append(currentVertI);
125 loopNumber[currentEdgeI - nIntEdges] = loopI;
127 // Step to next vertex
128 currentVertI = patchEdges[currentEdgeI].otherVertex(currentVertI);
130 // Step to next (unmarked, boundary) edge.
131 const labelList& curEdges = patchPointEdges[currentVertI];
137 label edgeI = curEdges[pI];
139 if (edgeI >= nIntEdges && (loopNumber[edgeI - nIntEdges] == -1))
141 // Unassigned boundary edge.
142 currentEdgeI = edgeI;
148 while (currentEdgeI != -1);
150 // Done all for current loop. Transfer to edgeLoops.
151 edgeLoops[loopI].transfer(loop);
156 edgeLoops.setSize(loopI);
160 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
161 << "calcEdgeLoops() : "
162 << "finished calculating boundary edge loops"
171 template<class> class FaceList,
175 const Foam::labelListList&
176 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
184 return *edgeLoopsPtr_;
188 // ************************************************************************* //