38 namespace triIntersect
60 return bStar == 0 ? 0 :
max(a*
sign(
b), 0)/bStar;
92 if (groups[i] ==
group)
106 if (groups[i] ==
group)
117 if (groups[i] ==
group)
126 if (groups[i] ==
group)
130 phi =
max(phi,
n*
x[i]/(
n*
x[i] - 1));
136 phi =
max(phi,
n*xn/(
n*xn - 1));
141 if (groups[i] ==
group)
143 y[i] =
min(
max((1 - phi)*
x[i] + phi/
n, 0), 1);
168 const vector CuCtut = Cu + Ctu*t;
173 CuCtut & CuCtut, CuCtut & CvCtvt,
174 CvCtvt & CuCtut, CvCtvt & CvCtvt
182 const scalar detA =
det(
A);
214 ((
C ^ Ctu) & Ctv) + ((Ct ^ Cu) & Ctv) + ((Ct ^ Ctu) &
Cv),
215 ((
C ^ Cu) & Ctv) + ((
C ^ Ctu) &
Cv) + ((Ct ^ Cu) &
Cv),
226 if (
mag(tRoots[tRooti]) > great)
continue;
243 tuvs[nTuvs ++] = tuv;
248 for (
label i = 0; i < nTuvs; ++ i)
250 const vector tuvOld = tuvs[i];
256 for (
label i = 0; i < nTuvs - 1; ++ i)
258 for (
label j = 0; j < nTuvs - 1; ++ j)
260 if (tuvClippage[j] > tuvClippage[j + 1])
262 Swap(tuvs[j], tuvs[j + 1]);
263 Swap(tuvClippage[j], tuvClippage[j + 1]);
270 for (
label i = 0; i < nTuvs; ++ i)
272 const scalar t = tuvs[i].x(), u = tuvs[i].y(), v = tuvs[i].z();
274 const scalar magSqrF =
275 magSqr(
C + Ct*t + Cu*u +
Cv*v + Ctu*t*u + Ctv*t*v);
276 const scalar magSqrErrF =
287 if (magSqrF < magSqrErrF)
313 const triPointRef tgtTri(tgtPs[0], tgtPs[1], tgtPs[2]);
320 srcFwd[srcPi] = (srcNs[srcPi] & tgtN) <
maxDot;
331 const label tgtPi0 = tgtEi, tgtPi1 = (tgtEi + 1) % 3;
332 result[srcPi][tgtEi] =
337 {tgtPs[tgtPi0], tgtPs[tgtPi1]},
350 result[srcPi] = {-vGreat, -vGreat, -vGreat};
360 const label srcPi0 = srcEi, srcPi1 = (srcEi + 1) % 3;
362 if (srcFwd[srcPi0] != srcFwd[srcPi1])
369 maxDot - (srcNs[srcPi0] & tgtN),
370 (srcNs[srcPi1] - srcNs[srcPi0]) & tgtN
372 const point srcP = (1 - srcT)*srcPs[srcPi0] + srcT*srcPs[srcPi1];
373 const vector srcN = (1 - srcT)*srcNs[srcPi0] + srcT*srcNs[srcPi1];
377 const label tgtPi0 = tgtEi, tgtPi1 = (tgtEi + 1) % 3;
378 result[srcFwd[srcPi0] ? srcPi1 : srcPi0][tgtEi] =
383 {tgtPs[tgtPi0], tgtPs[tgtPi1]},
413 const label srcPi0 = srcEi, srcPi1 = (srcEi + 1) % 3;
414 result[tgtPi][srcEi] =
417 {srcPs[srcPi0], srcPs[srcPi1]},
418 {srcNs[srcPi0], srcNs[srcPi1]},
439 forAll(thisOtherEdgeOffset, thisPi)
441 forAll(thisOtherEdgeOffset[thisPi], otherEi)
443 result[thisPi][otherEi] =
444 thisOtherEdgeOffset[thisPi][otherEi] > 0 ? +1 : -1;
483 const triPointRef tgtTri(tgtPs[0], tgtPs[1], tgtPs[2]);
490 forAll(tgtInSrcEdge, tgtPi)
492 if (result[tgtPi] == 1)
497 const bool tgtFwd = (srcN & tgtN) <
maxDot;
498 result[tgtPi] = tgtFwd ? +1 : -1;
515 forAll(thisOtherPis, thisPi)
517 const label otherPi = thisOtherPis[thisPi];
521 const label otherEi0 = (otherPi + 2) % 3, otherEi1 = otherPi;
594 order[nVisited ++] = i0;
650 auto branch = [&](
const bool isSrcEdge)
671 && (branch(
true) || branch(
false))
683 order[-- nVisited] = -1;
705 forAll(srcInTgtEdge, srcEi)
708 forAll(tgtInSrcEdge, tgtPi)
710 if (tgtInSrcEdge[tgtPi][srcEi] == 1)
725 if (
count(srcInTgtEdge, {-1, -1, -1}) == 3)
733 auto addPointLocations = [&pointLocations]
737 const bool add = true
740 if (!pointLocations.
empty())
772 label srcEj = srcEi0;
774 srcEj = (srcEj + 2) % 3
785 pointLocations.
append(l1);
789 pointLocations.
append(l2);
795 auto inTriToOut = [&addPointLocations,&srcInTgtEdge]
798 const label tgtOutSrcEi1,
799 const label tgtOutSrcPi1,
806 : srcInTgtEdge[tgtOutSrcPi1][tgtEi] == 1
807 ? (tgtOutSrcPi1 + 2*
reverse) % 3
808 : (tgtOutSrcPi1 + 2*!
reverse) % 3;
814 auto isPointToOutEdge = [&addPointLocations,&srcInTgtEdge]
817 const label tgtIsSrcPi0,
818 const label tgtOutSrcEi1,
823 const label srcEi0Opp = (tgtIsSrcPi0 + 1) % 3;
827 srcInTgtEdge[(tgtIsSrcPi0 + 1) % 3][tgtEi] == -1
828 && srcInTgtEdge[(tgtIsSrcPi0 + 2) % 3][tgtEi] == -1
834 if (tgtOutSrcEi1 == srcEi0Next)
839 if (tgtOutSrcEi1 == srcEi0Opp)
849 auto isPointToOutCorner = []
852 const label tgtIsSrcPi0,
853 const label tgtOutSrcPi1,
857 return tgtOutSrcPi1 != (tgtIsSrcPi0 + 1 +
reverse) % 3;
861 auto outEdgeToOutEdge = [&addPointLocations,&srcInTgtEdge]
864 const label tgtOutSrcEi0,
865 const label tgtOutSrcEi1
868 const label srcPi = (5 - tgtOutSrcEi0 - tgtOutSrcEi1) % 3;
872 (tgtOutSrcEi0 != (tgtOutSrcEi1 + 1) % 3)
873 && (srcInTgtEdge[srcPi][tgtEi] != 1)
881 (tgtOutSrcEi0 == (tgtOutSrcEi1 + 1) % 3)
882 != (srcInTgtEdge[srcPi][tgtEi] == 1)
897 auto outEdgeToOutCorner = [&addPointLocations,&srcInTgtEdge]
900 const label tgtOutSrcEi0,
901 const label tgtOutSrcPi1,
905 if (tgtOutSrcEi0 == tgtOutSrcPi1)
910 if ((tgtOutSrcEi0 + 1) % 3 == tgtOutSrcPi1)
915 const label srcPi1Prev = (tgtOutSrcPi1 + 1 + !
reverse) % 3;
917 if (srcInTgtEdge[srcPi1Prev][tgtEi] == -1)
922 const label srcPi1Next = (tgtOutSrcPi1 + 1 +
reverse) % 3;
924 if (srcInTgtEdge[srcPi1Next][tgtEi] == 1)
932 srcInTgtEdge[tgtOutSrcPi1][tgtEi] == 1
933 ? (tgtOutSrcPi1 + 2*
reverse) % 3
934 : (tgtOutSrcPi1 + 2*!
reverse) % 3;
943 addPointLocations(l1, l2);
949 auto outCornerToOutCorner = []
952 const label tgtOutSrcPi0,
953 const label tgtOutSrcPi1
956 return tgtOutSrcPi0 != (tgtOutSrcPi1 + 2) % 3;
960 for (
label tgtEi = 0; tgtEi < 3; tgtEi ++)
962 const label tgtPi0 = tgtEi, tgtPi1 = (tgtEi + 1) % 3;
964 const bool tgtInSrcTri0 =
tgtInSrcTri[tgtPi0] == 1;
965 const bool tgtInSrcTri1 =
tgtInSrcTri[tgtPi1] == 1;
967 const label tgtIsSrcPi0 =
969 const label tgtIsSrcPi1 =
972 const label tgtOutSrcEi0 =
973 count(tgtInSrcEdge[tgtPi0], -1) == 1
976 const label tgtOutSrcEi1 =
977 count(tgtInSrcEdge[tgtPi1], -1) == 1
981 const label tgtOutSrcPi0 =
982 count(tgtInSrcEdge[tgtPi0], -1) == 2
983 ? (
findIndex(tgtInSrcEdge[tgtPi0], 1) + 2) % 3
985 const label tgtOutSrcPi1 =
986 count(tgtInSrcEdge[tgtPi1], -1) == 2
987 ? (
findIndex(tgtInSrcEdge[tgtPi1], 1) + 2) % 3
995 if (tgtIsSrcPi0 != -1)
1003 (tgtInSrcTri0 && tgtInSrcTri1)
1004 || (tgtOutSrcEi0 != -1 && tgtOutSrcEi0 == tgtOutSrcEi1)
1005 || (tgtOutSrcPi0 != -1 && tgtOutSrcPi0 == tgtOutSrcPi1)
1013 (tgtInSrcTri0 && tgtIsSrcPi1 != -1)
1014 || (tgtIsSrcPi0 != -1 && tgtInSrcTri1)
1020 else if (tgtInSrcTri0 && (tgtOutSrcEi1 != -1 || tgtOutSrcPi1 != -1))
1024 inTriToOut(tgtEi, tgtOutSrcEi1, tgtOutSrcPi1, 0);
1026 else if ((tgtOutSrcEi0 != -1 || tgtOutSrcPi0 != -1) && tgtInSrcTri1)
1029 inTriToOut(tgtEi, tgtOutSrcEi0, tgtOutSrcPi0, 1);
1031 else if (tgtIsSrcPi0 != -1 && tgtIsSrcPi1 != -1)
1035 if (tgtIsSrcPi0 != (tgtIsSrcPi1 + 1) % 3)
1037 pointLocations.
clear();
1041 else if (tgtIsSrcPi0 != -1 && tgtOutSrcEi1 != -1)
1045 if (!isPointToOutEdge(tgtEi, tgtIsSrcPi0, tgtOutSrcEi1, 0))
1047 pointLocations.
clear();
1051 else if (tgtOutSrcEi0 != -1 && tgtIsSrcPi1 != -1)
1054 if (!isPointToOutEdge(tgtEi, tgtIsSrcPi1, tgtOutSrcEi0, 1))
1056 pointLocations.
clear();
1060 else if (tgtIsSrcPi0 != -1 && tgtOutSrcPi1 != -1)
1064 if (!isPointToOutCorner(tgtEi, tgtIsSrcPi0, tgtOutSrcPi1, 0))
1066 pointLocations.
clear();
1070 else if (tgtOutSrcPi0 != -1 && tgtIsSrcPi1 != -1)
1073 if (!isPointToOutCorner(tgtEi, tgtIsSrcPi1, tgtOutSrcPi0, 1))
1075 pointLocations.
clear();
1079 else if (tgtOutSrcEi0 != -1 && tgtOutSrcEi1 != -1)
1082 if (!outEdgeToOutEdge(tgtEi, tgtOutSrcEi0, tgtOutSrcEi1))
1084 pointLocations.
clear();
1088 else if (tgtOutSrcEi0 != -1 && tgtOutSrcPi1 != -1)
1092 if (!outEdgeToOutCorner(tgtEi, tgtOutSrcEi0, tgtOutSrcPi1, 0))
1094 pointLocations.
clear();
1098 else if (tgtOutSrcPi0 != -1 && tgtOutSrcEi1 != -1)
1101 if (!outEdgeToOutCorner(tgtEi, tgtOutSrcEi1, tgtOutSrcPi0, 1))
1103 pointLocations.
clear();
1107 else if (tgtOutSrcPi0 != -1 && tgtOutSrcPi1 != -1)
1110 if (!outCornerToOutCorner(tgtEi, tgtOutSrcPi0, tgtOutSrcPi1))
1112 pointLocations.
clear();
1120 pointLocations.
clear();
1127 if (!pointLocations.
empty())
1133 addPointLocations(l,
location(),
false);
1166 srcPointNormals.
resize(pointLocations.
size());
1169 forAll(pointLocations, pointi)
1171 const location& l = pointLocations[pointi];
1179 srcPoints[pointi] = srcP;
1180 srcPointNormals[pointi] = srcN;
1181 tgtPoints[pointi] = tgtP;
1197 if (tgtTs[iMid] < 0)
1205 const scalar t = tgtTs[iMax] + tgtTs[iMid];
1212 srcPoints[pointi] = srcP;
1213 srcPointNormals[pointi] = srcN;
1224 tgtPoints[pointi] = tgtP;
1228 const label srcPi0 = l.
srcEdgei(), srcPi1 = (srcPi0 + 1) % 3;
1229 const label tgtPi0 = l.
tgtEdgei(), tgtPi1 = (tgtPi0 + 1) % 3;
1234 {srcPs[srcPi0], srcPs[srcPi1]},
1235 {srcNs[srcPi0], srcNs[srcPi1]},
1236 {tgtPs[tgtPi0], tgtPs[tgtPi1]}
1238 const scalar srcT = ts.
first(), tgtT = ts.
second();
1241 (1 - srcT)*srcPs[srcPi0] + srcT*srcPs[srcPi1];
1242 srcPointNormals[pointi] =
1243 (1 - srcT)*srcNs[srcPi0] + srcT*srcNs[srcPi1];
1245 (1 - tgtT)*tgtPs[tgtPi0] + tgtT*tgtPs[tgtPi1];
1262 const label nNormal,
1263 const scalar lNormal
1266 scalar lengthScale = 0;
1267 for (
label i = 0; i < 3; ++ i)
1269 lengthScale =
max(lengthScale,
mag(srcPs[i] - srcPs[(i + 1) % 3]));
1272 const label nu = nEdge, nv = nNormal;
1273 const scalar
u0 = 0, u1 = 1;
1274 const scalar v0 = -lNormal/2*lengthScale, v1 = lNormal/2*lengthScale;
1277 for (
label i = 0; i < 3; ++ i)
1279 const point& p0 = srcPs[i], p1 = srcPs[(i + 1) % 3];
1280 const vector& n0 = srcNs[i], n1 = srcNs[(i + 1) % 3];
1282 for (
label iu = 0; iu <= nu; ++ iu)
1284 const scalar u =
u0 + (u1 -
u0)*scalar(iu)/nu;
1285 for (
label iv = 0; iv <= nv; ++ iv)
1287 const scalar v = v0 + (v1 - v0)*scalar(iv)/nv;
1288 const vector x = p0 + (p1 - p0)*u + (n0 + (n1 - n0)*u)*v;
1289 ps[i*(nu + 1)*(nv + 1) + iu*(nv + 1) + iv] =
x;
1295 for (
label i = 0; i < 3; ++ i)
1297 for (
label iu = 0; iu < nu; ++ iu)
1299 for (
label iv = 0; iv < nv; ++ iv)
1301 fs[i*nu*nv + iu*nv + iv] =
1304 i*(nu + 1)*(nv + 1) + (nv + 1)*iu + iv,
1305 i*(nu + 1)*(nv + 1) + (nv + 1)*iu + iv + 1,
1306 i*(nu + 1)*(nv + 1) + (nv + 1)*(iu + 1) + iv + 1,
1307 i*(nu + 1)*(nv + 1) + (nv + 1)*(iu + 1) + iv
1334 const tensor A(srcPs[1] - srcPs[0], srcNs[0], srcNs[1]);
1335 const scalar detA =
det(
A);
1339 const vector detAY =
T & (tgtP - srcPs[0]);
1342 const scalar
offset = Yx*detAY.
y() - (1 - Yx)*detAY.
z();
1353 const bool srcDirection
1374 const tensor A(srcN, tgtPs[1] - tgtPs[0], srcN^(tgtPs[1] - tgtPs[0]));
1375 const scalar detA =
det(
A);
1379 const vector detAY =
T & (tgtPs[0] - srcP);
1392 const bool tgtDirection
1419 srcPs[0] - tgtPs[0],
1420 srcPs[1] - srcPs[0],
1421 tgtPs[0] - tgtPs[1],
1424 srcNs[1] - srcNs[0],
1486 scalar tgtT0 = 0, tgtT1 = 1;
1491 const scalar
s = o0 > o1 ? +1 : -1;
1495 const scalar tgtT = (tgtT0 + tgtT1)/2;
1496 const vector tgtP = (1 - tgtT)*tgtPs[0] + tgtT*tgtPs[1];
1510 tgtT = (tgtT0 + tgtT1)/2;
1513 const vector srcDP = srcPs[1] - srcPs[0];
1514 const vector tgtP = (1 - tgtT)*tgtPs[0] + tgtT*tgtPs[1];
1516 const tensor A(srcDP, srcNs[0], srcNs[1]);
1517 const scalar detA =
det(
A);
1521 const scalar magDetAYx =
sign(detA)*(Tx & (tgtP - srcPs[0]));
1525 const vector srcN = (1 - srcTStar)*srcNs[0] + srcTStar*srcNs[1];
1527 const vector srcDPPerpN = srcDP - (srcDP & srcN)*srcN;
1532 (tgtP - srcPs[0]) & srcDPPerpN,
1567 const scalar srcT0 = 1 - srcTs.x() - srcTs.y();
1568 return srcT0*srcPNs[0] + srcTs.x()*srcPNs[1] + srcTs.y()*srcPNs[2];
1571 auto srcEdgePNs = [srcPN]
1578 return Pair<vector>(srcPN(srcPNs, srcTs0), srcPN(srcPNs, srcTs1));
1585 srcEdgePNs(srcPs, srcTs0, srcTs1),
1586 srcEdgePNs(srcNs, srcTs0, srcTs1),
1597 if (offsets[
findMin(offsets)] >= 0 || offsets[
findMax(offsets)] <= 0)
1607 srcPs[1] - srcPs[0],
1608 srcPs[2] - srcPs[0],
1609 srcNs[1] - srcNs[0],
1610 srcNs[2] - srcNs[0],
1623 const scalar
sign = offsets[
findMin(offsets)] > 0 ? +1 : -1;
1625 vector2D srcTsA(0, 0), srcTsB(1, 0), srcTsC(0, 1);
1629 const vector2D srcTsAB = (srcTsA + srcTsB)/2;
1630 const vector2D srcTsBC = (srcTsB + srcTsC)/2;
1631 const vector2D srcTsCA = (srcTsC + srcTsA)/2;
1633 const scalar oA =
sign*
offset(srcTsCA, srcTsAB);
1634 const scalar oB =
sign*
offset(srcTsAB, srcTsBC);
1635 const scalar oC =
sign*
offset(srcTsBC, srcTsCA);
1639 if (offsets[offsetMini] > 0)
1645 else if (offsetMini == 0)
1650 else if (offsetMini == 1)
1655 else if (offsetMini == 2)
1662 srcT = (srcTsA[0] + srcTsB[0] + srcTsC[0])/3;
1663 srcU = (srcTsA[1] + srcTsB[1] + srcTsC[1])/3;
1672 const label srcEi0 = (srcEi + 2) % 3, srcEi1 = (srcEi + 1) % 3;
1677 && offsets[srcEi0] >= 0
1678 && offsets[srcEi1] >= 0
1681 const label srcPi0 = srcEi, srcPi1 = (srcEi + 1) % 3;
1682 const label srcPiOpp = (srcEi + 2) % 3;
1690 srcPs[srcPi0] - tgtP,
1691 srcPs[srcPi1] - srcPs[srcPi0],
1692 srcPs[srcPi0] - srcPs[srcPiOpp],
1694 srcPs[srcPi1] - srcPs[srcPi0],
1695 srcNs[srcPi1] - srcNs[srcPi0],
1708 const vector2D srcTsOpp(srcPiOpp == 1, srcPiOpp == 2);
1709 const vector2D srcTs0(srcPi0 == 1, srcPi0 == 2);
1710 const vector2D srcTs1(srcPi1 == 1, srcPi1 == 2);
1712 scalar srcT0 = 0, srcT1 = 1;
1716 const scalar srcT = (srcT0 + srcT1)/2;
1717 const vector2D srcTs01(srcTs0*(1 - srcT) + srcTs1*srcT);
1719 const scalar o =
offset(srcTsOpp, srcTs01);
1731 srcT = (srcT0 + srcT1)/2;
1735 srcPs[srcPi0] - tgtP,
1736 srcPs[srcPi1] - srcPs[srcPi0],
1737 srcPs[srcPi0] - srcPs[srcPiOpp],
1739 srcPs[srcPi1] - srcPs[srcPi0],
1740 srcNs[srcPi1] - srcNs[srcPi0],
1748 y[srcPiOpp] = - srcU;
1749 y[srcPi0] = (1 + srcU)*(1 - srcT);
1750 y[srcPi1] = (1 + srcU)*srcT;
1758 const label srcEiOpp = (srcPi + 1) % 3;
1759 const label srcEi0 = (srcPi + 2) % 3, srcEi1 = srcPi;
1763 offsets[srcEiOpp] >= 0
1764 && offsets[srcEi0] <= 0
1765 && offsets[srcEi1] <= 0
1769 const label srcPi0 = (srcPi + 2) % 3, srcPi1 = (srcPi + 1) % 3;
1773 srcPs[srcPi] - srcPs[srcPi0],
1774 srcPs[srcPi] - srcPs[srcPi1],
1778 const scalar detA =
A.x() &
T0;
1789 y[srcPi] = 1 + srcT + srcU;
1796 <<
"Point " << tgtP <<
" could not be classified within triangle "
1797 << srcPs <<
" with projection normals " << srcNs <<
exit(
FatalError);
1798 return barycentric2D::uniform(NaN);
1809 const tensor A(tgtPs[1] - tgtPs[0], tgtPs[2] - tgtPs[0], - srcN);
1810 const scalar detA =
det(
A);
1815 const vector detAY = (
T & (srcP - tgtPs[0])) +
vector(detA, 0, 0);
1820 if (maxMagDetAY/vGreat <
mag(detA))
1830 if (maxMagDetAY > 0)
1832 const vector y = detAY/maxMagDetAY*vGreat;
1838 A.x() &
A.x(),
A.x() &
A.y(),
1839 A.y() &
A.x(),
A.y() &
A.y()
1841 const scalar detA2(
det(A2));
1846 T2 &
vector2D(
A.x() & (srcP - tgtPs[0]),
A.y() & (srcP - tgtPs[0]));
1852 if (maxMagDetAY2/vGreat <
mag(detA2))
1879 const word& writePrefix
1882 const bool write = writePrefix != word::null;
1901 srcPs, srcNs, srcOwns, srcTgtPis,
1908 srcPs, srcNs, srcOwns,
1909 tgtPs, tgtOwns, tgtSrcPis,
1916 if (
count(srcTgtPis, -1) != 3)
1921 <<
indent <<
"srcInTgtEdge=" << srcInTgtEdge <<
endl;
1922 if (
count(tgtSrcPis, -1) != 3)
1927 <<
indent <<
"tgtInSrcEdge=" << tgtInSrcEdge <<
endl;
static const Foam::dimensionedScalar A("A", Foam::dimPressure, 611.21)
static const Foam::dimensionedScalar B("B", Foam::dimless, 18.678)
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
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(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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const char *const group
Group name for atomic constants.
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.
scalar protectedDivideAndClip01(const scalar a, const scalar b)
Divide two numbers, protect the result from overflowing, and clip the.
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.
scalar protectedDivide(const scalar a, const scalar b)
Divide two numbers and protect the result from overflowing.
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
dimensionedScalar det(const dimensionedSphericalTensor &dt)
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.
word name(const bool)
Return a word representation of a bool.
void inplaceReverseList(ListType &list)
Inplace reversal of a list using Swap.
int order(const scalar s)
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 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.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensionSet cmptMag(const dimensionSet &)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
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.
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
void offset(label &lst, const label o)
Ostream & indent(Ostream &os)
Indent stream.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
dimensionedScalar cos(const dimensionedScalar &ds)
Functions with which to perform an intersection of a pair of triangles; the source and target....