31 static void markPointNbrs
33 const triSurface& surf,
39 const triSurface::face_type&
f = surf.localFaces()[facei];
47 okToCollapse[
pFaces[i]] =
false;
53 static triSurface pack
55 const triSurface& surf,
60 List<labelledTri> newTriangles(surf.size());
64 for (labelledTri
f : surf.localFaces())
67 f[0] = pointMap[
f[0]];
68 f[1] = pointMap[
f[1]];
69 f[2] = pointMap[
f[2]];
73 newTriangles[nNewTris++] =
f;
76 newTriangles.resize(nNewTris);
78 return triSurface(newTriangles, surf.patches(), localPoints);
83 label
collapseEdge(triSurface& surf,
const scalar minLen)
85 label nTotalCollapsed = 0;
89 const pointField& localPoints = surf.localPoints();
90 const List<labelledTri>& localFaces = surf.localFaces();
100 boolList okToCollapse(surf.size(),
true);
101 label nCollapsed = 0;
105 if (okToCollapse[facei])
108 const triSurface::face_type&
f = localFaces[facei];
113 label v1 =
f[
f.fcIndex(fp)];
115 if (
mag(localPoints[v1] - localPoints[v]) < minLen)
119 newPoints[v] = 0.5*(localPoints[v1] + localPoints[v]);
125 okToCollapse[facei] =
false;
128 markPointNbrs(surf, facei,
false, okToCollapse);
136 Info<<
"collapseEdge : collapsing " << nCollapsed
137 <<
" triangles to a single edge." 140 nTotalCollapsed += nCollapsed;
148 surf = pack(surf, newPoints, pointMap);
152 surf = triSurface(surf.localFaces(), surf.patches(), surf.localPoints());
154 return nTotalCollapsed;
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
#define forAll(list, i)
Loop across all elements in list.
vectorField pointField
pointField is a vectorField.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::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].reset(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]
Routines to collapse small edges.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
List< bool > boolList
A List of bools.