Go to the documentation of this file.
56 void Foam::triSurfaceTools::calcRefineStatus
58 const triSurface& surf,
60 List<refineType>& refine
63 if (refine[facei] == RED)
72 const labelList& myNeighbours = surf.faceFaces()[facei];
74 for (
const label neighbourFacei : myNeighbours)
76 if (refine[neighbourFacei] == GREEN)
79 calcRefineStatus(surf, neighbourFacei, refine);
81 else if (refine[neighbourFacei] == NONE)
83 refine[neighbourFacei] = GREEN;
91 void Foam::triSurfaceTools::greenRefine
93 const triSurface& surf,
97 DynamicList<labelledTri>& newFaces
100 const labelledTri&
f = surf.localFaces()[facei];
101 const edge&
e = surf.edges()[edgeI];
105 label fp0 =
f.find(
e[0]);
106 label fp1 =
f.fcIndex(fp0);
107 label fp2 =
f.fcIndex(fp1);
162 const triSurface& surf,
163 const List<refineType>& refineStatus
167 label newVertI = surf.
nPoints();
169 DynamicList<point> newPoints(newVertI);
170 newPoints.append(surf.localPoints());
173 DynamicList<labelledTri> newFaces(surf.size());
179 forAll(refineStatus, facei)
181 if (refineStatus[facei] == RED)
184 const labelList& fEdges = surf.faceEdges()[facei];
186 for (
const label edgei : fEdges)
188 if (edgeMid[edgei] == -1)
190 const edge&
e = surf.edges()[edgei];
193 newPoints.append(
e.centre(surf.localPoints()));
194 edgeMid[edgei] = newVertI++;
201 const edgeList& edges = surf.edges();
209 edges[fEdges[0]].commonVertex(edges[fEdges[1]]),
220 edges[fEdges[1]].commonVertex(edges[fEdges[2]]),
231 edges[fEdges[2]].commonVertex(edges[fEdges[0]]),
251 for (
const label edgei : fEdges)
253 label otherFacei =
otherFace(surf, facei, edgei);
255 if ((otherFacei != -1) && (refineStatus[otherFacei] == GREEN))
271 forAll(refineStatus, facei)
273 if (refineStatus[facei] == NONE)
275 newFaces.append(surf.localFaces()[facei]);
288 return triSurface(newFaces, surf.patches(),
allPoints,
true);
294 Foam::scalar Foam::triSurfaceTools::faceCosAngle
302 const vector common(pEnd - pStart);
303 const vector base0(pLeft - pStart);
304 const vector base1(pRight - pStart);
317 void Foam::triSurfaceTools::protectNeighbours
319 const triSurface& surf,
332 for (
const label edgei : surf.pointEdges()[vertI])
334 for (
const label facei : surf.edgeFaces()[edgei])
336 if ((faceStatus[facei] == ANYEDGE) || (faceStatus[facei] >= 0))
338 faceStatus[facei] = NOEDGE;
352 const triSurface& surf,
356 const edge&
e = surf.edges()[edgeI];
357 const label v1 =
e.start();
358 const label v2 =
e.end();
361 const labelList& myFaces = surf.edgeFaces()[edgeI];
364 facesToBeCollapsed.
insert(myFaces);
370 const labelList& v1Faces = surf.pointFaces()[v1];
372 for (
const label face1I : v1Faces)
374 label otherEdgeI = oppositeEdge(surf, face1I, v1);
377 label face2I =
otherFace(surf, face1I, otherEdgeI);
382 if (oppositeVertex(surf, face2I, otherEdgeI) == v2)
386 facesToBeCollapsed.insert(face1I);
387 facesToBeCollapsed.insert(face2I);
392 return facesToBeCollapsed;
397 Foam::label Foam::triSurfaceTools::vertexUsesFace
399 const triSurface& surf,
404 for (
const label face1I : surf.pointFaces()[vertI])
406 if (faceUsed.found(face1I))
416 void Foam::triSurfaceTools::getMergedEdges
418 const triSurface& surf,
421 Map<label>& edgeToEdge,
422 Map<label>& edgeToFace
425 const edge&
e = surf.edges()[edgeI];
426 const label v1 =
e.start();
427 const label v2 =
e.end();
429 const labelList& v1Faces = surf.pointFaces()[v1];
430 const labelList& v2Faces = surf.pointFaces()[v2];
435 for (
const label facei : v2Faces)
437 if (!collapsedFaces.found(facei))
439 v2FacesHash.
insert(facei);
444 for (
const label face1I: v1Faces)
446 if (collapsedFaces.found(face1I))
470 label commonVert = vert1I;
471 label face2I = vertexUsesFace(surf, v2FacesHash, commonVert);
475 face2I = vertexUsesFace(surf, v2FacesHash, commonVert);
481 label edge1I = getEdge(surf, v1, commonVert);
482 label edge2I = getEdge(surf, v2, commonVert);
484 edgeToEdge.insert(edge1I, edge2I);
485 edgeToEdge.insert(edge2I, edge1I);
487 edgeToFace.insert(edge1I, face2I);
488 edgeToFace.insert(edge2I, face1I);
496 Foam::scalar Foam::triSurfaceTools::edgeCosAngle
498 const triSurface& surf,
502 const Map<label>& edgeToEdge,
503 const Map<label>& edgeToFace,
508 const pointField& localPoints = surf.localPoints();
510 label
A = surf.edges()[edgeI].start();
511 label
B = surf.edges()[edgeI].end();
512 label
C = oppositeVertex(surf, facei, edgeI);
518 if (edgeToEdge.found(edgeI))
521 label edge2I = edgeToEdge[edgeI];
522 face2I = edgeToFace[edgeI];
524 D = oppositeVertex(surf, face2I, edge2I);
531 if ((face2I != -1) && !collapsedFaces.found(face2I))
533 D = oppositeVertex(surf, face2I, edgeI);
543 cosAngle = faceCosAngle
553 cosAngle = faceCosAngle
563 cosAngle = faceCosAngle
573 cosAngle = faceCosAngle
584 <<
"face " << facei <<
" does not use vertex "
592 Foam::scalar Foam::triSurfaceTools::collapseMinCosAngle
594 const triSurface& surf,
598 const Map<label>& edgeToEdge,
599 const Map<label>& edgeToFace
602 const labelList& v1Faces = surf.pointFaces()[v1];
606 for (
const label facei : v1Faces)
608 if (collapsedFaces.found(facei))
613 for (
const label edgeI : surf.faceEdges()[facei])
640 bool Foam::triSurfaceTools::collapseCreatesFold
642 const triSurface& surf,
646 const Map<label>& edgeToEdge,
647 const Map<label>& edgeToFace,
651 const labelList& v1Faces = surf.pointFaces()[v1];
653 for (
const label facei : v1Faces)
655 if (collapsedFaces.found(facei))
660 const labelList& myEdges = surf.faceEdges()[facei];
662 for (
const label edgeI : myEdges)
797 const label excludeEdgeI,
798 const label excludePointi,
800 const point& triPoint,
801 const plane& cutPlane,
806 const labelledTri&
f =
s[triI];
807 const labelList& fEdges =
s.faceEdges()[triI];
810 FixedList<scalar, 3> d;
815 d[fp] = cutPlane.signedDistance(
points[
f[fp]]);
824 if (
mag(d[i]) < 1
e-6)
833 if (excludePointi != -1)
837 label fp0 =
s.localFaces()[triI].find(excludePointi);
845 label fp1 =
f.fcIndex(fp0);
846 label fp2 =
f.fcIndex(fp1);
854 cut.setIndex(
s.localFaces()[triI][fp1]);
856 else if (d[fp2] == 0.0)
861 cut.setIndex(
s.localFaces()[triI][fp2]);
865 (d[fp1] < 0 && d[fp2] < 0)
866 || (d[fp1] > 0 && d[fp2] > 0)
881 cut.setIndex(fEdges[fp1]);
887 FixedList<surfaceLocation, 2> inters;
892 label fp1 =
f.fcIndex(fp0);
899 <<
"problem : triangle has three intersections." <<
nl
900 <<
"triangle:" <<
f.tri(
points)
903 inters[interI].setHit();
904 inters[interI].setPoint(
points[
f[fp0]]);
906 inters[interI].setIndex(
s.localFaces()[triI][fp0]);
911 (d[fp0] < 0 && d[fp1] > 0)
912 || (d[fp0] > 0 && d[fp1] < 0)
918 <<
"problem : triangle has three intersections." <<
nl
919 <<
"triangle:" <<
f.tri(
points)
922 inters[interI].setHit();
923 inters[interI].setPoint
929 inters[interI].setIndex(fEdges[fp0]);
939 else if (interI == 1)
944 else if (interI == 2)
950 && inters[0].index() == excludeEdgeI
958 && inters[1].index() == excludeEdgeI
986 void Foam::triSurfaceTools::snapToEnd
989 const surfaceLocation&
end,
990 surfaceLocation& current
998 if (current.index() ==
end.index())
1016 const labelList& fEdges =
s.faceEdges()[current.index()];
1018 if (fEdges.found(
end.index()))
1032 if (current.index() ==
end.index())
1046 const edge&
e =
s.edges()[
end.index()];
1048 if (current.index() ==
e[0] || current.index() ==
e[1])
1067 if (
f.found(
end.index()))
1081 const edge&
e =
s.edges()[current.index()];
1083 if (
end.index() ==
e[0] ||
end.index() ==
e[1])
1097 if (current.index() ==
end.index())
1118 const triSurface&
s,
1120 const surfaceLocation& start,
1121 const label excludeEdgeI,
1122 const label excludePointi,
1123 const surfaceLocation&
end,
1124 const plane& cutPlane
1127 surfaceLocation nearest;
1131 for (
const label triI : eFaces)
1134 if (triI != start.triangle())
1141 nearest.triangle() = triI;
1148 surfaceLocation cutInfo = cutEdge
1160 if (excludeEdgeI != -1 && !cutInfo.hit())
1163 <<
"Triangle:" << triI
1164 <<
" excludeEdge:" << excludeEdgeI
1165 <<
" point:" << start.rawPoint()
1166 <<
" plane:" << cutPlane
1172 scalar distSqr =
magSqr(cutInfo.rawPoint()-
end.rawPoint());
1174 if (distSqr < minDistSqr)
1176 minDistSqr = distSqr;
1178 nearest.triangle() = triI;
1186 if (nearest.triangle() == -1)
1209 for (
const point& pt : pts)
1211 outFile<<
"v " << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() <<
endl;
1213 Pout<<
"Written " << pts.size() <<
" vertices to file " << fName <<
endl;
1228 forAll(markedVerts, vertI)
1230 if (markedVerts[vertI])
1234 outFile<<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
1239 Pout<<
"Written " << nVerts <<
" vertices to file " << fName <<
endl;
1258 label face1I = myFaces[0];
1260 if (myFaces.size() == 2)
1262 face2I = myFaces[1];
1270 edgeTris.
setSize(startFaces.size() + endFaces.size() - myFaces.size());
1273 for (
const label facei : startFaces)
1275 edgeTris[nTris++] = facei;
1278 for (
const label facei : endFaces)
1280 if ((facei != face1I) && (facei != face2I))
1282 edgeTris[nTris++] = facei;
1296 const label v1 =
e.start();
1297 const label v2 =
e.end();
1304 for (
const label edgei : v1Edges)
1306 vertexNeighbours.
insert(edges[edgei].otherVertex(v1));
1311 for (
const label edgei : v2Edges)
1313 vertexNeighbours.
insert(edges[edgei].otherVertex(v2));
1315 return vertexNeighbours.
toc();
1329 if (myFaces.size() != 2)
1333 else if (facei == myFaces[0])
1356 label i0 = eFaces.find(edgeI);
1361 <<
"Edge " << surf.
edges()[edgeI] <<
" not in face "
1365 label i1 = eFaces.fcIndex(i0);
1366 label i2 = eFaces.fcIndex(i1);
1390 else if (vertI ==
f[1])
1395 else if (vertI ==
f[2])
1403 <<
"Vertex " << vertI <<
" not in face " <<
f <<
nl
1419 for (
const label edgei : myEdges)
1423 if (!
e.found(vertI))
1430 <<
"Cannot find vertex " << vertI <<
" in edges of face " << facei
1449 for (
const label pointi :
f)
1451 if (!
e.found(pointi))
1458 <<
"Cannot find vertex opposite edge " << edgeI <<
" vertices " <<
e
1475 for (
const label edgei : v1Edges)
1497 if ((e0I == e1I) || (e0I == e2I) || (e1I == e2I))
1500 <<
"Duplicate edge labels : e0:" << e0I <<
" e1:" << e1I
1507 for (
const label facei : eFaces)
1514 || (myEdges[1] == e1I)
1515 || (myEdges[2] == e1I)
1521 || (myEdges[1] == e2I)
1522 || (myEdges[2] == e2I)
1549 labelList faceStatus(surf.size(), ANYEDGE);
1576 return collapseEdges(surf, collapsableEdges, edgeMids, faceStatus);
1598 forAll(localPoints, pointi)
1600 pointMap[pointi] = pointi;
1606 for (
const label edgei : collapseEdgeLabels)
1608 if (edgei < 0 || edgei >= surf.
nEdges())
1611 <<
"Edge label outside valid range." <<
endl
1612 <<
"edge label:" << edgei <<
endl
1613 <<
"total number of edges:" << surf.
nEdges() <<
endl
1617 const labelList& neighbours = edgeFaces[edgei];
1619 if (neighbours.size() == 2)
1621 const label stat0 = faceStatus[neighbours[0]];
1622 const label stat1 = faceStatus[neighbours[1]];
1627 ((stat0 == ANYEDGE) || (stat0 == edgei))
1628 && ((stat1 == ANYEDGE) || (stat1 == edgei))
1631 const edge&
e = edges[edgei];
1636 (pointMap[
e.start()] !=
e.start())
1637 || (pointMap[
e.end()] !=
e.end())
1641 <<
"points already mapped. Double collapse." <<
endl
1642 <<
"edgei:" << edgei
1643 <<
" start:" <<
e.start()
1644 <<
" end:" <<
e.end()
1645 <<
" pointMap[start]:" << pointMap[
e.start()]
1646 <<
" pointMap[end]:" << pointMap[
e.end()]
1650 const label minVert =
min(
e.start(),
e.end());
1651 pointMap[
e.start()] = minVert;
1652 pointMap[
e.end()] = minVert;
1655 newPoints[minVert] = edgeMids[edgei];
1658 protectNeighbours(surf,
e.start(), faceStatus);
1659 protectNeighbours(surf,
e.end(), faceStatus);
1663 oppositeVertex(surf, neighbours[0], edgei),
1669 oppositeVertex(surf, neighbours[1], edgei),
1681 forAll(collapseFaces, collapseI)
1683 faceStatus[collapseFaces[collapseI]] = COLLAPSED;
1698 forAll(localFaces, facei)
1702 const label a = pointMap[
f[0]];
1703 const label
b = pointMap[
f[1]];
1704 const label
c = pointMap[
f[2]];
1708 (a !=
b) && (a !=
c) && (
b !=
c)
1709 && (faceStatus[facei] != COLLAPSED)
1732 tempSurf.localFaces(),
1734 tempSurf.localPoints()
1750 forAll(refineFaces, refineFacei)
1752 calcRefineStatus(surf, refineFaces[refineFacei], refineStatus);
1756 return doRefine(surf, refineStatus);
1778 for (
const label edgei : refineEdges)
1782 bool neighbourIsRefined=
false;
1784 for (
const label facei : myFaces)
1786 if (refineStatus[facei] != NONE)
1788 neighbourIsRefined =
true;
1793 if (!neighbourIsRefined)
1801 for (
const label facei : myFaces)
1814 refineStatus[facei] = GREEN;
1824 if (refineStatus[facei] == NONE)
1849 scalar minLen = GREAT;
1852 for (
const label edgei : edgeIndices)
1858 if (length < minLen)
1876 scalar maxLen = -GREAT;
1879 for (
const label edgei : edgeIndices)
1885 if (length > maxLen)
1900 const scalar mergeTol
1922 label newTriangleI = 0;
1928 label newA = pointMap[
f[0]];
1929 label newB = pointMap[
f[1]];
1930 label newC = pointMap[
f[2]];
1932 if ((newA != newB) && (newA != newC) && (newB != newC))
1934 newTriangles[newTriangleI++] =
1938 newTriangles.
setSize(newTriangleI);
1957 const label nearestFacei,
1958 const point& nearestPt
1964 label nearType, nearLabel;
1966 f.nearestPointClassify(nearestPt,
points, nearType, nearLabel);
1976 label edgeI = surf.
faceEdges()[nearestFacei][nearLabel];
1983 for (
const label facei : eFaces)
2001 const point& sample,
2002 const point& nearestPoint,
2008 if (eFaces.size() != 2)
2022 if (((sample - nearestPoint) &
n) > 0)
2038 const point& sample,
2039 const label nearestFacei
2046 label nearType, nearLabel;
2048 pointHit pHit =
f.nearestPointClassify(sample,
points, nearType, nearLabel);
2054 vector sampleNearestVec = (sample - nearestPoint);
2057 scalar
c = sampleNearestVec & surf.
faceNormals()[nearestFacei];
2105 label edgeI = surf.
faceEdges()[nearestFacei][nearLabel];
2129 return edgeSide(surf, sample, nearestPoint, edgeI);
2139 label nearPointi = localF[nearLabel];
2143 const point& base = localPoints[nearPointi];
2148 label minEdgeI = -1;
2152 label edgeI = pEdges[i];
2154 const edge&
e = edges[edgeI];
2156 label otherPointi =
e.otherVertex(nearPointi);
2159 vector eVec(localPoints[otherPointi] - base);
2160 scalar magEVec =
mag(eVec);
2162 if (magEVec > VSMALL)
2167 const point perturbPoint = base + eVec;
2171 if (distSqr < minDistSqr)
2173 minDistSqr = distSqr;
2182 <<
"Problem: did not find edge closer than " << minDistSqr
2186 return edgeSide(surf, sample, nearestPoint, minEdgeI);
2208 for (
const label patchi : includePatches)
2212 nFaces +=
patch.size();
2216 nTris += triFaces.size();
2222 label newPatchi = 0;
2225 for (
const label patchi : includePatches)
2230 label nTriTotal = 0;
2239 f.triangles(
points, nTri, triFaces);
2241 for (
const face&
f : triFaces)
2254 Pout<<
patch.name() <<
" : generated " << nTriTotal
2255 <<
" triangles from " <<
patch.size() <<
" faces with"
2256 <<
" new patchid " << newPatchi <<
endl;
2269 rawSurface.localFaces(),
2270 rawSurface.localPoints()
2278 for (
const label patchi : includePatches)
2282 surface.patches()[newPatchi].name() =
patch.name();
2283 surface.patches()[newPatchi].geometricType() =
patch.type();
2305 label newPatchi = 0;
2307 for (
const label patchi : includePatches)
2312 label nTriTotal = 0;
2324 f.triangles(
points, nTri, triFaces);
2326 forAll(triFaces, triFacei)
2328 const face&
f = triFaces[triFacei];
2339 Pout<<
patch.name() <<
" : generated " << nTriTotal
2340 <<
" triangles from " <<
patch.size() <<
" faces with"
2341 <<
" new patchid " << newPatchi <<
endl;
2354 rawSurface.localFaces(),
2355 rawSurface.localPoints()
2363 for (
const label patchi : includePatches)
2367 surface.patches()[newPatchi].name() =
patch.name();
2368 surface.patches()[newPatchi].geometricType() =
patch.type();
2399 forAll(faceCentres, facei)
2401 newPoints[
newPointi++] = faceCentres[facei];
2408 label newPatchi = 0;
2410 for (
const label patchi : includePatches)
2414 label nTriTotal = 0;
2422 label fc =
points.size() + patchFacei +
patch.start();
2426 label fp1 =
f.fcIndex(fp);
2436 Pout<<
patch.name() <<
" : generated " << nTriTotal
2437 <<
" triangles from " <<
patch.size() <<
" faces with"
2438 <<
" new patchid " << newPatchi <<
endl;
2461 for (
const label patchi : includePatches)
2465 surface.patches()[newPatchi].name() =
patch.name();
2466 surface.patches()[newPatchi].geometricType() =
patch.type();
2483 geompackVertices[doubleI++] = pt[0];
2484 geompackVertices[doubleI++] = pt[1];
2489 List<int> triangle_node(m2*3*pts.size());
2490 List<int> triangle_neighbor(m2*3*pts.size());
2497 geompackVertices.begin(),
2499 triangle_node.begin(),
2500 triangle_neighbor.begin()
2506 <<
"Failed dtris2 with vertices:" << pts.size()
2511 triangle_node.setSize(3*nTris);
2512 triangle_neighbor.setSize(3*nTris);
2521 triangle_node[3*i]-1,
2522 triangle_node[3*i+1]-1,
2523 triangle_node[3*i+2]-1,
2531 points[i][0] = pts[i][0];
2532 points[i][1] = pts[i][1];
2550 edge[0] = tri.
c()-tri.
b();
2551 edge[1] = tri.
a()-tri.
c();
2552 edge[2] = tri.
b()-tri.
a();
2558 for (label i=0; i<3; i++)
2563 weights[0] = ((
p-tri.
b()) & normal[0]) /
max(VSMALL, normal[0] &
edge[1]);
2564 weights[1] = ((
p-tri.
c()) & normal[1]) /
max(VSMALL, normal[1] &
edge[2]);
2565 weights[2] = ((
p-tri.
a()) & normal[2]) /
max(VSMALL, normal[2] &
edge[0]);
2579 allVerts.setSize(samplePts.size());
2580 allWeights.setSize(samplePts.size());
2586 const point& samplePt = samplePts[i];
2591 scalar minDistance = GREAT;
2597 label nearType, nearLabel;
2613 calcInterpolationWeights(tri, nearest.
rawPoint(), weights);
2623 else if (nearest.
distance() < minDistance)
2631 verts[0] =
f[nearLabel];
2634 weights[1] = -GREAT;
2636 weights[2] = -GREAT;
2645 verts[0] =
f[nearLabel];
2646 verts[1] =
f[
f.fcIndex(nearLabel)];
2665 weights[2] = -GREAT;
2679 calcInterpolationWeights(tri, nearest.
rawPoint(), weights);
2706 const FaceType&
f = surf[facei];
2709 for (
const label pointi :
f)
2711 if (pointi < 0 || pointi >= surf.
points().size())
2716 <<
"triangle " << facei <<
" vertices " <<
f
2717 <<
" uses point indices outside point range 0.."
2724 if (
f[0] ==
f[1] ||
f[0] ==
f[2] ||
f[1] ==
f[2])
2729 <<
"triangle " << facei
2730 <<
" uses non-unique vertices " <<
f
2742 for (
const label nbrFacei : fFaces)
2744 if (nbrFacei <= facei)
2750 const FaceType& nbrF = surf[nbrFacei];
2755 (
f[0] == nbrF[0] ||
f[0] == nbrF[1] ||
f[0] == nbrF[2])
2756 && (
f[1] == nbrF[0] ||
f[1] == nbrF[1] ||
f[1] == nbrF[2])
2757 && (
f[2] == nbrF[0] ||
f[2] == nbrF[1] ||
f[2] == nbrF[2])
2763 <<
"triangle " << facei <<
" vertices " <<
f
2764 <<
" has the same vertices as triangle " << nbrFacei
2765 <<
" vertices " << nbrF
2784 typedef face FaceType;
2785 const FaceType&
f = surf[facei];
2793 <<
" is not a triangle, it has " <<
f.size()
2794 <<
" indices" <<
endl;
2800 for (
const label pointi :
f)
2802 if (pointi < 0 || pointi >= surf.points().
size())
2807 <<
"triangle " << facei <<
" vertices " <<
f
2808 <<
" uses point indices outside point range 0.."
2815 if (
f[0] ==
f[1] ||
f[0] ==
f[2] ||
f[1] ==
f[2])
2820 <<
"triangle " << facei
2821 <<
" uses non-unique vertices " <<
f
2822 <<
" coords:" <<
f.points(surf.points()) <<
endl;
2829 const labelList& fFaces = surf.faceFaces()[facei];
2833 for (
const label nbrFacei : fFaces)
2835 if (nbrFacei <= facei)
2841 const FaceType& nbrF = surf[nbrFacei];
2846 (
f[0] == nbrF[0] ||
f[0] == nbrF[1] ||
f[0] == nbrF[2])
2847 && (
f[1] == nbrF[0] ||
f[1] == nbrF[1] ||
f[1] == nbrF[2])
2848 && (
f[2] == nbrF[0] ||
f[2] == nbrF[1] ||
f[2] == nbrF[2])
2854 <<
"triangle " << facei <<
" vertices " <<
f
2855 <<
" has the same vertices as triangle " << nbrFacei
2856 <<
" vertices " << nbrF
2857 <<
" coords:" <<
f.points(surf.points()) <<
endl;
2875 const point& trianglePoint
2881 label index, elemType;
2901 nearest.
setIndex(
s.faceEdges()[triI][index]);
2907 nearest.
setIndex(
s.localFaces()[triI][index]);
2920 const plane& cutPlane
2928 snapToEnd(
s,
end, nearest);
2961 nearest = visitFaces
2976 nearest = visitFaces
2987 snapToEnd(
s,
end, nearest);
2997 const plane& cutPlane,
3013 hitInfo = trackToEdge
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
virtual const pointField & points() const
Return raw points.
const Cmpt & x() const
Access to the vector x component.
const labelListList & pointFaces() const
Return point-face addressing.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
const labelListList & edgeFaces() const
Return edge-face addressing.
List< edge > edgeList
A List of edges.
A class for handling file names.
void setIndex(const label index) noexcept
Set the index.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
static constexpr const zero Zero
Global zero (0)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
bool containsAny(const UList< point > &points) const
Contains any of the points? (inside or on edge)
const Field< point_type > & pointNormals() const
Return point normals for patch.
label nEdges() const
Return number of edges in patch.
Contains information about location on a triSurface.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
int dtris2(int point_num, double point_xy[], int *tri_num, int tri_vert[], int tri_nabe[])
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
scalar distance() const noexcept
Return distance to hit.
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
void setMiss() noexcept
Set the hit status off.
void append(const T &val)
Append an element at the end of the list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const labelListList & faceEdges() const
Return face-edge addressing.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const geometricSurfacePatchList & patches() const
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
const Cmpt & z() const
Access to the vector z component.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
A triangle primitive used to calculate face normals and swept volumes.
bool hit() const noexcept
Is there a hit?
const Point & c() const
Return third vertex.
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]=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]
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf())
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Triangulated surface description with patch information.
A patch is a list of labels that address the faces in the global face list.
const point_type & rawPoint() const noexcept
The point, no checks.
const Point & a() const
Return first vertex.
const labelListList & pointEdges() const
Return point-edge addressing.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Patchify triangles based on orientation w.r.t other (triangulated or triangulatable) surfaces.
label nPoints() const
Return number of points supporting patch faces.
label nBoundaryFaces() const
Number of boundary faces (== nFaces - nInternalFaces)
const point_type & rawPoint() const noexcept
The point, no checks. Same as point()
const Point & b() const
Return second vertex.
PointFrompoint toPoint(const Foam::point &p)
const Field< point_type > & points() const
Return reference to global points.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
void setSize(const label n)
Dummy function, to make FixedList consistent with List.
errorManip< error > abort(error &err)
Vector< scalar > vector
A scalar version of the templated Vector.
label mergePoints(const PointList &points, const scalar mergeTol, const bool verbose, labelList &pointMap, typename PointList::const_reference origin=PointList::value_type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
Output to file stream, using an OSstream.
VectorSpace< Form, Cmpt, Ncmpts > normalised(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
void setPoint(const point_type &p)
Set the point.
pointHit nearestPointClassify(const point &p, label &nearType, label &nearLabel) const
Find the nearest point to p on the triangle and classify it:
const Cmpt & y() const
Access to the vector y component.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const std::string patch
OpenFOAM patch number as a std::string.
label & triangle() noexcept
label index() const noexcept
Return the hit index.
triPointRef::proxType & elementType() noexcept
void setHit() noexcept
Set the hit status on.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const vectorField & faceCentres() const
const dimensionedScalar e
Elementary charge.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
const dimensionedScalar & D
Triangle with additional region number.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
A bounding box defined in terms of min/max extrema points.
const dimensionedScalar c
Speed of light in a vacuum.
A face is a list of labels corresponding to mesh vertices.
labelledTri face_type
The face type (same as the underlying PrimitivePatch)
const volScalarField & p0
vector point
Point is a vector.
const labelListList & faceFaces() const
Return face-face addressing.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
void setSize(const label newSize)
Alias for resize(const label)
label size() const
The surface size is the number of faces.
bool hit() const noexcept
Is there a hit.
#define WarningInFunction
Report a warning using Foam::Warning.
triangle< point, const point & > triPointRef
A triangle using referred points.
A list of faces which address into the list of points.