53 void Foam::triSurfaceTools::calcRefineStatus
55 const triSurface& surf,
57 List<refineType>& refine
60 if (refine[faceI] == RED)
69 const labelList& myNeighbours = surf.faceFaces()[faceI];
71 forAll(myNeighbours, myNeighbourI)
73 label neighbourFaceI = myNeighbours[myNeighbourI];
75 if (refine[neighbourFaceI] == GREEN)
78 calcRefineStatus(surf, neighbourFaceI, refine);
80 else if (refine[neighbourFaceI] == NONE)
82 refine[neighbourFaceI] = GREEN;
90 void Foam::triSurfaceTools::greenRefine
92 const triSurface& surf,
95 const label newPointI,
96 DynamicList<labelledTri>& newFaces
99 const labelledTri& f = surf.localFaces()[faceI];
100 const edge& e = surf.edges()[edgeI];
105 label fp1 = f.fcIndex(fp0);
106 label fp2 = f.fcIndex(fp1);
161 const triSurface& surf,
162 const List<refineType>& refineStatus
166 DynamicList<point> newPoints(surf.nPoints());
167 forAll(surf.localPoints(), pointI)
169 newPoints.append(surf.localPoints()[pointI]);
171 label newVertI = surf.nPoints();
174 DynamicList<labelledTri> newFaces(surf.size());
180 forAll(refineStatus, faceI)
182 if (refineStatus[faceI] == RED)
185 const labelList& fEdges = surf.faceEdges()[faceI];
189 label edgeI = fEdges[i];
191 if (edgeMid[edgeI] == -1)
193 const edge& e = surf.edges()[edgeI];
200 surf.localPoints()[e.start()]
201 + surf.localPoints()[e.end()]
204 edgeMid[edgeI] = newVertI++;
211 const edgeList& edges = surf.edges();
219 edges[fEdges[0]].commonVertex(edges[fEdges[1]]),
230 edges[fEdges[1]].commonVertex(edges[fEdges[2]]),
241 edges[fEdges[2]].commonVertex(edges[fEdges[0]]),
263 const label edgeI = fEdges[i];
267 if ((otherFaceI != -1) && (refineStatus[otherFaceI] == GREEN))
283 forAll(refineStatus, faceI)
285 if (refineStatus[faceI] == NONE)
287 newFaces.append(surf.localFaces()[faceI]);
297 allPoints.transfer(newPoints);
300 return triSurface(newFaces, surf.patches(),
allPoints,
true);
306 Foam::scalar Foam::triSurfaceTools::faceCosAngle
314 const vector common(pEnd - pStart);
315 const vector base0(pLeft - pStart);
316 const vector base1(pRight - pStart);
318 vector n0(common ^ base0);
321 vector n1(base1 ^ common);
332 void Foam::triSurfaceTools::protectNeighbours
334 const triSurface& surf,
350 const labelList& myEdges = surf.pointEdges()[vertI];
353 const labelList& myFaces = surf.edgeFaces()[myEdges[i]];
357 label faceI = myFaces[myFaceI];
359 if ((faceStatus[faceI] ==
ANYEDGE) || (faceStatus[faceI] >= 0))
361 faceStatus[faceI] =
NOEDGE;
375 const triSurface& surf,
379 const edge& e = surf.edges()[edgeI];
380 label v1 = e.start();
384 const labelList& myFaces = surf.edgeFaces()[edgeI];
390 facesToBeCollapsed.insert(myFaces[myFaceI]);
397 const labelList& v1Faces = surf.pointFaces()[v1];
401 label face1I = v1Faces[v1FaceI];
415 facesToBeCollapsed.insert(face1I);
416 facesToBeCollapsed.insert(face2I);
421 return facesToBeCollapsed;
428 const triSurface& surf,
433 const labelList& myFaces = surf.pointFaces()[vertI];
437 label face1I = myFaces[myFaceI];
439 if (faceUsed.found(face1I))
449 void Foam::triSurfaceTools::getMergedEdges
451 const triSurface& surf,
454 HashTable<
label,
label, Hash<label> >& edgeToEdge,
455 HashTable<
label,
label, Hash<label> >& edgeToFace
458 const edge& e = surf.edges()[edgeI];
459 label v1 = e.start();
462 const labelList& v1Faces = surf.pointFaces()[v1];
463 const labelList& v2Faces = surf.pointFaces()[v2];
470 if (!collapsedFaces.found(v2Faces[v2FaceI]))
472 v2FacesHash.insert(v2Faces[v2FaceI]);
479 label face1I = v1Faces[v1FaceI];
481 if (collapsedFaces.found(face1I))
505 label commonVert = vert1I;
506 label face2I = vertexUsesFace(surf, v2FacesHash, commonVert);
510 face2I = vertexUsesFace(surf, v2FacesHash, commonVert);
519 edgeToEdge.insert(edge1I, edge2I);
520 edgeToEdge.insert(edge2I, edge1I);
522 edgeToFace.insert(edge1I, face2I);
523 edgeToFace.insert(edge2I, face1I);
531 Foam::scalar Foam::triSurfaceTools::edgeCosAngle
533 const triSurface& surf,
537 const HashTable<
label,
label, Hash<label> >& edgeToEdge,
538 const HashTable<
label,
label, Hash<label> >& edgeToFace,
543 const pointField& localPoints = surf.localPoints();
545 label A = surf.edges()[edgeI].start();
546 label B = surf.edges()[edgeI].end();
553 if (edgeToEdge.found(edgeI))
556 label edge2I = edgeToEdge[edgeI];
557 face2I = edgeToFace[edgeI];
566 if ((face2I != -1) && !collapsedFaces.found(face2I))
578 cosAngle = faceCosAngle
588 cosAngle = faceCosAngle
598 cosAngle = faceCosAngle
608 cosAngle = faceCosAngle
619 <<
"face " << faceI <<
" does not use vertex " 629 Foam::scalar Foam::triSurfaceTools::collapseMinCosAngle
631 const triSurface& surf,
635 const HashTable<
label,
label, Hash<label> >& edgeToEdge,
636 const HashTable<
label,
label, Hash<label> >& edgeToFace
639 const labelList& v1Faces = surf.pointFaces()[v1];
645 label faceI = v1Faces[v1FaceI];
647 if (collapsedFaces.found(faceI))
652 const labelList& myEdges = surf.faceEdges()[faceI];
656 label edgeI = myEdges[myEdgeI];
683 bool Foam::triSurfaceTools::collapseCreatesFold
685 const triSurface& surf,
689 const HashTable<
label,
label, Hash<label> >& edgeToEdge,
690 const HashTable<
label,
label, Hash<label> >& edgeToFace,
694 const labelList& v1Faces = surf.pointFaces()[v1];
698 label faceI = v1Faces[v1FaceI];
700 if (collapsedFaces.found(faceI))
705 const labelList& myEdges = surf.faceEdges()[faceI];
709 label edgeI = myEdges[myEdgeI];
846 const label excludeEdgeI,
847 const label excludePointI,
849 const point& triPoint,
850 const plane& cutPlane,
855 const labelledTri& f = s[triI];
856 const labelList& fEdges = s.faceEdges()[triI];
859 FixedList<scalar, 3> d;
864 d[fp] = (points[f[fp]]-cutPlane.refPoint()) & cutPlane.normal();
873 if (
mag(d[i]) < 1e-6)
882 if (excludePointI != -1)
890 FatalErrorIn(
"cutEdge(..)") <<
"excludePointI:" << excludePointI
894 label fp1 = f.fcIndex(fp0);
895 label fp2 = f.fcIndex(fp1);
901 cut.setPoint(points[f[fp1]]);
903 cut.setIndex(s.localFaces()[triI][fp1]);
905 else if (d[fp2] == 0.0)
908 cut.setPoint(points[f[fp2]]);
910 cut.setIndex(s.localFaces()[triI][fp2]);
914 (d[fp1] < 0 && d[fp2] < 0)
915 || (d[fp1] > 0 && d[fp2] > 0)
926 (d[fp2]*points[f[fp1]] - d[fp1]*points[f[fp2]])
930 cut.setIndex(fEdges[fp1]);
936 FixedList<surfaceLocation, 2> inters;
941 label fp1 = f.fcIndex(fp0);
948 <<
"problem : triangle has three intersections." <<
nl 949 <<
"triangle:" << f.tri(points)
952 inters[interI].setHit();
953 inters[interI].setPoint(points[f[fp0]]);
955 inters[interI].setIndex(s.localFaces()[triI][fp0]);
960 (d[fp0] < 0 && d[fp1] > 0)
961 || (d[fp0] > 0 && d[fp1] < 0)
967 <<
"problem : triangle has three intersections." <<
nl 968 <<
"triangle:" << f.tri(points)
971 inters[interI].setHit();
972 inters[interI].setPoint
974 (d[fp0]*points[f[fp1]] - d[fp1]*points[f[fp0]])
978 inters[interI].setIndex(fEdges[fp0]);
988 else if (interI == 1)
993 else if (interI == 2)
999 && inters[0].index() == excludeEdgeI
1007 && inters[1].index() == excludeEdgeI
1017 magSqr(inters[0].rawPoint() - toPoint)
1018 <
magSqr(inters[1].rawPoint() - toPoint)
1035 void Foam::triSurfaceTools::snapToEnd
1037 const triSurface& s,
1038 const surfaceLocation& end,
1039 surfaceLocation& current
1047 if (current.index() == end.index())
1065 const labelList& fEdges = s.faceEdges()[current.index()];
1067 if (
findIndex(fEdges, end.index()) != -1)
1081 if (current.index() == end.index())
1095 const edge& e = s.edges()[end.index()];
1097 if (current.index() == e[0] || current.index() == e[1])
1130 const edge& e = s.
edges()[current.index()];
1132 if (end.index() == e[0] || end.index() == e[1])
1146 if (current.index() == end.index())
1167 const triSurface& s,
1169 const surfaceLocation& start,
1170 const label excludeEdgeI,
1171 const label excludePointI,
1172 const surfaceLocation& end,
1173 const plane& cutPlane
1176 surfaceLocation nearest;
1182 label triI = eFaces[i];
1185 if (triI != start.triangle())
1192 nearest.triangle() = triI;
1199 surfaceLocation cutInfo = cutEdge
1211 if (excludeEdgeI != -1 && !cutInfo.hit())
1214 <<
"Triangle:" << triI
1215 <<
" excludeEdge:" << excludeEdgeI
1216 <<
" point:" << start.rawPoint()
1217 <<
" plane:" << cutPlane
1223 scalar distSqr =
magSqr(cutInfo.rawPoint()-end.rawPoint());
1225 if (distSqr < minDistSqr)
1227 minDistSqr = distSqr;
1229 nearest.triangle() = triI;
1237 if (nearest.triangle() == -1)
1262 const point& pt = pts[pointI];
1264 outFile<<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
1266 Pout<<
"Written " << pts.
size() <<
" vertices to file " << fName <<
endl;
1281 forAll(markedVerts, vertI)
1283 if (markedVerts[vertI])
1287 outFile<<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
1292 Pout<<
"Written " << nVerts <<
" vertices to file " << fName <<
endl;
1311 label face1I = myFaces[0];
1313 if (myFaces.
size() == 2)
1315 face2I = myFaces[1];
1326 forAll(startFaces, startFaceI)
1328 edgeTris[nTris++] = startFaces[startFaceI];
1331 forAll(endFaces, endFaceI)
1333 label faceI = endFaces[endFaceI];
1335 if ((faceI != face1I) && (faceI != face2I))
1337 edgeTris[nTris++] = faceI;
1362 const edge& e = edges[v1Edges[v1EdgeI]];
1370 const edge& e = edges[v2Edges[v2EdgeI]];
1374 vertexNeighbours.
insert(vertI);
1376 return vertexNeighbours.
toc();
1438 if (myFaces.
size() != 2)
1444 if (faceI == myFaces[0])
1475 "(const triSurface&, const label, const label," 1477 ) <<
"Edge " << surf.
edges()[edgeI] <<
" not in face " 1506 else if (vertI == f[1])
1511 else if (vertI == f[2])
1521 "(const triSurface&, const label, const label," 1540 label edgeI = myEdges[myEdgeI];
1544 if ((e.
start() != vertI) && (e.
end() != vertI))
1553 "(const triSurface&, const label, const label)" 1554 ) <<
"Cannot find vertex " << vertI <<
" in edges of face " << faceI
1574 label vertI = f[fp];
1576 if (vertI != e.
start() && vertI != e.
end())
1583 <<
"Cannot find vertex opposite edge " << edgeI <<
" vertices " << e
1602 label edgeI = v1Edges[v1EdgeI];
1605 if ((e.
start() == v2) || (e.
end() == v2))
1623 if ((e0I == e1I) || (e0I == e2I) || (e1I == e2I))
1628 "(const triSurface&, const label, const label," 1630 ) <<
"Duplicate edge labels : e0:" << e0I <<
" e1:" << e1I
1639 label faceI = eFaces[eFaceI];
1646 || (myEdges[1] == e1I)
1647 || (myEdges[2] == e1I)
1653 || (myEdges[1] == e2I)
1654 || (myEdges[2] == e2I)
1714 return collapseEdges(surf, collapsableEdges, edgeMids, faceStatus);
1736 forAll(localPoints, pointI)
1738 pointMap[pointI] = pointI;
1744 forAll(collapseEdgeLabels, collapseEdgeI)
1746 const label edgeI = collapseEdgeLabels[collapseEdgeI];
1748 if ((edgeI < 0) || (edgeI >= surf.
nEdges()))
1751 <<
"Edge label outside valid range." <<
endl 1752 <<
"edge label:" << edgeI <<
endl 1753 <<
"total number of edges:" << surf.
nEdges() <<
endl 1757 const labelList& neighbours = edgeFaces[edgeI];
1759 if (neighbours.
size() == 2)
1761 const label stat0 = faceStatus[neighbours[0]];
1762 const label stat1 = faceStatus[neighbours[1]];
1767 ((stat0 ==
ANYEDGE) || (stat0 == edgeI))
1768 && ((stat1 ==
ANYEDGE) || (stat1 == edgeI))
1771 const edge& e = edges[edgeI];
1777 || (pointMap[e.
end()] != e.
end())
1781 <<
"points already mapped. Double collapse." <<
endl 1782 <<
"edgeI:" << edgeI
1783 <<
" start:" << e.
start()
1784 <<
" end:" << e.
end()
1785 <<
" pointMap[start]:" << pointMap[e.
start()]
1786 <<
" pointMap[end]:" << pointMap[e.
end()]
1791 pointMap[e.
start()] = minVert;
1792 pointMap[e.
end()] = minVert;
1795 newPoints[minVert] = edgeMids[edgeI];
1798 protectNeighbours(surf, e.
start(), faceStatus);
1799 protectNeighbours(surf, e.
end(), faceStatus);
1821 forAll(collapseFaces, collapseI)
1823 faceStatus[collapseFaces[collapseI]] =
COLLAPSED;
1838 forAll(localFaces, faceI)
1842 const label a = pointMap[f[0]];
1843 const label b = pointMap[f[1]];
1844 const label c = pointMap[f[2]];
1848 (a != b) && (a != c) && (b != c)
1853 newTris[newTriI++] =
labelledTri(a, b, c, f.region());
1872 tempSurf.localFaces(),
1874 tempSurf.localPoints()
1890 forAll(refineFaces, refineFaceI)
1892 calcRefineStatus(surf, refineFaces[refineFaceI], refineStatus);
1896 return doRefine(surf, refineStatus);
1918 forAll(refineEdges, refineEdgeI)
1920 label edgeI = refineEdges[refineEdgeI];
1924 bool neighbourIsRefined=
false;
1928 if (refineStatus[myFaces[myFaceI]] != NONE)
1930 neighbourIsRefined =
true;
1935 if (!neighbourIsRefined)
1947 newPoints[newPointI] = mid;
1963 refineStatus[myFaces[myFaceI]] = GREEN;
1973 if (refineStatus[faceI] == NONE)
1998 scalar minLength = GREAT;
1999 label minIndex = -1;
2002 const edge& e = surf.
edges()[edgeIndices[i]];
2011 if (length < minLength)
2017 return edgeIndices[minIndex];
2028 scalar maxLength = -GREAT;
2029 label maxIndex = -1;
2032 const edge& e = surf.
edges()[edgeIndices[i]];
2041 if (length > maxLength)
2047 return edgeIndices[maxIndex];
2055 const scalar mergeTol
2077 label newTriangleI = 0;
2083 label newA = pointMap[f[0]];
2084 label newB = pointMap[f[1]];
2085 label newC = pointMap[f[2]];
2087 if ((newA != newB) && (newA != newC) && (newB != newC))
2089 newTriangles[newTriangleI++] =
2093 newTriangles.
setSize(newTriangleI);
2114 const label nearestFaceI,
2115 const point& nearestPt
2121 label nearType, nearLabel;
2144 return edgeNormal/(
mag(edgeNormal) + VSMALL);
2158 const point& sample,
2159 const point& nearestPoint,
2165 if (eFaces.
size() != 2)
2177 vector n = 0.5*(faceNormals[eFaces[0]] + faceNormals[eFaces[1]]);
2179 if (((sample - nearestPoint) & n) > 0)
2195 const point& sample,
2196 const label nearestFaceI
2203 label nearType, nearLabel;
2211 vector sampleNearestVec = (sample - nearestPoint);
2214 scalar
c = sampleNearestVec & surf.
faceNormals()[nearestFaceI];
2286 return edgeSide(surf, sample, nearestPoint, edgeI);
2296 label nearPointI = localF[nearLabel];
2300 const point& base = localPoints[nearPointI];
2305 label minEdgeI = -1;
2309 label edgeI = pEdges[i];
2311 const edge& e = edges[edgeI];
2316 vector eVec(localPoints[otherPointI] - base);
2317 scalar magEVec =
mag(eVec);
2319 if (magEVec > VSMALL)
2324 const point perturbPoint = base + eVec;
2328 if (distSqr < minDistSqr)
2330 minDistSqr = distSqr;
2339 <<
"Problem: did not find edge closer than " << minDistSqr
2343 return edgeSide(surf, sample, nearestPoint, minEdgeI);
2364 label newPatchI = 0;
2368 const label patchI = iter.key();
2372 label nTriTotal = 0;
2374 forAll(patch, patchFaceI)
2376 const face& f = patch[patchFaceI];
2384 forAll(triFaces, triFaceI)
2386 const face& f = triFaces[triFaceI];
2396 Pout<< patch.
name() <<
" : generated " << nTriTotal
2397 <<
" triangles from " << patch.size() <<
" faces with" 2398 <<
" new patchid " << newPatchI <<
endl;
2411 rawSurface.localFaces(),
2412 rawSurface.localPoints()
2422 const label patchI = iter.key();
2425 surface.patches()[newPatchI].
name() = patch.
name();
2426 surface.patches()[newPatchI].geometricType() = patch.type();
2451 label newPointI = 0;
2455 newPoints[newPointI++] = points[pointI];
2457 forAll(faceCentres, faceI)
2459 newPoints[newPointI++] = faceCentres[faceI];
2469 label newPatchI = 0;
2473 const label patchI = iter.key();
2476 label nTriTotal = 0;
2478 forAll(patch, patchFaceI)
2481 const face& f = patch[patchFaceI];
2490 triangles.append(
labelledTri(f[fp], f[fp1], fc, newPatchI));
2498 Pout<< patch.
name() <<
" : generated " << nTriTotal
2499 <<
" triangles from " << patch.size() <<
" faces with" 2500 <<
" new patchid " << newPatchI <<
endl;
2525 const label patchI = iter.key();
2528 surface.patches()[newPatchI].
name() = patch.
name();
2529 surface.patches()[newPatchI].geometricType() = patch.type();
2546 geompackVertices[doubleI++] = pts[i][0];
2547 geompackVertices[doubleI++] = pts[i][1];
2560 geompackVertices.begin(),
2562 triangle_node.
begin(),
2563 triangle_neighbor.begin()
2568 FatalErrorIn(
"triSurfaceTools::delaunay2D(const List<vector2D>&)")
2569 <<
"Failed dtris2 with vertices:" << pts.
size()
2574 triangle_node.setSize(3*nTris);
2575 triangle_neighbor.setSize(3*nTris);
2584 triangle_node[3*i]-1,
2585 triangle_node[3*i+1]-1,
2586 triangle_node[3*i+2]-1,
2594 points[i][0] = pts[i][0];
2595 points[i][1] = pts[i][1];
2613 edge[0] = tri.
c()-tri.
b();
2614 edge[1] = tri.
a()-tri.
c();
2615 edge[2] = tri.
b()-tri.
a();
2617 vector triangleFaceNormal = edge[1] ^ edge[2];
2621 for (
label i=0; i<3; i++)
2623 normal[i] = triangleFaceNormal ^ edge[i];
2624 normal[i] /=
mag(normal[i]) + VSMALL;
2627 weights[0] = ((p-tri.
b()) & normal[0]) /
max(VSMALL, normal[0] & edge[1]);
2628 weights[1] = ((p-tri.
c()) & normal[1]) /
max(VSMALL, normal[1] & edge[2]);
2629 weights[2] = ((p-tri.
a()) & normal[2]) /
max(VSMALL, normal[2] & edge[0]);
2643 allVerts.setSize(samplePts.
size());
2644 allWeights.setSize(samplePts.
size());
2650 const point& samplePt = samplePts[i];
2656 scalar minDistance = GREAT;
2664 label nearType, nearLabel;
2690 else if (nearest.
distance() < minDistance)
2698 verts[0] = f[nearLabel];
2701 weights[1] = -GREAT;
2703 weights[2] = -GREAT;
2712 verts[0] = f[nearLabel];
2713 verts[1] = f[f.
fcIndex(nearLabel)];
2716 const point& p0 = points[verts[0]];
2717 const point& p1 = points[verts[1]];
2732 weights[2] = -GREAT;
2771 const point& trianglePoint
2777 label index, elemType;
2816 const plane& cutPlane
2824 snapToEnd(s, end, nearest);
2857 nearest = visitFaces
2872 nearest = visitFaces
2883 snapToEnd(s, end, nearest);
2893 const plane& cutPlane,
const Point & rawPoint() const
Return point with no checking.
int dtris2(int point_num, double point_xy[], int *tri_num, int tri_vert[], int tri_nabe[])
const pointField & points
const Field< PointType > & pointNormals() const
Return point normals for patch.
vector point
Point is a vector.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject( name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE ))
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
const word & name() const
Return name.
dimensioned< scalar > mag(const dimensioned< Type > &)
edgeList edges() const
Return edges in face point ordering,.
const labelListList & edgeFaces() const
Return edge-face addressing.
static void calcInterpolationWeights(const triPointRef &, const point &, FixedList< scalar, 3 > &weights)
Calculate linear interpolation weights for point (guaranteed to be.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
static label getEdge(const triSurface &surf, const label vert1I, const label vert2I)
Returns edge label connecting v1, v2 (local numbering)
const Point & rawPoint() const
Return point with no checking.
const labelListList & pointFaces() const
Return point-face addressing.
static const label NOEDGE
Triangulated surface description with patch information.
static void getVertexTriangles(const triSurface &surf, const label edgeI, labelList &edgeTris)
Get all triangles using edge endpoint.
const Point & c() const
Return third vertex.
static label oppositeEdge(const triSurface &surf, const label faceI, const label vertI)
Get edge opposite vertex (local numbering)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Dummy setSize function.
static labelList getVertexVertices(const triSurface &surf, const edge &e)
Get all vertices (local numbering) connected to vertices of edge.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
bool hit() const
Is there a hit.
static vector surfaceNormal(const triSurface &surf, const label nearestFaceI, const point &nearestPt)
Triangle (unit) normal. If nearest point to triangle on edge use.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label index() const
Return index.
label nPoints() const
Return number of points supporting patch faces.
vectorField pointField
pointField is a vectorField.
A triangle primitive used to calculate face normals and swept volumes.
A patch is a list of labels that address the faces in the global face list.
static label maxEdge(const triSurface &surf, const labelList &edgeIndices)
Returns element in edgeIndices with minimum length.
triangle< point, const point & > triPointRef
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
A face is a list of labels corresponding to mesh vertices.
iterator begin()
Return an iterator to begin traversing the UList.
static surfaceLocation trackToEdge(const triSurface &, const surfaceLocation &start, const surfaceLocation &end, const plane &cutPlane)
Track on surface to get closer to point.
static const label ANYEDGE
Face collapse status.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
Triangle with additional region number.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const geometricSurfacePatchList & patches() const
virtual const pointField & points() const
Return raw points.
static const label COLLAPSED
static label getTriangle(const triSurface &surf, const label e0I, const label e1I, const label e2I)
Return index of triangle (or -1) using all three edges.
static triSurface redGreenRefine(const triSurface &surf, const labelList &refineFaces)
Refine face by splitting all edges. Neighbouring face is.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
label otherVertex(const label a) const
Given one vertex, return the other.
static void track(const triSurface &, const surfaceLocation &endInfo, const plane &cutPlane, surfaceLocation &hitInfo)
Track from edge to edge across surface. Uses trackToEdge.
static triSurface collapseEdges(const triSurface &surf, const labelList &collapsableEdges)
Create new triSurface by collapsing edges to edge mids.
static void writeOBJ(const fileName &fName, const pointField &pts)
Write pointField to OBJ format file.
List< Key > toc() const
Return the table of contents.
static triSurface mergePoints(const triSurface &surf, const scalar mergeTol)
Merge points within distance.
static label otherFace(const triSurface &surf, const label faceI, const label edgeI)
Get face connected to edge not faceI.
errorManip< error > abort(error &err)
const word & name() const
Return name.
const Field< PointType > & faceNormals() const
Return face normals for patch.
void setIndex(const label index)
sideType
On which side of surface.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
static label minEdge(const triSurface &surf, const labelList &edgeIndices)
Returns element in edgeIndices with minimum length.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
tmp< pointField > allPoints(const Triangulation &t)
Extract all points in vertex-index order.
static sideType edgeSide(const triSurface &surf, const point &sample, const point &nearestPoint, const label edgeI)
If nearest point is on edgeI, determine on which side of surface.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
scalar distance() const
Return distance to hit.
label start() const
Return start label of this patch in the polyMesh face list.
label nInternalFaces() const
triSurface triangulateFaceCentre(const polyBoundaryMesh &mBesh, const labelHashSet &includePatches, const bool verbose=false)
Face-centre triangulation of (selected patches of) boundaryMesh.
label mergePoints(const UList< Type > &points, const scalar mergeTol, const bool verbose, labelList &pointMap, const Type &origin=Type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
triPointRef::proxType & elementType()
Mesh consisting of general polyhedral cells.
pointHit nearestPointClassify(const point &p, const pointField &points, label &nearType, label &nearLabel) const
Return nearest point to face and classify it:
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
const labelListList & pointEdges() const
Return point-edge addressing.
const polyMesh & mesh() const
Return the mesh reference.
void setPoint(const Point &p)
label end() const
Return end vertex label.
List< label > labelList
A List of labels.
triPointRef tri(const pointField &) const
Return the triangle.
static triSurface triangulate(const polyBoundaryMesh &mBesh, const labelHashSet &includePatches, const bool verbose=false)
Simple triangulation of (selected patches of) boundaryMesh. Needs.
A class for handling file names.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
const labelListList & faceEdges() const
Return face-edge addressing.
bool hit() const
Is there a hit.
A normal distribution model.
const dimensionedScalar c
Speed of light in a vacuum.
Vector< scalar > vector
A scalar version of the templated Vector.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
const Point & a() const
Return first vertex.
pointHit nearestPointClassify(const point &p, label &nearType, label &nearLabel) const
Find the nearest point to p on the triangle and classify it:
void append(const T &)
Append an element at the end of the list.
label start() const
Return start vertex label.
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]
const Point & b() const
Return second vertex.
static surfaceLocation classify(const triSurface &, const label triI, const point &trianglePoint)
Test point on plane of triangle to see if on edge or point or inside.
static void otherVertices(const triSurface &surf, const label faceI, const label vertI, label &vert1I, label &vert2I)
Get the two vertices (local numbering) on faceI counterclockwise.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
label nEdges() const
Return number of edges in patch.
label nTriangles() const
Number of triangles after splitting.
label triangles(const pointField &points, label &triI, faceList &triFaces) const
Split into triangles using existing points.
Contains information about location on a triSurface:
static triSurface delaunay2D(const List< vector2D > &)
Do unconstrained Delaunay of points. Returns triSurface with 3D.
static sideType surfaceSide(const triSurface &surf, const point &sample, const label nearestFaceI)
Given nearest point (to sample) on surface determines which side.
const Field< PointType > & points() const
Return reference to global points.
static void otherEdges(const triSurface &surf, const label faceI, const label edgeI, label &e1, label &e2)
Get the two edges on faceI counterclockwise after edgeI.
prefixOSstream Pout(cout,"Pout")
const vectorField & faceCentres() const
static label oppositeVertex(const triSurface &surf, const label faceI, const label edgeI)
Get vertex (local numbering) opposite edge.
bool insert(const Key &key)
Insert a new entry.