38 namespace triIntersect
75 if (groups[i] ==
group)
89 if (groups[i] ==
group)
100 if (groups[i] ==
group)
109 if (groups[i] ==
group)
113 phi =
max(phi,
n*
x[i]/(
n*
x[i] - 1));
119 phi =
max(phi,
n*xn/(
n*xn - 1));
124 if (groups[i] ==
group)
126 y[i] =
min(
max((1 - phi)*
x[i] + phi/
n, 0), 1);
151 const vector CuCtut = Cu + Ctu*t;
156 CuCtut & CuCtut, CuCtut & CvCtvt,
157 CvCtvt & CuCtut, CvCtvt & CvCtvt
165 const scalar detA =
det(
A);
197 ((
C ^ Ctu) & Ctv) + ((Ct ^ Cu) & Ctv) + ((Ct ^ Ctu) &
Cv),
198 ((
C ^ Cu) & Ctv) + ((
C ^ Ctu) &
Cv) + ((Ct ^ Cu) &
Cv),
209 if (
mag(tRoots[tRooti]) > great)
continue;
226 tuvs[nTuvs ++] = tuv;
231 for (
label i = 0; i < nTuvs; ++ i)
233 const vector tuvOld = tuvs[i];
239 for (
label i = 0; i < nTuvs - 1; ++ i)
241 for (
label j = 0; j < nTuvs - 1; ++ j)
243 if (tuvClippage[j] > tuvClippage[j + 1])
245 Swap(tuvs[j], tuvs[j + 1]);
246 Swap(tuvClippage[j], tuvClippage[j + 1]);
253 for (
label i = 0; i < nTuvs; ++ i)
255 const scalar t = tuvs[i].x(), u = tuvs[i].y(), v = tuvs[i].z();
257 const scalar magSqrF =
258 magSqr(
C + Ct*t + Cu*u +
Cv*v + Ctu*t*u + Ctv*t*v);
259 const scalar magSqrErrF =
270 if (magSqrF < magSqrErrF)
296 const triPointRef tgtTri(tgtPs[0], tgtPs[1], tgtPs[2]);
303 srcFwd[srcPi] = (srcNs[srcPi] & tgtN) <
maxDot;
314 const label tgtPi0 = tgtEi, tgtPi1 = (tgtEi + 1) % 3;
315 result[srcPi][tgtEi] =
320 {tgtPs[tgtPi0], tgtPs[tgtPi1]},
333 result[srcPi] = {-vGreat, -vGreat, -vGreat};
343 const label srcPi0 = srcEi, srcPi1 = (srcEi + 1) % 3;
345 if (srcFwd[srcPi0] != srcFwd[srcPi1])
352 maxDot - (srcNs[srcPi0] & tgtN),
353 (srcNs[srcPi1] - srcNs[srcPi0]) & tgtN
355 const point srcP = (1 - srcT)*srcPs[srcPi0] + srcT*srcPs[srcPi1];
356 const vector srcN = (1 - srcT)*srcNs[srcPi0] + srcT*srcNs[srcPi1];
360 const label tgtPi0 = tgtEi, tgtPi1 = (tgtEi + 1) % 3;
361 result[srcFwd[srcPi0] ? srcPi1 : srcPi0][tgtEi] =
366 {tgtPs[tgtPi0], tgtPs[tgtPi1]},
396 const label srcPi0 = srcEi, srcPi1 = (srcEi + 1) % 3;
397 result[tgtPi][srcEi] =
400 {srcPs[srcPi0], srcPs[srcPi1]},
401 {srcNs[srcPi0], srcNs[srcPi1]},
422 forAll(thisOtherEdgeOffset, thisPi)
424 forAll(thisOtherEdgeOffset[thisPi], otherEi)
426 result[thisPi][otherEi] =
427 thisOtherEdgeOffset[thisPi][otherEi] > 0 ? +1 : -1;
466 const triPointRef tgtTri(tgtPs[0], tgtPs[1], tgtPs[2]);
473 forAll(tgtInSrcEdge, tgtPi)
475 if (result[tgtPi] == 1)
480 const bool tgtFwd = (srcN & tgtN) <
maxDot;
481 result[tgtPi] = tgtFwd ? +1 : -1;
498 forAll(thisOtherPis, thisPi)
500 const label otherPi = thisOtherPis[thisPi];
504 const label otherEi0 = (otherPi + 2) % 3, otherEi1 = otherPi;
577 order[nVisited ++] = i0;
633 auto branch = [&](
const bool isSrcEdge)
654 && (branch(
true) || branch(
false))
666 order[-- nVisited] = -1;
688 forAll(srcInTgtEdge, srcEi)
691 forAll(tgtInSrcEdge, tgtPi)
693 if (tgtInSrcEdge[tgtPi][srcEi] == 1)
708 if (
count(srcInTgtEdge, {-1, -1, -1}) == 3)
716 auto addPointLocations = [&pointLocations]
720 const bool add = true
723 if (!pointLocations.
empty())
755 label srcEj = srcEi0;
757 srcEj = (srcEj + 2) % 3
768 pointLocations.
append(l1);
772 pointLocations.
append(l2);
778 auto inTriToOut = [&addPointLocations,&srcInTgtEdge]
781 const label tgtOutSrcEi1,
782 const label tgtOutSrcPi1,
789 : srcInTgtEdge[tgtOutSrcPi1][tgtEi] == 1
790 ? (tgtOutSrcPi1 + 2*
reverse) % 3
791 : (tgtOutSrcPi1 + 2*!
reverse) % 3;
797 auto isPointToOutEdge = [&addPointLocations,&srcInTgtEdge]
800 const label tgtIsSrcPi0,
801 const label tgtOutSrcEi1,
806 const label srcEi0Opp = (tgtIsSrcPi0 + 1) % 3;
810 srcInTgtEdge[(tgtIsSrcPi0 + 1) % 3][tgtEi] == -1
811 && srcInTgtEdge[(tgtIsSrcPi0 + 2) % 3][tgtEi] == -1
817 if (tgtOutSrcEi1 == srcEi0Next)
822 if (tgtOutSrcEi1 == srcEi0Opp)
832 auto isPointToOutCorner = []
835 const label tgtIsSrcPi0,
836 const label tgtOutSrcPi1,
840 return tgtOutSrcPi1 != (tgtIsSrcPi0 + 1 +
reverse) % 3;
844 auto outEdgeToOutEdge = [&addPointLocations,&srcInTgtEdge]
847 const label tgtOutSrcEi0,
848 const label tgtOutSrcEi1
851 const label srcPi = (5 - tgtOutSrcEi0 - tgtOutSrcEi1) % 3;
855 (tgtOutSrcEi0 != (tgtOutSrcEi1 + 1) % 3)
856 && (srcInTgtEdge[srcPi][tgtEi] != 1)
864 (tgtOutSrcEi0 == (tgtOutSrcEi1 + 1) % 3)
865 != (srcInTgtEdge[srcPi][tgtEi] == 1)
880 auto outEdgeToOutCorner = [&addPointLocations,&srcInTgtEdge]
883 const label tgtOutSrcEi0,
884 const label tgtOutSrcPi1,
888 if (tgtOutSrcEi0 == tgtOutSrcPi1)
893 if ((tgtOutSrcEi0 + 1) % 3 == tgtOutSrcPi1)
898 const label srcPi1Prev = (tgtOutSrcPi1 + 1 + !
reverse) % 3;
900 if (srcInTgtEdge[srcPi1Prev][tgtEi] == -1)
905 const label srcPi1Next = (tgtOutSrcPi1 + 1 +
reverse) % 3;
907 if (srcInTgtEdge[srcPi1Next][tgtEi] == 1)
915 srcInTgtEdge[tgtOutSrcPi1][tgtEi] == 1
916 ? (tgtOutSrcPi1 + 2*
reverse) % 3
917 : (tgtOutSrcPi1 + 2*!
reverse) % 3;
926 addPointLocations(l1, l2);
932 auto outCornerToOutCorner = []
935 const label tgtOutSrcPi0,
936 const label tgtOutSrcPi1
939 return tgtOutSrcPi0 != (tgtOutSrcPi1 + 2) % 3;
943 for (
label tgtEi = 0; tgtEi < 3; tgtEi ++)
945 const label tgtPi0 = tgtEi, tgtPi1 = (tgtEi + 1) % 3;
947 const bool tgtInSrcTri0 =
tgtInSrcTri[tgtPi0] == 1;
948 const bool tgtInSrcTri1 =
tgtInSrcTri[tgtPi1] == 1;
950 const label tgtIsSrcPi0 =
952 const label tgtIsSrcPi1 =
955 const label tgtOutSrcEi0 =
956 count(tgtInSrcEdge[tgtPi0], -1) == 1
959 const label tgtOutSrcEi1 =
960 count(tgtInSrcEdge[tgtPi1], -1) == 1
964 const label tgtOutSrcPi0 =
965 count(tgtInSrcEdge[tgtPi0], -1) == 2
966 ? (
findIndex(tgtInSrcEdge[tgtPi0], 1) + 2) % 3
968 const label tgtOutSrcPi1 =
969 count(tgtInSrcEdge[tgtPi1], -1) == 2
970 ? (
findIndex(tgtInSrcEdge[tgtPi1], 1) + 2) % 3
978 if (tgtIsSrcPi0 != -1)
986 (tgtInSrcTri0 && tgtInSrcTri1)
987 || (tgtOutSrcEi0 != -1 && tgtOutSrcEi0 == tgtOutSrcEi1)
988 || (tgtOutSrcPi0 != -1 && tgtOutSrcPi0 == tgtOutSrcPi1)
996 (tgtInSrcTri0 && tgtIsSrcPi1 != -1)
997 || (tgtIsSrcPi0 != -1 && tgtInSrcTri1)
1003 else if (tgtInSrcTri0 && (tgtOutSrcEi1 != -1 || tgtOutSrcPi1 != -1))
1007 inTriToOut(tgtEi, tgtOutSrcEi1, tgtOutSrcPi1, 0);
1009 else if ((tgtOutSrcEi0 != -1 || tgtOutSrcPi0 != -1) && tgtInSrcTri1)
1012 inTriToOut(tgtEi, tgtOutSrcEi0, tgtOutSrcPi0, 1);
1014 else if (tgtIsSrcPi0 != -1 && tgtIsSrcPi1 != -1)
1018 if (tgtIsSrcPi0 != (tgtIsSrcPi1 + 1) % 3)
1020 pointLocations.
clear();
1024 else if (tgtIsSrcPi0 != -1 && tgtOutSrcEi1 != -1)
1028 if (!isPointToOutEdge(tgtEi, tgtIsSrcPi0, tgtOutSrcEi1, 0))
1030 pointLocations.
clear();
1034 else if (tgtOutSrcEi0 != -1 && tgtIsSrcPi1 != -1)
1037 if (!isPointToOutEdge(tgtEi, tgtIsSrcPi1, tgtOutSrcEi0, 1))
1039 pointLocations.
clear();
1043 else if (tgtIsSrcPi0 != -1 && tgtOutSrcPi1 != -1)
1047 if (!isPointToOutCorner(tgtEi, tgtIsSrcPi0, tgtOutSrcPi1, 0))
1049 pointLocations.
clear();
1053 else if (tgtOutSrcPi0 != -1 && tgtIsSrcPi1 != -1)
1056 if (!isPointToOutCorner(tgtEi, tgtIsSrcPi1, tgtOutSrcPi0, 1))
1058 pointLocations.
clear();
1062 else if (tgtOutSrcEi0 != -1 && tgtOutSrcEi1 != -1)
1065 if (!outEdgeToOutEdge(tgtEi, tgtOutSrcEi0, tgtOutSrcEi1))
1067 pointLocations.
clear();
1071 else if (tgtOutSrcEi0 != -1 && tgtOutSrcPi1 != -1)
1075 if (!outEdgeToOutCorner(tgtEi, tgtOutSrcEi0, tgtOutSrcPi1, 0))
1077 pointLocations.
clear();
1081 else if (tgtOutSrcPi0 != -1 && tgtOutSrcEi1 != -1)
1084 if (!outEdgeToOutCorner(tgtEi, tgtOutSrcEi1, tgtOutSrcPi0, 1))
1086 pointLocations.
clear();
1090 else if (tgtOutSrcPi0 != -1 && tgtOutSrcPi1 != -1)
1093 if (!outCornerToOutCorner(tgtEi, tgtOutSrcPi0, tgtOutSrcPi1))
1095 pointLocations.
clear();
1103 pointLocations.
clear();
1110 if (!pointLocations.
empty())
1116 addPointLocations(l,
location(),
false);
1149 srcPointNormals.
resize(pointLocations.
size());
1152 forAll(pointLocations, pointi)
1154 const location& l = pointLocations[pointi];
1162 srcPoints[pointi] = srcP;
1163 srcPointNormals[pointi] = srcN;
1164 tgtPoints[pointi] = tgtP;
1180 if (tgtTs[iMid] < 0)
1188 const scalar t = tgtTs[iMax] + tgtTs[iMid];
1195 srcPoints[pointi] = srcP;
1196 srcPointNormals[pointi] = srcN;
1207 tgtPoints[pointi] = tgtP;
1211 const label srcPi0 = l.
srcEdgei(), srcPi1 = (srcPi0 + 1) % 3;
1212 const label tgtPi0 = l.
tgtEdgei(), tgtPi1 = (tgtPi0 + 1) % 3;
1217 {srcPs[srcPi0], srcPs[srcPi1]},
1218 {srcNs[srcPi0], srcNs[srcPi1]},
1219 {tgtPs[tgtPi0], tgtPs[tgtPi1]}
1221 const scalar srcT = ts.
first(), tgtT = ts.
second();
1224 (1 - srcT)*srcPs[srcPi0] + srcT*srcPs[srcPi1];
1225 srcPointNormals[pointi] =
1226 (1 - srcT)*srcNs[srcPi0] + srcT*srcNs[srcPi1];
1228 (1 - tgtT)*tgtPs[tgtPi0] + tgtT*tgtPs[tgtPi1];
1245 const label nNormal,
1246 const scalar lNormal
1249 scalar lengthScale = 0;
1250 for (
label i = 0; i < 3; ++ i)
1252 lengthScale =
max(lengthScale,
mag(srcPs[i] - srcPs[(i + 1) % 3]));
1255 const label nu = nEdge, nv = nNormal;
1256 const scalar
u0 = 0, u1 = 1;
1257 const scalar v0 = -lNormal/2*lengthScale, v1 = lNormal/2*lengthScale;
1260 for (
label i = 0; i < 3; ++ i)
1262 const point& p0 = srcPs[i], & p1 = srcPs[(i + 1) % 3];
1263 const vector& n0 = srcNs[i], & n1 = srcNs[(i + 1) % 3];
1265 for (
label iu = 0; iu <= nu; ++ iu)
1267 const scalar u =
u0 + (u1 -
u0)*scalar(iu)/nu;
1268 for (
label iv = 0; iv <= nv; ++ iv)
1270 const scalar v = v0 + (v1 - v0)*scalar(iv)/nv;
1271 const vector x = p0 + (p1 - p0)*u + (n0 + (n1 - n0)*u)*v;
1272 ps[i*(nu + 1)*(nv + 1) + iu*(nv + 1) + iv] =
x;
1278 for (
label i = 0; i < 3; ++ i)
1280 for (
label iu = 0; iu < nu; ++ iu)
1282 for (
label iv = 0; iv < nv; ++ iv)
1284 fs[i*nu*nv + iu*nv + iv] =
1287 i*(nu + 1)*(nv + 1) + (nv + 1)*iu + iv,
1288 i*(nu + 1)*(nv + 1) + (nv + 1)*iu + iv + 1,
1289 i*(nu + 1)*(nv + 1) + (nv + 1)*(iu + 1) + iv + 1,
1290 i*(nu + 1)*(nv + 1) + (nv + 1)*(iu + 1) + iv
1317 const tensor A(srcPs[1] - srcPs[0], srcNs[0], srcNs[1]);
1318 const scalar detA =
det(
A);
1322 const vector detAY =
T & (tgtP - srcPs[0]);
1325 const scalar
offset = Yx*detAY.
y() - (1 - Yx)*detAY.
z();
1336 const bool srcDirection
1357 const tensor A(srcN, tgtPs[1] - tgtPs[0], srcN^(tgtPs[1] - tgtPs[0]));
1358 const scalar detA =
det(
A);
1362 const vector detAY =
T & (tgtPs[0] - srcP);
1375 const bool tgtDirection
1402 srcPs[0] - tgtPs[0],
1403 srcPs[1] - srcPs[0],
1404 tgtPs[0] - tgtPs[1],
1407 srcNs[1] - srcNs[0],
1469 scalar tgtT0 = 0, tgtT1 = 1;
1474 const scalar
s = o0 > o1 ? +1 : -1;
1478 const scalar tgtT = (tgtT0 + tgtT1)/2;
1479 const vector tgtP = (1 - tgtT)*tgtPs[0] + tgtT*tgtPs[1];
1493 tgtT = (tgtT0 + tgtT1)/2;
1496 const vector srcDP = srcPs[1] - srcPs[0];
1497 const vector tgtP = (1 - tgtT)*tgtPs[0] + tgtT*tgtPs[1];
1499 const tensor A(srcDP, srcNs[0], srcNs[1]);
1500 const scalar detA =
det(
A);
1504 const scalar magDetAYx =
sign(detA)*(Tx & (tgtP - srcPs[0]));
1508 const vector srcN = (1 - srcTStar)*srcNs[0] + srcTStar*srcNs[1];
1510 const vector srcDPPerpN = srcDP - (srcDP & srcN)*srcN;
1515 (tgtP - srcPs[0]) & srcDPPerpN,
1550 const scalar srcT0 = 1 - srcTs.x() - srcTs.y();
1551 return srcT0*srcPNs[0] + srcTs.x()*srcPNs[1] + srcTs.y()*srcPNs[2];
1554 auto srcEdgePNs = [srcPN]
1561 return Pair<vector>(srcPN(srcPNs, srcTs0), srcPN(srcPNs, srcTs1));
1568 srcEdgePNs(srcPs, srcTs0, srcTs1),
1569 srcEdgePNs(srcNs, srcTs0, srcTs1),
1580 if (offsets[
findMin(offsets)] >= 0 || offsets[
findMax(offsets)] <= 0)
1590 srcPs[1] - srcPs[0],
1591 srcPs[2] - srcPs[0],
1592 srcNs[1] - srcNs[0],
1593 srcNs[2] - srcNs[0],
1606 const scalar
sign = offsets[
findMin(offsets)] > 0 ? +1 : -1;
1608 vector2D srcTsA(0, 0), srcTsB(1, 0), srcTsC(0, 1);
1612 const vector2D srcTsAB = (srcTsA + srcTsB)/2;
1613 const vector2D srcTsBC = (srcTsB + srcTsC)/2;
1614 const vector2D srcTsCA = (srcTsC + srcTsA)/2;
1616 const scalar oA =
sign*
offset(srcTsCA, srcTsAB);
1617 const scalar oB =
sign*
offset(srcTsAB, srcTsBC);
1618 const scalar oC =
sign*
offset(srcTsBC, srcTsCA);
1622 if (offsets[offsetMini] > 0)
1628 else if (offsetMini == 0)
1633 else if (offsetMini == 1)
1638 else if (offsetMini == 2)
1645 srcT = (srcTsA[0] + srcTsB[0] + srcTsC[0])/3;
1646 srcU = (srcTsA[1] + srcTsB[1] + srcTsC[1])/3;
1655 const label srcEi0 = (srcEi + 2) % 3, srcEi1 = (srcEi + 1) % 3;
1660 && offsets[srcEi0] >= 0
1661 && offsets[srcEi1] >= 0
1664 const label srcPi0 = srcEi, srcPi1 = (srcEi + 1) % 3;
1665 const label srcPiOpp = (srcEi + 2) % 3;
1673 srcPs[srcPi0] - tgtP,
1674 srcPs[srcPi1] - srcPs[srcPi0],
1675 srcPs[srcPi0] - srcPs[srcPiOpp],
1677 srcPs[srcPi1] - srcPs[srcPi0],
1678 srcNs[srcPi1] - srcNs[srcPi0],
1691 const vector2D srcTsOpp(srcPiOpp == 1, srcPiOpp == 2);
1692 const vector2D srcTs0(srcPi0 == 1, srcPi0 == 2);
1693 const vector2D srcTs1(srcPi1 == 1, srcPi1 == 2);
1695 scalar srcT0 = 0, srcT1 = 1;
1699 const scalar srcT = (srcT0 + srcT1)/2;
1700 const vector2D srcTs01(srcTs0*(1 - srcT) + srcTs1*srcT);
1702 const scalar o =
offset(srcTsOpp, srcTs01);
1714 srcT = (srcT0 + srcT1)/2;
1718 srcPs[srcPi0] - tgtP,
1719 srcPs[srcPi1] - srcPs[srcPi0],
1720 srcPs[srcPi0] - srcPs[srcPiOpp],
1722 srcPs[srcPi1] - srcPs[srcPi0],
1723 srcNs[srcPi1] - srcNs[srcPi0],
1731 y[srcPiOpp] = - srcU;
1732 y[srcPi0] = (1 + srcU)*(1 - srcT);
1733 y[srcPi1] = (1 + srcU)*srcT;
1741 const label srcEiOpp = (srcPi + 1) % 3;
1742 const label srcEi0 = (srcPi + 2) % 3, srcEi1 = srcPi;
1746 offsets[srcEiOpp] >= 0
1747 && offsets[srcEi0] <= 0
1748 && offsets[srcEi1] <= 0
1752 const label srcPi0 = (srcPi + 2) % 3, srcPi1 = (srcPi + 1) % 3;
1756 srcPs[srcPi] - srcPs[srcPi0],
1757 srcPs[srcPi] - srcPs[srcPi1],
1761 const scalar detA =
A.x() &
T0;
1772 y[srcPi] = 1 + srcT + srcU;
1779 <<
"Point " << tgtP <<
" could not be classified within triangle "
1780 << srcPs <<
" with projection normals " << srcNs <<
exit(
FatalError);
1781 return barycentric2D::uniform(NaN);
1792 const tensor A(tgtPs[1] - tgtPs[0], tgtPs[2] - tgtPs[0], - srcN);
1793 const scalar detA =
det(
A);
1798 const vector detAY = (
T & (srcP - tgtPs[0])) +
vector(detA, 0, 0);
1803 if (maxMagDetAY/vGreat <
mag(detA))
1813 if (maxMagDetAY > 0)
1815 const vector y = detAY/maxMagDetAY*vGreat;
1821 A.x() &
A.x(),
A.x() &
A.y(),
1822 A.y() &
A.x(),
A.y() &
A.y()
1824 const scalar detA2(
det(A2));
1829 T2 &
vector2D(
A.x() & (srcP - tgtPs[0]),
A.y() & (srcP - tgtPs[0]));
1835 if (maxMagDetAY2/vGreat <
mag(detA2))
1862 const word& writePrefix
1865 const bool write = writePrefix != word::null;
1884 srcPs, srcNs, srcOwns, srcTgtPis,
1891 srcPs, srcNs, srcOwns,
1892 tgtPs, tgtOwns, tgtSrcPis,
1899 if (
count(srcTgtPis, -1) != 3)
1904 <<
indent <<
"srcInTgtEdge=" << srcInTgtEdge <<
endl;
1905 if (
count(tgtSrcPis, -1) != 3)
1910 <<
indent <<
"tgtInSrcEdge=" << tgtInSrcEdge <<
endl;
scalar Cv(const scalar p, const scalar T) const
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Templated 2D Barycentric derived from VectorSpace. Has 3 components, one of which is redundant.
Graphite solid properties.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void resize(const label)
Alter the addressed list size.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void clear()
Clear the addressed list, i.e. set the size to zero.
A 1D vector of objects of type <T> with a fixed size <Size>.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const Type & second() const
Return second.
const Type & first() const
Return first.
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
void type(const direction i, const rootType t)
Set the type of the i-th root.
Templated 2D tensor derived from VectorSpace adding construction from 4 components,...
A 2-tuple for storing two objects of different types.
T * first()
Return the first entry.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Return the first element of the list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
T & last()
Return the last element of the list.
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
Cubic equation of the form a*x^3 + b*x^2 + c*x + d = 0.
Roots< 3 > roots(const bool real=false) const
Get the roots.
A face is a list of labels corresponding to mesh vertices.
Selector class for relaxation factors, solver type and solution.
bool isTgtNotSrcPoint() const
Return whether the location is a target point and not a source.
static location intersection(const label srcEi, const label tgtEi)
Construct an intersection location between a source and a.
bool isTgtPoint() const
Return whether the location is a target point.
label tgtEdgei() const
Return the target edge index.
static location srcTgtPoint(const label srcPi, const label tgtPi)
Construct a source and target point location.
bool isSrcNotTgtPoint() const
Return whether the location is a source point and not a target.
static location tgtPoint(const label tgtPi)
Construct a target point location.
label srcPointi() const
Return the source point index.
label tgtPointi() const
Return the target point index.
bool isSrcAndTgtPoint() const
Return whether the location is a source point and a target point.
bool isIntersection() const
Return whether the location is an intersection.
bool isSrcPoint() const
Return whether the location is a source point.
label srcEdgei() const
Return the source edge index.
static location srcPoint(const label srcPi)
Construct a source point location.
A triangle primitive used to calculate face areas and swept volumes.
vector normal() const
Return unit normal.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const char *const group
Group name for atomic constants.
static const coefficient B("B", dimless, 18.678)
static const coefficient A("A", dimPressure, 611.21)
barycentric2D srcPointTgtTriIntersection(const point &srcP, const vector &srcN, const FixedList< point, 3 > &tgtPs)
Calculate the intersection of a projected source point with a target.
scalar srcPointTgtEdgeOffset(const point &srcP, const vector &srcN, const Pair< point > &tgtPs)
Calculate the signed offset of a projected source point in relation to a.
void tgtInSrc(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< bool, 3 > &srcOwns, const FixedList< point, 3 > &tgtPs, const FixedList< bool, 3 > &tgtOwns, const FixedList< label, 3 > &tgtSrcPis, FixedList< FixedList< label, 3 >, 3 > &tgtInSrcEdge, FixedList< label, 3 > &tgtInSrcTri)
Calculate whether the points of the given target triangle project inside or.
void generateGeometry(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< point, 3 > &tgtPs, DynamicList< point > &srcPoints, DynamicList< vector > &srcPointNormals, DynamicList< point > &tgtPoints, const DynamicList< location > &pointLocations)
Construct the intersection geometry.
barycentric2D srcTriTgtPointIntersection(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const point &tgtP)
Calculate the intersection of a target point with a source triangle's.
Tuple2< bool, vector > solveProjection(const vector &C, const vector &Ct, const vector &Cu, const vector &Cv, const vector &Ctu, const vector &Ctv, const FixedList< label, 3 > groups)
Solve a projection equation.
void writeTriProjection(const word &name, const FixedList< point, 3 > &srcTriPs, const FixedList< vector, 3 > &srcTriNs, const label nEdge=20, const label nNormal=20, const scalar lNormal=0.5)
Write a VTK file of a triangle projection.
FixedList< FixedList< scalar, 3 >, 3 > tgtSrcEdgeOffset(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< bool, 3 > &srcOwns, const FixedList< point, 3 > &tgtPs, const FixedList< bool, 3 > &tgtOwns)
Calculate the non-dimensional offsets the target points from the source.
void srcInTgt(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< bool, 3 > &srcOwns, const FixedList< label, 3 > &srcTgtPis, const FixedList< point, 3 > &tgtPs, const FixedList< bool, 3 > &tgtOwns, FixedList< FixedList< label, 3 >, 3 > &srcInTgtEdge, FixedList< label, 3 > &srcInTgtTri)
Calculate whether the points of the given source triangle project inside or.
void thisIsOther(const FixedList< label, 3 > &thisOtherPis, FixedList< FixedList< label, 3 >, 3 > &thisInOtherEdge, FixedList< label, 3 > &thisInOtherTri)
Override results of the srcInTgt/tgtInSrc calculations with explicit.
FixedList< label, 3 > tgtInSrcTri(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< point, 3 > &tgtPs, const FixedList< FixedList< label, 3 >, 3 > &tgtInSrcEdge)
Construct target-point-inside/outside-source-triangle topology from a set.
FixedList< FixedList< label, 3 >, 3 > thisInOtherEdge(const FixedList< FixedList< scalar, 3 >, 3 > &thisOtherEdgeOffset)
Construct point-inside/outside-edge topology from a set of point-edge.
Ostream & operator<<(Ostream &os, const FixedList< FixedList< Type, 3 >, 3 > &l)
Print 3x3 FixedListLists on one line.
bool generateLocations(const FixedList< label, 3 > &tgtSrcPis, const FixedList< FixedList< label, 3 >, 3 > &srcInTgtEdge, const FixedList< FixedList< label, 3 >, 3 > &tgtInSrcEdge, const FixedList< label, 3 > &srcInTgtTri, const FixedList< label, 3 > &tgtInSrcTri, DynamicList< location > &pointLocations)
Construct the intersection topology.
vector clipped01(const vector x, const FixedList< label, 3 > groups)
Clip the given vector between values of 0 and 1, and also clip one minus.
const scalar maxDot
The maximum dot product between a source point normal and a target plane.
FixedList< label, 3 > thisInOtherTri(const FixedList< FixedList< label, 3 >, 3 > &thisInOtherEdge)
Construct point-inside/outside-triangle topology from a set of.
scalar srcEdgeTgtPointOffset(const Pair< point > &srcPs, const Pair< vector > &srcNs, const point &tgtP)
Calculate the signed offset of a target point in relation to a projected.
vector solveProjectionGivenT(const vector &C, const vector &Ct, const vector &Cu, const vector &Cv, const vector &Ctu, const vector &Ctv, const FixedList< label, 3 > groups, const scalar t)
Solve a projection equation given a value of the t variable.
Type tgtTriInterpolate(const barycentric2D &y, const FixedList< Type, 3 > &tgtPsis)
Use the coordinates obtained from srcPointTgtTriIntersection to interpolate.
void writePolygon(const word &name, const PointField &ps)
Write a VTK file of a polygon.
FixedList< FixedList< scalar, 3 >, 3 > srcTgtEdgeOffset(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< bool, 3 > &srcOwns, const FixedList< point, 3 > &tgtPs, const FixedList< bool, 3 > &tgtOwns)
Calculate the non-dimensional offsets of the source points from the target.
bool orderLocations(const UList< location > &locations, bool isSrcEdge, const label i0, label &nVisited, boolList &visited, labelList &order)
Order intersection locations into a polygon.
Pair< scalar > srcEdgeTgtEdgeIntersection(const Pair< point > &srcPs, const Pair< vector > &srcNs, const Pair< point > &tgtPs)
Calculate the intersection of a target edge with a source edge's.
Type srcTriInterpolate(const barycentric2D &y, const FixedList< Type, 3 > &tgtPsis)
Use the coordinates obtained from srcTriTgtPointIntersection to interpolate.
void intersectTris(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< bool, 3 > &srcOwns, const FixedList< label, 3 > &srcTgtPis, const FixedList< point, 3 > &tgtPs, const FixedList< bool, 3 > &tgtOwns, const FixedList< label, 3 > &tgtSrcPis, DynamicList< point > &srcPoints, DynamicList< vector > &srcPointNormals, DynamicList< point > &tgtPoints, DynamicList< location > &pointLocations, const bool debug, const word &writePrefix=word::null)
Construct the intersection of a source triangle's projected volume and a.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Vector2D< scalar > vector2D
vector2D obtained from generic Vector2D
Scalar protectedDivideAndClip01(const Scalar a, const Scalar b)
Divide two numbers, protect the result from overflowing, and clip the.
Scalar protectedDivide(const Scalar a, const Scalar b)
Divide two numbers and protect the result from overflowing.
errorManipArg< error, int > exit(error &err, const int errNo=1)
scalar degToRad(const scalar deg)
Convert degrees to radians.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
List< label > labelList
A List of labels.
label log2(label i)
Return the log base 2 by successive bit-shifting of the given label.
dimensionedScalar sign(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
label findMax(const ListType &, const label start=0)
Find index of max element (and larger than given element).
Ostream & endl(Ostream &os)
Add newline and flush stream.
void inplaceReverseList(ListType &list)
Inplace reversal of a list using Swap.
int order(const scalar s)
void T(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
void det(LagrangianPatchField< scalar > &f, const LagrangianPatchField< tensor > &f1)
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
void reverse(UList< T > &, const label n)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Vector< scalar > vector
A scalar version of the templated Vector.
List< labelList > labelListList
A List of labelList.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
label findMin(const ListType &, const label start=0)
Find index of min element (and less than given element).
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
void add(LagrangianPatchField< typename typeOfSum< Type1, Type2 >::type > &f, const LagrangianPatchField< Type1 > &f1, const LagrangianPatchField< Type2 > &f2)
void offset(label &lst, const label o)
Ostream & indent(Ostream &os)
Indent stream.
void cmptMag(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
dimensionedScalar cos(const dimensionedScalar &ds)
Functions with which to perform an intersection of a pair of triangles; the source and target....