28 static void markPointNbrs
30 const triSurface& surf,
36 const triSurface::FaceType& f = surf.localFaces()[facei];
44 okToCollapse[pFaces[i]] =
false;
50 static triSurface pack
52 const triSurface& surf,
57 List<labelledTri> newTriangles(surf.size());
58 label newTriangleI = 0;
62 const labelledTri& f = surf.localFaces()[facei];
64 label newA = pointMap[f[0]];
65 label newB = pointMap[f[1]];
66 label newC = pointMap[f[2]];
68 if ((newA != newB) && (newA != newC) && (newB != newC))
70 newTriangles[newTriangleI++] =
71 labelledTri(newA, newB, newC, f.region());
74 newTriangles.setSize(newTriangleI);
76 return triSurface(newTriangles, surf.patches(), localPoints);
83 label nTotalCollapsed = 0;
87 const pointField& localPoints = surf.localPoints();
88 const List<labelledTri>& localFaces = surf.localFaces();
102 boolList okToCollapse(surf.size(),
true);
103 label nCollapsed = 0;
107 if (okToCollapse[facei])
110 const triSurface::FaceType& f = localFaces[facei];
115 label v1 = f[f.fcIndex(fp)];
117 if (
mag(localPoints[v1] - localPoints[v]) < minLen)
121 newPoints[v] = 0.5*(localPoints[v1] + localPoints[v]);
127 okToCollapse[facei] =
false;
130 markPointNbrs(surf, facei,
false, okToCollapse);
138 Info<<
"collapseEdge : collapsing " << nCollapsed
139 <<
" triangles to a single edge." 142 nTotalCollapsed += nCollapsed;
150 surf = pack(surf, newPoints, pointMap);
154 surf = triSurface(surf.localFaces(), surf.patches(), surf.localPoints());
156 return nTotalCollapsed;
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
List< bool > boolList
Bool container classes.
vectorField pointField
pointField is a vectorField.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints,-1);const cellModel &hex=*(cellModeller::lookup("hex"));labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){pointMap[i]=i;}for(label i=0;i< nPoints;i++){if(f[i] > 0.0){hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei){if(edges[ei].mag(points)< SMALL){label start=pointMap[edges[ei].start()];while(start!=pointMap[start]){start=pointMap[start];}label end=pointMap[edges[ei].end()];while(end!=pointMap[end]){end=pointMap[end];}label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;}}cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){cellShape &cs=cellShapes[celli];forAll(cs, i){cs[i]=pointMap[cs[i]];}cs.collapse();}label bcIDs[11]={-1, 0, 2, 4,-1, 5,-1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={&wallPolyPatch::typeName,&wallPolyPatch::typeName,&wallPolyPatch::typeName,&wallPolyPatch::typeName,&symmetryPolyPatch::typeName,&wedgePolyPatch::typeName,&polyPatch::typeName,&polyPatch::typeName,&polyPatch::typeName,&polyPatch::typeName,&symmetryPolyPatch::typeName,&oldCyclicPolyPatch::typeName};enum patchTypeNames{PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={"piston","valve","liner","cylinderHead","axis","wedge","inflow","outflow","presin","presout","symmetryPlane","cyclic"};List< SLList< face > > pFaces[nBCs]
List< label > labelList
A List of labels.
Routines to collapse small edges.
dimensioned< scalar > mag(const dimensioned< Type > &)