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 Create the list of loops of outside vertices. Goes wrong on multiply
26 connected edges (loops will be unclosed).
28 \*---------------------------------------------------------------------------*/
30 #include "PrimitivePatch.H"
33 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38 template<class> class FaceList,
43 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
48 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
49 << "calcEdgeLoops() : "
50 << "calculating boundary edge loops"
56 // it is considered an error to attempt to recalculate
57 // if already allocated
60 "PrimitivePatch<Face, FaceList, PointField, PointType>::"
62 ) << "edge loops already calculated"
66 const edgeList& patchEdges = edges();
67 label nIntEdges = nInternalEdges();
68 label nBdryEdges = patchEdges.size() - nIntEdges;
72 edgeLoopsPtr_ = new labelListList(0);
76 const labelListList& patchPointEdges = pointEdges();
80 // Walk point-edge-point and assign loop number
83 // Loop per (boundary) edge.
84 labelList loopNumber(nBdryEdges, -1);
86 // Size return list plenty big
87 edgeLoopsPtr_ = new labelListList(nBdryEdges);
88 labelListList& edgeLoops = *edgeLoopsPtr_;
91 // Current loop number.
96 // Find edge not yet given a loop number.
97 label currentEdgeI = -1;
99 for (label edgeI = nIntEdges; edgeI < patchEdges.size(); edgeI++)
101 if (loopNumber[edgeI-nIntEdges] == -1)
103 currentEdgeI = edgeI;
108 if (currentEdgeI == -1)
110 // Did not find edge not yet assigned a loop number so done all.
114 // Temporary storage for vertices of current loop
115 DynamicList<label> loop(nBdryEdges);
117 // Walk from first all the way round, assigning loops
118 label currentVertI = patchEdges[currentEdgeI].start();
122 loop.append(currentVertI);
124 loopNumber[currentEdgeI - nIntEdges] = loopI;
126 // Step to next vertex
127 currentVertI = patchEdges[currentEdgeI].otherVertex(currentVertI);
129 // Step to next (unmarked, boundary) edge.
130 const labelList& curEdges = patchPointEdges[currentVertI];
136 label edgeI = curEdges[pI];
138 if (edgeI >= nIntEdges && (loopNumber[edgeI - nIntEdges] == -1))
140 // Unassigned boundary edge.
141 currentEdgeI = edgeI;
147 while (currentEdgeI != -1);
149 // Done all for current loop. Transfer to edgeLoops.
150 edgeLoops[loopI].transfer(loop);
155 edgeLoops.setSize(loopI);
159 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
160 << "calcEdgeLoops() : "
161 << "finished calculating boundary edge loops"
170 template<class> class FaceList,
174 const Foam::labelListList&
175 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
183 return *edgeLoopsPtr_;
187 // ************************************************************************* //