55void Foam::triSurfaceTools::calcRefineStatus
57 const triSurface& surf,
59 List<refineType>& refine
62 if (refine[facei] == RED)
71 const labelList& myNeighbours = surf.faceFaces()[facei];
73 for (
const label neighbourFacei : myNeighbours)
75 if (refine[neighbourFacei] == GREEN)
78 calcRefineStatus(surf, neighbourFacei, refine);
80 else if (refine[neighbourFacei] == NONE)
82 refine[neighbourFacei] = GREEN;
90void Foam::triSurfaceTools::greenRefine
92 const triSurface& surf,
96 DynamicList<labelledTri>& newFaces
99 const labelledTri&
f = surf.localFaces()[facei];
100 const edge&
e = surf.edges()[edgeI];
161 const triSurface& surf,
162 const List<refineType>& refineStatus
166 label newVertI = surf.
nPoints();
168 DynamicList<point> newPoints(newVertI);
169 newPoints.append(surf.localPoints());
172 DynamicList<labelledTri> newFaces(surf.size());
178 forAll(refineStatus, facei)
180 if (refineStatus[facei] == RED)
183 const labelList& fEdges = surf.faceEdges()[facei];
185 for (
const label edgei : fEdges)
187 if (edgeMid[edgei] == -1)
189 const edge&
e = surf.edges()[edgei];
192 newPoints.
append(
e.centre(surf.localPoints()));
193 edgeMid[edgei] = newVertI++;
200 const edgeList& edges = surf.edges();
208 edges[fEdges[0]].commonVertex(edges[fEdges[1]]),
219 edges[fEdges[1]].commonVertex(edges[fEdges[2]]),
230 edges[fEdges[2]].commonVertex(edges[fEdges[0]]),
250 for (
const label edgei : fEdges)
252 label otherFacei =
otherFace(surf, facei, edgei);
254 if ((otherFacei != -1) && (refineStatus[otherFacei] == GREEN))
270 forAll(refineStatus, facei)
272 if (refineStatus[facei] == NONE)
274 newFaces.append(surf.localFaces()[facei]);
287 return triSurface(newFaces, surf.patches(), allPoints,
true);
293Foam::scalar Foam::triSurfaceTools::faceCosAngle
301 const vector common(pEnd - pStart);
302 const vector base0(pLeft - pStart);
303 const vector base1(pRight - pStart);
316void Foam::triSurfaceTools::protectNeighbours
318 const triSurface& surf,
331 for (
const label edgei : surf.pointEdges()[vertI])
333 for (
const label facei : surf.edgeFaces()[edgei])
335 if ((faceStatus[facei] == ANYEDGE) || (faceStatus[facei] >= 0))
337 faceStatus[facei] = NOEDGE;
351 const triSurface& surf,
355 const edge&
e = surf.edges()[edgeI];
356 const label v1 =
e.start();
357 const label v2 =
e.
end();
360 const labelList& myFaces = surf.edgeFaces()[edgeI];
363 facesToBeCollapsed.insert(myFaces);
369 const labelList& v1Faces = surf.pointFaces()[v1];
371 for (
const label face1I : v1Faces)
373 label otherEdgeI = oppositeEdge(surf, face1I, v1);
376 label face2I =
otherFace(surf, face1I, otherEdgeI);
381 if (oppositeVertex(surf, face2I, otherEdgeI) == v2)
385 facesToBeCollapsed.insert(face1I);
386 facesToBeCollapsed.insert(face2I);
391 return facesToBeCollapsed;
396Foam::label Foam::triSurfaceTools::vertexUsesFace
398 const triSurface& surf,
403 for (
const label face1I : surf.pointFaces()[vertI])
405 if (faceUsed.found(face1I))
415void Foam::triSurfaceTools::getMergedEdges
417 const triSurface& surf,
420 Map<label>& edgeToEdge,
421 Map<label>& edgeToFace
424 const edge&
e = surf.edges()[edgeI];
425 const label v1 =
e.start();
426 const label v2 =
e.
end();
428 const labelList& v1Faces = surf.pointFaces()[v1];
429 const labelList& v2Faces = surf.pointFaces()[v2];
434 for (
const label facei : v2Faces)
436 if (!collapsedFaces.found(facei))
438 v2FacesHash.insert(facei);
443 for (
const label face1I: v1Faces)
445 if (collapsedFaces.found(face1I))
469 label commonVert = vert1I;
470 label face2I = vertexUsesFace(surf, v2FacesHash, commonVert);
474 face2I = vertexUsesFace(surf, v2FacesHash, commonVert);
480 label edge1I = getEdge(surf, v1, commonVert);
481 label edge2I = getEdge(surf, v2, commonVert);
483 edgeToEdge.insert(edge1I, edge2I);
484 edgeToEdge.insert(edge2I, edge1I);
486 edgeToFace.insert(edge1I, face2I);
487 edgeToFace.insert(edge2I, face1I);
495Foam::scalar Foam::triSurfaceTools::edgeCosAngle
497 const triSurface& surf,
501 const Map<label>& edgeToEdge,
502 const Map<label>& edgeToFace,
507 const pointField& localPoints = surf.localPoints();
509 label
A = surf.edges()[edgeI].start();
510 label
B = surf.edges()[edgeI].end();
511 label
C = oppositeVertex(surf, facei, edgeI);
517 if (edgeToEdge.found(edgeI))
520 label edge2I = edgeToEdge[edgeI];
521 face2I = edgeToFace[edgeI];
523 D = oppositeVertex(surf, face2I, edge2I);
530 if ((face2I != -1) && !collapsedFaces.found(face2I))
532 D = oppositeVertex(surf, face2I, edgeI);
542 cosAngle = faceCosAngle
552 cosAngle = faceCosAngle
562 cosAngle = faceCosAngle
572 cosAngle = faceCosAngle
583 <<
"face " << facei <<
" does not use vertex "
591Foam::scalar Foam::triSurfaceTools::collapseMinCosAngle
593 const triSurface& surf,
597 const Map<label>& edgeToEdge,
598 const Map<label>& edgeToFace
601 const labelList& v1Faces = surf.pointFaces()[v1];
605 for (
const label facei : v1Faces)
607 if (collapsedFaces.found(facei))
612 for (
const label edgeI : surf.faceEdges()[facei])
639bool Foam::triSurfaceTools::collapseCreatesFold
641 const triSurface& surf,
645 const Map<label>& edgeToEdge,
646 const Map<label>& edgeToFace,
650 const labelList& v1Faces = surf.pointFaces()[v1];
652 for (
const label facei : v1Faces)
654 if (collapsedFaces.found(facei))
659 const labelList& myEdges = surf.faceEdges()[facei];
661 for (
const label edgeI : myEdges)
796 const label excludeEdgeI,
797 const label excludePointi,
799 const point& triPoint,
800 const plane& cutPlane,
805 const labelledTri&
f =
s[triI];
806 const labelList& fEdges =
s.faceEdges()[triI];
809 FixedList<scalar, 3> d;
814 d[fp] = cutPlane.signedDistance(
points[
f[fp]]);
823 if (
mag(d[i]) < 1
e-6)
832 if (excludePointi != -1)
836 label fp0 =
s.localFaces()[triI].find(excludePointi);
853 cut.setIndex(
s.localFaces()[triI][fp1]);
855 else if (d[fp2] == 0.0)
860 cut.setIndex(
s.localFaces()[triI][fp2]);
864 (d[fp1] < 0 && d[fp2] < 0)
865 || (d[fp1] > 0 && d[fp2] > 0)
880 cut.setIndex(fEdges[fp1]);
886 FixedList<surfaceLocation, 2> inters;
898 <<
"problem : triangle has three intersections." <<
nl
899 <<
"triangle:" <<
f.tri(
points)
902 inters[interI].setHit();
903 inters[interI].setPoint(
points[
f[fp0]]);
905 inters[interI].setIndex(
s.localFaces()[triI][fp0]);
910 (d[fp0] < 0 && d[fp1] > 0)
911 || (d[fp0] > 0 && d[fp1] < 0)
917 <<
"problem : triangle has three intersections." <<
nl
918 <<
"triangle:" <<
f.tri(
points)
921 inters[interI].setHit();
922 inters[interI].setPoint
928 inters[interI].setIndex(fEdges[fp0]);
938 else if (interI == 1)
943 else if (interI == 2)
949 && inters[0].index() == excludeEdgeI
957 && inters[1].index() == excludeEdgeI
985void Foam::triSurfaceTools::snapToEnd
988 const surfaceLocation& end,
989 surfaceLocation& current
997 if (current.index() ==
end.index())
1015 const labelList& fEdges =
s.faceEdges()[current.index()];
1017 if (fEdges.found(
end.index()))
1031 if (current.index() ==
end.index())
1045 const edge&
e =
s.edges()[
end.index()];
1047 if (current.index() ==
e[0] || current.index() ==
e[1])
1080 const edge&
e =
s.edges()[current.index()];
1082 if (
end.index() ==
e[0] ||
end.index() ==
e[1])
1096 if (current.index() ==
end.index())
1117 const triSurface&
s,
1119 const surfaceLocation& start,
1120 const label excludeEdgeI,
1121 const label excludePointi,
1122 const surfaceLocation& end,
1123 const plane& cutPlane
1126 surfaceLocation nearest;
1130 for (
const label triI : eFaces)
1133 if (triI != start.triangle())
1140 nearest.triangle() = triI;
1147 surfaceLocation cutInfo = cutEdge
1159 if (excludeEdgeI != -1 && !cutInfo.hit())
1162 <<
"Triangle:" << triI
1163 <<
" excludeEdge:" << excludeEdgeI
1164 <<
" point:" << start.rawPoint()
1165 <<
" plane:" << cutPlane
1171 scalar distSqr =
magSqr(cutInfo.rawPoint()-
end.rawPoint());
1173 if (distSqr < minDistSqr)
1175 minDistSqr = distSqr;
1177 nearest.triangle() = triI;
1185 if (nearest.triangle() == -1)
1208 for (
const point& pt : pts)
1210 outFile<<
"v " << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() <<
endl;
1212 Pout<<
"Written " << pts.
size() <<
" vertices to file " << fName <<
endl;
1227 forAll(markedVerts, vertI)
1229 if (markedVerts[vertI])
1233 outFile<<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
1238 Pout<<
"Written " << nVerts <<
" vertices to file " << fName <<
endl;
1257 label face1I = myFaces[0];
1259 if (myFaces.
size() == 2)
1261 face2I = myFaces[1];
1272 for (
const label facei : startFaces)
1274 edgeTris[nTris++] = facei;
1277 for (
const label facei : endFaces)
1279 if ((facei != face1I) && (facei != face2I))
1281 edgeTris[nTris++] = facei;
1295 const label v1 =
e.start();
1296 const label v2 =
e.
end();
1303 for (
const label edgei : v1Edges)
1305 vertexNeighbours.
insert(edges[edgei].otherVertex(v1));
1310 for (
const label edgei : v2Edges)
1312 vertexNeighbours.
insert(edges[edgei].otherVertex(v2));
1314 return vertexNeighbours.
toc();
1328 if (myFaces.
size() != 2)
1332 else if (facei == myFaces[0])
1355 label i0 = eFaces.
find(edgeI);
1360 <<
"Edge " << surf.
edges()[edgeI] <<
" not in face "
1364 label i1 = eFaces.
fcIndex(i0);
1365 label i2 = eFaces.
fcIndex(i1);
1389 else if (vertI ==
f[1])
1394 else if (vertI ==
f[2])
1402 <<
"Vertex " << vertI <<
" not in face " <<
f <<
nl
1418 for (
const label edgei : myEdges)
1429 <<
"Cannot find vertex " << vertI <<
" in edges of face " << facei
1448 for (
const label pointi :
f)
1457 <<
"Cannot find vertex opposite edge " << edgeI <<
" vertices " <<
e
1474 for (
const label edgei : v1Edges)
1496 if ((e0I == e1I) || (e0I == e2I) || (e1I == e2I))
1499 <<
"Duplicate edge labels : e0:" << e0I <<
" e1:" << e1I
1506 for (
const label facei : eFaces)
1513 || (myEdges[1] == e1I)
1514 || (myEdges[2] == e1I)
1520 || (myEdges[1] == e2I)
1521 || (myEdges[2] == e2I)
1575 return collapseEdges(surf, collapsableEdges, edgeMids, faceStatus);
1600 for (
const label edgei : collapseEdgeLabels)
1602 if (edgei < 0 || edgei >= surf.
nEdges())
1605 <<
"Edge label outside valid range." <<
endl
1606 <<
"edge label:" << edgei <<
endl
1607 <<
"total number of edges:" << surf.
nEdges() <<
endl
1611 const labelList& neighbours = edgeFaces[edgei];
1613 if (neighbours.
size() == 2)
1615 const label stat0 = faceStatus[neighbours[0]];
1616 const label stat1 = faceStatus[neighbours[1]];
1621 ((stat0 == ANYEDGE) || (stat0 == edgei))
1622 && ((stat1 == ANYEDGE) || (stat1 == edgei))
1625 const edge&
e = edges[edgei];
1630 (pointMap[
e.start()] !=
e.start())
1635 <<
"points already mapped. Double collapse." <<
endl
1636 <<
"edgei:" << edgei
1637 <<
" start:" <<
e.start()
1638 <<
" end:" <<
e.
end()
1639 <<
" pointMap[start]:" << pointMap[
e.start()]
1640 <<
" pointMap[end]:" << pointMap[
e.
end()]
1644 const label minVert =
min(
e.start(),
e.
end());
1645 pointMap[
e.start()] = minVert;
1646 pointMap[
e.
end()] = minVert;
1649 newPoints[minVert] = edgeMids[edgei];
1652 protectNeighbours(surf,
e.start(), faceStatus);
1653 protectNeighbours(surf,
e.
end(), faceStatus);
1657 oppositeVertex(surf, neighbours[0], edgei),
1663 oppositeVertex(surf, neighbours[1], edgei),
1675 forAll(collapseFaces, collapseI)
1677 faceStatus[collapseFaces[collapseI]] = COLLAPSED;
1691 forAll(localFaces, facei)
1693 if (faceStatus[facei] != COLLAPSED)
1699 f[0] = pointMap[
f[0]];
1700 f[1] = pointMap[
f[1]];
1701 f[2] = pointMap[
f[2]];
1705 newTriangles[nNewTris++] =
f;
1709 newTriangles.
resize(nNewTris);
1737 forAll(refineFaces, refineFacei)
1739 calcRefineStatus(surf, refineFaces[refineFacei], refineStatus);
1743 return doRefine(surf, refineStatus);
1765 for (
const label edgei : refineEdges)
1769 bool neighbourIsRefined=
false;
1771 for (
const label facei : myFaces)
1773 if (refineStatus[facei] != NONE)
1775 neighbourIsRefined =
true;
1780 if (!neighbourIsRefined)
1788 for (
const label facei : myFaces)
1801 refineStatus[facei] = GREEN;
1811 if (refineStatus[facei] == NONE)
1836 scalar minLen = GREAT;
1839 for (
const label edgei : edgeIndices)
1845 if (length < minLen)
1863 scalar maxLen = -GREAT;
1866 for (
const label edgei : edgeIndices)
1872 if (length > maxLen)
1887 const scalar mergeTol
1914 f[0] = pointMap[
f[0]];
1915 f[1] = pointMap[
f[1]];
1916 f[2] = pointMap[
f[2]];
1920 newTriangles[nNewTris++] =
f;
1923 newTriangles.
resize(nNewTris);
1944 const label nearestFacei,
1945 const point& nearestPt
1951 label nearType, nearLabel;
1953 f.nearestPointClassify(nearestPt,
points, nearType, nearLabel);
1963 label edgeI = surf.
faceEdges()[nearestFacei][nearLabel];
1970 for (
const label facei : eFaces)
1989 const point& nearestPoint,
1995 if (eFaces.
size() != 2)
2009 if (((
sample - nearestPoint) &
n) > 0)
2026 const label nearestFacei
2033 label nearType, nearLabel;
2044 scalar c = sampleNearestVec & surf.
faceNormals()[nearestFacei];
2092 label edgeI = surf.
faceEdges()[nearestFacei][nearLabel];
2116 return edgeSide(surf,
sample, nearestPoint, edgeI);
2126 label nearPointi = localF[nearLabel];
2130 const point& base = localPoints[nearPointi];
2135 label minEdgeI = -1;
2139 label edgeI = pEdges[i];
2141 const edge&
e = edges[edgeI];
2143 label otherPointi =
e.otherVertex(nearPointi);
2146 vector eVec(localPoints[otherPointi] - base);
2147 scalar magEVec =
mag(eVec);
2149 if (magEVec > VSMALL)
2154 const point perturbPoint = base + eVec;
2158 if (distSqr < minDistSqr)
2160 minDistSqr = distSqr;
2169 <<
"Problem: did not find edge closer than " << minDistSqr
2173 return edgeSide(surf,
sample, nearestPoint, minEdgeI);
2194 for (
const label patchi : includePatches)
2198 for (
const face&
f : patch)
2200 nTris +=
f.nTriangles(
points);
2206 label newPatchi = 0;
2209 for (
const label patchi : includePatches)
2214 label nTriTotal = 0;
2217 for (
const face&
f : patch)
2223 f.triangles(
points, nTri, triFaces);
2225 for (
const face&
f : triFaces)
2227 faceMap[nTris] = patch.start() + faceI;
2238 Pout<< patch.name() <<
" : generated " << nTriTotal
2239 <<
" triangles from " << patch.size() <<
" faces with"
2240 <<
" new patchid " << newPatchi <<
endl;
2258 surface.patches().
setSize(newPatchi);
2262 for (
const label patchi : includePatches)
2266 surface.patches()[newPatchi].name() = patch.name();
2267 surface.patches()[newPatchi].geometricType() = patch.type();
2289 label newPatchi = 0;
2291 for (
const label patchi : includePatches)
2296 label nTriTotal = 0;
2298 forAll(patch, patchFacei)
2300 const face&
f = patch[patchFacei];
2308 f.triangles(
points, nTri, triFaces);
2310 forAll(triFaces, triFacei)
2312 const face&
f = triFaces[triFacei];
2323 Pout<< patch.name() <<
" : generated " << nTriTotal
2324 <<
" triangles from " << patch.size() <<
" faces with"
2325 <<
" new patchid " << newPatchi <<
endl;
2343 surface.patches().
setSize(newPatchi);
2347 for (
const label patchi : includePatches)
2351 surface.patches()[newPatchi].name() = patch.name();
2352 surface.patches()[newPatchi].geometricType() = patch.type();
2383 forAll(faceCentres, facei)
2385 newPoints[
newPointi++] = faceCentres[facei];
2392 label newPatchi = 0;
2394 for (
const label patchi : includePatches)
2398 label nTriTotal = 0;
2400 forAll(patch, patchFacei)
2403 const face&
f = patch[patchFacei];
2406 label fc =
points.
size() + patchFacei + patch.start();
2420 Pout<< patch.name() <<
" : generated " << nTriTotal
2421 <<
" triangles from " << patch.size() <<
" faces with"
2422 <<
" new patchid " << newPatchi <<
endl;
2441 surface.patches().
setSize(newPatchi);
2445 for (
const label patchi : includePatches)
2449 surface.patches()[newPatchi].name() = patch.name();
2450 surface.patches()[newPatchi].geometricType() = patch.type();
2467 geompackVertices[doubleI++] = pt[0];
2468 geompackVertices[doubleI++] = pt[1];
2481 geompackVertices.
begin(),
2483 triangle_node.
begin(),
2484 triangle_neighbor.
begin()
2490 <<
"Failed dtris2 with vertices:" << pts.
size()
2495 triangle_node.
setSize(3*nTris);
2496 triangle_neighbor.
setSize(3*nTris);
2505 triangle_node[3*i]-1,
2506 triangle_node[3*i+1]-1,
2507 triangle_node[3*i+2]-1,
2515 points[i][0] = pts[i][0];
2516 points[i][1] = pts[i][1];
2534 edge[0] = tri.
c()-tri.
b();
2535 edge[1] = tri.
a()-tri.
c();
2536 edge[2] = tri.
b()-tri.
a();
2542 for (label i=0; i<3; i++)
2547 weights[0] = ((
p-tri.
b()) & normal[0]) /
max(VSMALL, normal[0] &
edge[1]);
2548 weights[1] = ((
p-tri.
c()) & normal[1]) /
max(VSMALL, normal[1] &
edge[2]);
2549 weights[2] = ((
p-tri.
a()) & normal[2]) /
max(VSMALL, normal[2] &
edge[0]);
2563 allVerts.setSize(samplePts.
size());
2564 allWeights.setSize(samplePts.
size());
2570 const point& samplePt = samplePts[i];
2575 scalar minDistance = GREAT;
2581 label nearType, nearLabel;
2597 calcInterpolationWeights(tri, nearest.
rawPoint(), weights);
2607 else if (nearest.
distance() < minDistance)
2615 verts[0] =
f[nearLabel];
2618 weights[1] = -GREAT;
2620 weights[2] = -GREAT;
2629 verts[0] =
f[nearLabel];
2649 weights[2] = -GREAT;
2663 calcInterpolationWeights(tri, nearest.
rawPoint(), weights);
2690 const FaceType&
f = surf[facei];
2693 for (
const label pointi :
f)
2695 if (pointi < 0 || pointi >= surf.
points().size())
2700 <<
"triangle " << facei <<
" vertices " <<
f
2701 <<
" uses point indices outside point range 0.."
2708 if (
f[0] ==
f[1] ||
f[0] ==
f[2] ||
f[1] ==
f[2])
2713 <<
"triangle " << facei
2714 <<
" uses non-unique vertices " <<
f
2726 for (
const label nbrFacei : fFaces)
2728 if (nbrFacei <= facei)
2734 const FaceType& nbrF = surf[nbrFacei];
2739 (
f[0] == nbrF[0] ||
f[0] == nbrF[1] ||
f[0] == nbrF[2])
2740 && (
f[1] == nbrF[0] ||
f[1] == nbrF[1] ||
f[1] == nbrF[2])
2741 && (
f[2] == nbrF[0] ||
f[2] == nbrF[1] ||
f[2] == nbrF[2])
2747 <<
"triangle " << facei <<
" vertices " <<
f
2748 <<
" has the same vertices as triangle " << nbrFacei
2749 <<
" vertices " << nbrF
2768 typedef face FaceType;
2769 const FaceType&
f = surf[facei];
2777 <<
" is not a triangle, it has " <<
f.
size()
2778 <<
" indices" <<
endl;
2784 for (
const label pointi :
f)
2786 if (pointi < 0 || pointi >= surf.
points().size())
2791 <<
"triangle " << facei <<
" vertices " <<
f
2792 <<
" uses point indices outside point range 0.."
2799 if (
f[0] ==
f[1] ||
f[0] ==
f[2] ||
f[1] ==
f[2])
2804 <<
"triangle " << facei
2805 <<
" uses non-unique vertices " <<
f
2817 for (
const label nbrFacei : fFaces)
2819 if (nbrFacei <= facei)
2825 const FaceType& nbrF = surf[nbrFacei];
2830 (
f[0] == nbrF[0] ||
f[0] == nbrF[1] ||
f[0] == nbrF[2])
2831 && (
f[1] == nbrF[0] ||
f[1] == nbrF[1] ||
f[1] == nbrF[2])
2832 && (
f[2] == nbrF[0] ||
f[2] == nbrF[1] ||
f[2] == nbrF[2])
2838 <<
"triangle " << facei <<
" vertices " <<
f
2839 <<
" has the same vertices as triangle " << nbrFacei
2840 <<
" vertices " << nbrF
2859 const point& trianglePoint
2865 label index, elemType;
2885 nearest.
setIndex(
s.faceEdges()[triI][index]);
2891 nearest.
setIndex(
s.localFaces()[triI][index]);
2904 const plane& cutPlane
2912 snapToEnd(
s, end, nearest);
2945 nearest = visitFaces
2960 nearest = visitFaces
2971 snapToEnd(
s, end, nearest);
2981 const plane& cutPlane,
2997 hitInfo = trackToEdge
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
void append(const T &val)
Copy append an element to the end of this list.
A 1D vector of objects of type <T> with a fixed length <N>.
Minimal example by using system/controlDict.functions:
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
void setSize(const label n)
Alias for resize()
void append(const T &val)
Append an element at the end of the list.
void resize(const label len)
Adjust allocated size of list.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
Output to file stream, using an OSstream.
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
const point_type & rawPoint() const noexcept
The point, no checks.
scalar distance() const noexcept
Return distance to hit.
bool hit() const noexcept
Is there a hit.
void setHit() noexcept
Set the hit status on.
const point_type & rawPoint() const noexcept
The point, no checks. Same as point()
void setIndex(const label index) noexcept
Set the index.
void setPoint(const point_type &p)
Set the point.
label index() const noexcept
Return the hit index.
void setMiss() noexcept
Set the hit status off.
bool hit() const noexcept
Is there a hit?
A list of faces which address into the list of points.
label nEdges() const
Number of edges in patch.
label nPoints() const
Number of points supporting patch faces.
const labelListList & pointEdges() const
Return point-edge addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
const Field< point_type > & pointNormals() const
Return point normals for patch.
const Field< point_type > & points() const noexcept
Return reference to global points.
const labelListList & faceFaces() const
Return face-face addressing.
const labelListList & pointFaces() const
Return point-face addressing.
const labelListList & edgeFaces() const
Return edge-face addressing.
const labelListList & faceEdges() const
Return face-edge addressing.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
iterator end() noexcept
Return an iterator to end traversing the UList.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
label fcIndex(const label i) const noexcept
const Cmpt & z() const
Access to the vector z component.
const Cmpt & y() const
Access to the vector y component.
const Cmpt & x() const
Access to the vector x component.
A bounding box defined in terms of min/max extrema points.
bool containsAny(const UList< point > &points) const
Contains any of the points? (inside or on edge)
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
virtual void track()
Do the actual tracking to fill the track data.
A triFace with additional (region) index.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
const vectorField & faceCentres() const
Patchify triangles based on orientation w.r.t other (triangulated or triangulatable) surfaces.
Contains information about location on a triSurface.
triPointRef::proxType & elementType() noexcept
label & triangle() noexcept
Triangulated surface description with patch information.
labelledTri face_type
The face type (same as the underlying PrimitivePatch)
const geometricSurfacePatchList & patches() const noexcept
A triangle primitive used to calculate face normals and swept volumes.
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:
const Point & c() const
Return third vertex.
const Point & b() const
Return second vertex.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const volScalarField & p0
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int dtris2(int point_num, double point_xy[], int *tri_num, int tri_vert[], int tri_nabe[])
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))
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf())
Geometric merging of points. See below.
#define WarningInFunction
Report a warning using Foam::Warning.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
PointFrompoint toPoint(const Foam::point &p)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
label mergePoints(const PointList &points, labelList &pointToUnique, labelList &uniquePoints, const scalar mergeTol=SMALL, const bool verbose=false)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
triangle< point, const point & > triPointRef
A triangle using referred points.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
List< edge > edgeList
A List of edges.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
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]
const dimensionedScalar & D
#define forAll(list, i)
Loop across all elements in list.