49 const bool removeConnections
52 Info <<
"Checking cells connected to surface vertices" <<
endl;
62 const VRWGraph& cellCells = mesh_.addressingData().cellCells();
63 const VRWGraph& pointCells = mesh_.addressingData().pointCells();
71 parallelBndNode[it()] =
true;
77 label nBadVertices(0);
82 # pragma omp parallel for private(frontCells) schedule(dynamic, 1000)
84 for(
label bpI=0;bpI<size;++bpI)
86 if( parallelBndNode[bpI] )
89 const label pointI = bPoints[bpI];
97 const label cellI = pointCells(pointI, cI);
99 if( cellGroup.found(cellI) )
102 cellGroup.insert(cellI, nGroup);
106 while( frontCells.
size() != 0 )
112 const label neiCell = cellCells(cLabel, nI);
114 if( cellGroup.found(neiCell) )
117 if( pointCells.
contains(pointI, neiCell) )
119 cellGroup.insert(neiCell, nGroup);
120 frontCells.
append(neiCell);
132 # pragma omp critical
136 badVertices.
insert(pointI);
138 if( removeConnections )
143 const label cellI = pointCells(pointI, pcI);
145 if( cellGroup[cellI] != 0 )
161 for(
label i=1;i<nGroup;++i)
179 const labelList& neighbour = mesh_.neighbour();
181 mesh_.procBoundaries();
184 mesh_.addressingData().globalCellLabel();
186 std::map<label, DynList<edge> > dualEdgesForPoint;
187 std::map<label, DynList<edge> >::iterator bpIter;
188 forAll(parallelBndNode, bpI)
190 if( !parallelBndNode[bpI] )
193 dualEdgesForPoint.insert
200 for(
label faceI=0;faceI<mesh_.nInternalFaces();++faceI)
202 const face&
f = faces[faceI];
206 if(
f[pI] >= origNumVertices )
209 bpIter = dualEdgesForPoint.find(bp[
f[pI]]);
210 if( bpIter != dualEdgesForPoint.end() )
212 const label cOwn = globalCellLabel[owner[faceI]];
213 const label cNei = globalCellLabel[neighbour[faceI]];
223 forAll(procBoundaries, patchI)
225 if( procBoundaries[patchI].owner() )
228 const label start = procBoundaries[patchI].patchStart();
229 labelList globalLabels(procBoundaries[patchI].patchSize());
231 globalLabels[fI] = globalCellLabel[owner[start+fI]];
236 procBoundaries[patchI].neiProcNo(),
237 globalLabels.byteSize()
240 toOtherProc << globalLabels;
243 forAll(procBoundaries, patchI)
245 if( !procBoundaries[patchI].owner() )
252 procBoundaries[patchI].neiProcNo()
255 fromOtherProc >> receivedData;
257 const label start = procBoundaries[patchI].patchStart();
261 const face&
f = faces[start+i];
265 bpIter = dualEdgesForPoint.find(bp[
f[pI]]);
266 if( bpIter != dualEdgesForPoint.end() )
268 const label cOwn = globalCellLabel[owner[start+i]];
269 const label cNei = receivedData[i];
281 std::map<label, labelLongList> exchangeData;
284 bpIter=dualEdgesForPoint.begin();
285 bpIter!=dualEdgesForPoint.end();
289 const label bpI = bpIter->first;
293 const label neiProc = bpAtProcs(bpI, i);
303 dts.
append(globalPointLabel[bpI]);
307 dts.
append(edges[eI].start());
308 dts.
append(edges[eI].end());
317 while( counter < receivedData.
size() )
319 const label bpI = globalToLocal[receivedData[counter++]];
320 const label nEdges = receivedData[counter++];
322 for(
label i=0;i<nEdges;++i)
324 const label s = receivedData[counter++];
325 const label e = receivedData[counter++];
326 dualEdgesForPoint[bpI].append(
edge(
s,
e));
337 bpIter=dualEdgesForPoint.begin();
338 bpIter!=dualEdgesForPoint.end();
343 Pout <<
"Global point label " << globalPointLabel[bpIter->first]
344 <<
" point cells " << pointCells[bPoints[bpIter->first]]
345 <<
" dual edges " << pEdges <<
endl;
356 bpIter=dualEdgesForPoint.begin();
357 bpIter!=dualEdgesForPoint.end();
362 std::map<label, DynList<label> > bpEdges;
366 bpEdges[pEdges[eI][i]].append(eI);
379 if( cellGroup.found(it->first) )
382 cellGroup.insert(it->first, counter);
384 frontCells.
append(it->first);
386 while( frontCells.
size() != 0 )
391 forAll(attachedEdges, aeI)
394 pEdges[attachedEdges[aeI]].otherVertex(cLabel);
396 if( cellGroup.found(oCell) )
400 cellGroup.insert(oCell, counter);
410 badVertices.
insert(bPoints[bpIter->first]);
412 if( !removeConnections )
415 const label pointI = bPoints[bpIter->first];
419 const label cellI = pointCells(pointI, pcI);
421 if( cellGroup[globalCellLabel[cellI]] == 0 )
434 nPoints + cellGroup[globalCellLabel[cellI]] - 1;
438 for(
label i=1;i<counter;++i)
449 Info <<
"Found " << nBadVertices <<
" problematic vertices" <<
endl;
450 Info <<
"Finished checking cells connected to surface vertices" <<
endl;
452 if( nBadVertices != 0 )
455 mesh_.clearAddressingData();
469 Info <<
"Checking for non-manifold surface edges" <<
endl;
482 badVertices.
insert(edges[edgeI].start());
483 badVertices.
insert(edges[edgeI].end());
498 std::map<label, labelLongList> exchangeData;
504 std::map<label, labelLongList>::iterator eIter;
510 numFacesAtEdge.insert
518 const label neiProc = edgesAtProcs(eI, procI);
523 eIter = exchangeData.find(neiProc);
524 eIter->second.append(globalEdgeLabel[eI]);
525 eIter->second.append(edgeFaces.
sizeOfRow(eI));
535 while( counter < receivedData.
size() )
537 const label geI = receivedData[counter++];
538 const label nFaces = receivedData[counter++];
540 numFacesAtEdge[geI] += nFaces;
542 if( numFacesAtEdge[geI] > 2 )
544 const label edgeI = globalToLocalEdgeLabel[geI];
545 badVertices.
insert(edges[edgeI].start());
546 badVertices.
insert(edges[edgeI].end());
554 Info <<
"Found " << nBadEdges <<
" non-manifold edges" <<
endl;
555 Info <<
"Finished checking for non-manifold surface edges" <<
endl;
560 boolList removeCell(mesh_.cells().size(),
false);
564 const labelList& neighbour = mesh_.neighbour();
568 const face&
f = faces[faceI];
572 const edge e =
f.faceEdge(pI);
574 if( (bp[
e[0]] != -1) && (bp[
e[1]] != -1) )
576 const label bpI = bp[
e[0]];
580 const label edgeI = pointEdges(bpI, peI);
581 if( (edges[edgeI] ==
e) && badEdges.
found(edgeI) )
583 removeCell[owner[faceI]] =
true;
584 if( neighbour[faceI] < 0 )
586 removeCell[neighbour[faceI]] =
true;
608 Info <<
"Checking faces connections to surface vertices" <<
endl;
624 parallelBndPoint[it()] =
true;
631 # pragma omp parallel for private(front) schedule(dynamic)
633 for(
label bpI=0;bpI<size;++bpI)
635 if( parallelBndPoint[bpI] )
643 const label fI = pointFaces(bpI, pfI);
645 if( faceGroup.found(fI) )
650 faceGroup.insert(fI, nGroup);
652 while( front.
size() != 0 )
658 const label neiFace = faceFaces(fLabel, ffI);
660 if( faceGroup.found(neiFace) )
663 if( pointFaces.
contains(bpI, neiFace) )
666 faceGroup.insert(neiFace, nGroup);
676 const label pointI = bPoints[bpI];
678 # pragma omp critical
681 badVertices.
insert(pointI);
682 invalidVertices.
insert(pointI);
712 std::map<label, DynList<edge> > dualEdgesForPoint;
713 std::map<label, DynList<edge> >::iterator bpIter;
714 forAll(parallelBndPoint, bpI)
716 if( !parallelBndPoint[bpI] )
719 dualEdgesForPoint.insert(std::make_pair(bpI,
DynList<edge>()));
723 const label edgeI = pointEdges(bpI, peI);
730 globalFaceLabel[edgeFaces(edgeI, 0)],
731 globalFaceLabel[edgeFaces(edgeI, 1)]
734 dualEdgesForPoint[bpI].append(
e);
739 std::map<label, labelLongList> exchangeData;
743 exchangeData.insert(std::make_pair(beNeiProcs[i],
labelLongList()));
746 const label beI = it.key();
753 exchangeData[it()].append(globalEdgeLabel[beI]);
754 exchangeData[it()].append(globalFaceLabel[edgeFaces(beI, 0)]);
762 while( counter < receivedData.
size() )
764 const label beI = globalToLocalEdge[receivedData[counter++]];
765 const label fLabel = receivedData[counter++];
767 const edge&
e = edges[beI];
770 const label bpI = bp[
e[i]];
772 const label fLocal = globalFaceLabel[edgeFaces(beI, 0)];
773 dualEdgesForPoint[bpI].
append(
edge(fLabel, fLocal));
779 exchangeData.clear();
782 bpIter=dualEdgesForPoint.begin();
783 bpIter!=dualEdgesForPoint.end();
787 const label bpI = bpIter->first;
791 const label neiProc = bpAtProcs(bpI, i);
801 dts.
append(globalPointLabel[bpI]);
805 dts.
append(edges[eI].start());
806 dts.
append(edges[eI].end());
811 receivedData.
clear();
815 while( counter < receivedData.
size() )
817 const label bpI = globalToLocal[receivedData[counter++]];
818 const label nEdges = receivedData[counter++];
819 for(
label i=0;i<nEdges;++i)
821 const label s = receivedData[counter++];
822 const label e = receivedData[counter++];
823 dualEdgesForPoint[bpI].append(
edge(
s,
e));
834 bpIter=dualEdgesForPoint.begin();
835 bpIter!=dualEdgesForPoint.end();
840 Pout <<
"Global point label "
841 << globalPointLabel[bpIter->first]
842 <<
" dual edges " << pEdges <<
endl;
853 bpIter=dualEdgesForPoint.begin();
854 bpIter!=dualEdgesForPoint.end();
860 std::map<label, DynList<label> > bpEdges;
864 bpEdges[pEdges[eI][i]].append(eI);
877 if( cellGroup.found(it->first) )
880 cellGroup.insert(it->first, counter);
884 while( front.
size() != 0 )
889 forAll(attachedEdges, aeI)
892 pEdges[attachedEdges[aeI]].otherVertex(cLabel);
894 if( cellGroup.found(oCell) )
898 cellGroup.insert(oCell, counter);
907 invalidVertices.
insert(bPoints[bpIter->first]);
908 badVertices.
insert(bPoints[bpIter->first]);
913 const label nBadVertices =
915 Info <<
"Found " << nBadVertices <<
" invalid connections" <<
endl;
916 Info <<
"Finished checking faces connections to surface vertices" <<
endl;
920 const VRWGraph& pointCells = mesh_.addressingData().pointCells();
922 boolList removeCell(mesh_.cells().size(),
false);
927 removeCell[pointCells(it.key(), pcI)] =
true;