40 #include "PatchTools.H"
56 x.setSize(sz+
y.size());
70 const scalar featureCos,
84 if (isFeatureEdge[pEdges[i]])
88 for (
label j = i+1; j < pEdges.
size(); j++)
90 if (isFeatureEdge[pEdges[j]])
92 const edge& eI = edges[pEdges[i]];
93 const edge& eJ = edges[pEdges[j]];
100 scalar vIMag =
mag(vI);
103 scalar vJMag =
mag(vJ);
109 && ((vI/vIMag & vJ/vJMag) < featureCos)
140 for (
label avgIter = 0; avgIter < 20; avgIter++)
161 forAll(pointEdges, pointI)
163 const labelList& pEdges = pointEdges[pointI];
165 label nConstraints = constraints[pointI].first();
167 if (nConstraints <= 1)
171 label edgeI = pEdges[i];
173 if (isPatchMasterEdge[edgeI])
175 label nbrPointI = edges[edgeI].otherVertex(pointI);
176 if (constraints[nbrPointI].first() >= nConstraints)
178 dispSum[pointI] += disp[nbrPointI];
186 syncTools::syncPointList
195 syncTools::syncPointList
206 forAll(constraints, pointI)
208 if (dispCount[pointI] > 0)
213 *(disp[pointI] + dispSum[pointI]/dispCount[pointI]);
235 faceDisp.setSize(pp.size());
236 faceDisp = vector::zero;
237 faceSurfaceNormal.setSize(pp.size());
238 faceSurfaceNormal = vector::zero;
239 faceSurfaceGlobalRegion.
setSize(pp.size());
240 faceSurfaceGlobalRegion = -1;
244 surfaceZonesInfo::getNamedSurfaces(surfaces.
surfZones());
246 surfaceZonesInfo::getUnnamedSurfaces(surfaces.
surfZones());
261 label zoneSurfI = zonedSurfaces[i];
263 const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
266 label zoneI =
mesh.faceZones().findZoneID(faceZoneName);
270 <<
"Problem. Cannot find zone " << faceZoneName
277 isZonedFace[fZone[i]] = 1;
282 forAll(pp.addressing(), i)
284 if (isZonedFace[pp.addressing()[i]])
286 snapSurf[i] = zoneSurfI;
288 meshFaces.
append(pp.addressing()[i]);
322 if (hitInfo[hitI].hit())
324 label faceI = ppFaces[hitI];
325 faceDisp[faceI] = hitInfo[hitI].hitPoint() - fc[hitI];
326 faceSurfaceNormal[faceI] = hitNormal[hitI];
336 <<
"Did not find surface near face centre " << fc[hitI]
349 forAll(pp.addressing(), i)
351 if (snapSurf[i] == -1)
354 meshFaces.
append(pp.addressing()[i]);
386 if (hitInfo[hitI].hit())
388 label faceI = ppFaces[hitI];
389 faceDisp[faceI] = hitInfo[hitI].hitPoint() - fc[hitI];
390 faceSurfaceNormal[faceI] = hitNormal[hitI];
400 <<
"Did not find surface near face centre " << fc[hitI]
453 const labelList& faceSurfaceGlobalRegion,
470 pointFaceSurfNormals.setSize(pp.
nPoints());
471 pointFaceDisp.setSize(pp.
nPoints());
472 pointFaceCentres.setSize(pp.
nPoints());
485 if (isMasterFace[faceI] && faceSurfaceGlobalRegion[faceI] != -1)
492 List<point>& pNormals = pointFaceSurfNormals[pointI];
498 labelList& pFid = pointFacePatchID[pointI];
505 label globalRegionI = faceSurfaceGlobalRegion[faceI];
507 if (isMasterFace[faceI] && globalRegionI != -1)
509 pNormals[nFaces] = faceSurfaceNormal[faceI];
510 pDisp[nFaces] = faceDisp[faceI];
512 pFid[nFaces] = globalToMasterPatch_[globalRegionI];
535 if (pp.
coupled() || isA<emptyPolyPatch>(pp))
540 patchID[meshFaceI-
mesh.nInternalFaces()] = -1;
546 forAll(pp.addressing(), i)
548 label meshFaceI = pp.addressing()[i];
549 patchID[meshFaceI-
mesh.nInternalFaces()] = -1;
560 localPointRegion::findDuplicateFaces(
mesh, pp.addressing())
572 const edge&
e = edges[edgeI];
573 const labelList& eFaces = edgeFaces[edgeI];
575 if (eFaces.
size() == 1)
578 isBoundaryPoint[
e[0]] =
true;
579 isBoundaryPoint[
e[1]] =
true;
581 else if (eFaces.
size() == 2 && bafflePair[eFaces[0]] == eFaces[1])
584 isBoundaryPoint[
e[0]] =
true;
585 isBoundaryPoint[
e[1]] =
true;
594 meshToPatchPoint[pp.
meshPoints()[pointI]] = pointI;
599 label patchI = patchID[bFaceI];
603 label faceI =
mesh.nInternalFaces()+bFaceI;
608 label pointI = meshToPatchPoint[
f[fp]];
610 if (pointI != -1 && isBoundaryPoint[pointI])
612 List<point>& pNormals = pointFaceSurfNormals[pointI];
615 labelList& pFid = pointFacePatchID[pointI];
630 syncTools::syncPointList
634 pointFaceSurfNormals,
639 syncTools::syncPointList
648 syncTools::syncPointList
657 syncTools::syncPointList
670 forAll(pointFaceDisp, pointI)
672 List<point>& pNormals = pointFaceSurfNormals[pointI];
675 labelList& pFid = pointFacePatchID[pointI];
702 scalar tang = ((pt-edgePt)&edgeNormal);
707 if (order[0] < order[1])
711 vector attractD = surfacePoints[order[0]]-edgePt;
713 scalar tang2 = (attractD&edgeNormal);
715 attractD -= tang2*edgeNormal;
717 scalar magAttractD =
mag(attractD);
718 scalar fraction = magAttractD/(magAttractD+
mag(edgeOffset));
722 + ((1.0-fraction)*tang2 + fraction*tang)*edgeNormal;
723 edgeOffset = linePt-pt;
738 label patch0 = patchIDs[0];
740 for (
label i = 1; i < patchIDs.
size(); i++)
742 if (patchIDs[i] != patch0)
754 const scalar featureCos,
763 scalar cosAngle = (
n&surfaceNormals[j]);
767 (cosAngle >= featureCos)
768 || (cosAngle < (-1+0.001))
793 if (patchIDs.empty())
799 label patch0 = patchIDs[0];
801 for (
label i = 1; i < patchIDs.
size(); i++)
803 if (patchIDs[i] != patch0)
817 if (surfaceNormals.size() == 1)
825 labelList normalToPatch(surfaceNormals.size(), -1);
826 forAll(faceToNormalBin, i)
828 if (faceToNormalBin[i] != -1)
830 label& patch = normalToPatch[faceToNormalBin[i]];
836 else if (patch == -2)
840 else if (patch != patchIDs[i])
848 forAll(normalToPatch, normalI)
850 if (normalToPatch[normalI] == -2)
872 label nMasterPoints = 0;
877 forAll(patchConstraints, pointI)
879 if (isPatchMasterPoint[pointI])
883 if (patchConstraints[pointI].first() == 1)
887 else if (patchConstraints[pointI].first() == 2)
891 else if (patchConstraints[pointI].first() == 3)
902 Info<<
"total master points :" << nMasterPoints
903 <<
" of which attracted to :" <<
nl
904 <<
" feature point : " << nPoint <<
nl
905 <<
" feature edge : " << nEdge <<
nl
906 <<
" nearest surface : " << nPlanar <<
nl
907 <<
" rest : " << nMasterPoints-nPoint-nEdge-nPlanar
916 const scalar featureCos,
936 patchAttraction = vector::zero;
939 const List<point>& pfSurfNormals = pointFaceSurfNormals[pointI];
941 const List<point>& pfCentres = pointFaceCentres[pointI];
951 surfacePoints.
clear();
952 surfaceNormals.
clear();
956 faceToNormalBin = -1;
960 const point& fc = pfCentres[i];
961 const vector& fSNormal = pfSurfNormals[i];
962 const vector& fDisp = pfDisp[i];
965 if (
magSqr(fDisp) <
sqr(snapDist[pointI]) &&
mag(fSNormal) > VSMALL)
967 const point pt = fc + fDisp;
970 faceToNormalBin[i] = findNormal
977 if (faceToNormalBin[i] != -1)
985 if (surfacePoints.size() <= 1)
988 faceToNormalBin[i] = surfaceNormals.size();
989 surfaceNormals.
append(fSNormal);
991 else if (surfacePoints.size() == 2)
993 plane pl0(surfacePoints[0], surfaceNormals[0]);
994 plane pl1(surfacePoints[1], surfaceNormals[1]);
998 if (
mag(fSNormal&featureNormal) >= 0.001)
1001 surfacePoints.
append(pt);
1002 faceToNormalBin[i] = surfaceNormals.size();
1003 surfaceNormals.
append(fSNormal);
1006 else if (surfacePoints.size() == 3)
1010 plane pl0(surfacePoints[0], surfaceNormals[0]);
1011 plane pl1(surfacePoints[1], surfaceNormals[1]);
1012 plane pl2(surfacePoints[2], surfaceNormals[2]);
1017 if (
mag(fSNormal&featureNormal) >= 0.001)
1019 plane pl3(pt, fSNormal);
1022 if (
mag(p012-p013) > snapDist[pointI])
1025 surfacePoints.
append(pt);
1026 faceToNormalBin[i] = surfaceNormals.size();
1027 surfaceNormals.
append(fSNormal);
1039 if (surfaceNormals.size() == 1)
1043 ((surfacePoints[0]-pt) & surfaceNormals[0])
1052 patchAttraction = d;
1057 else if (surfaceNormals.size() == 2)
1059 plane pl0(surfacePoints[0], surfaceNormals[0]);
1060 plane pl1(surfacePoints[1], surfaceNormals[1]);
1074 patchAttraction = d;
1080 else if (surfaceNormals.size() == 3)
1083 plane pl0(surfacePoints[0], surfaceNormals[0]);
1084 plane pl1(surfacePoints[1], surfaceNormals[1]);
1085 plane pl2(surfacePoints[2], surfaceNormals[2]);
1087 vector d = cornerPt - pt;
1095 patchAttraction = d;
1109 const scalar featureCos,
1126 if (debug&meshRefinement::ATTRACTION)
1132 meshRefiner_.mesh().time().path()
1133 /
"implicitFeatureEdge_" +
name(iter) +
".obj"
1136 Info<<
"Dumping implicit feature-edge direction to "
1137 << feStr().name() <<
endl;
1143 meshRefiner_.mesh().time().path()
1144 /
"implicitFeaturePoint_" +
name(iter) +
".obj"
1147 Info<<
"Dumping implicit feature-point direction to "
1148 << fpStr().name() <<
endl;
1158 vector attraction = vector::zero;
1161 featureAttractionUsingReconstruction
1172 pointFaceSurfNormals,
1187 (constraint.
first() > patchConstraints[pointI].first())
1189 (constraint.
first() == patchConstraints[pointI].first())
1190 && (
magSqr(attraction) <
magSqr(patchAttraction[pointI]))
1194 patchAttraction[pointI] = attraction;
1195 patchConstraints[pointI] = constraint;
1199 if (patchConstraints[pointI].first() == 2 && feStr.
valid())
1201 feStr().write(
linePointRef(pt, pt+patchAttraction[pointI]));
1203 else if (patchConstraints[pointI].first() == 3 && fpStr.
valid())
1205 fpStr().write(
linePointRef(pt, pt+patchAttraction[pointI]));
1215 const scalar featureCos,
1254 forAll(pointEdges, pointI)
1256 if (patchConstraints[pointI].first() == 2)
1259 const labelList& pEdges = pointEdges[pointI];
1260 const vector& featVec = patchConstraints[pointI].second();
1264 bool hasPos =
false;
1265 bool hasNeg =
false;
1270 label nbrPointI =
e.otherVertex(pointI);
1272 if (patchConstraints[nbrPointI].first() > 1)
1275 const point featPt =
1276 nbrPt + patchAttraction[nbrPointI];
1277 const scalar cosAngle = (featVec & (featPt-pt));
1290 if (!hasPos || !hasNeg)
1296 label bestPosPointI = -1;
1297 scalar minPosDistSqr = GREAT;
1298 label bestNegPointI = -1;
1299 scalar minNegDistSqr = GREAT;
1304 label nbrPointI =
e.otherVertex(pointI);
1308 patchConstraints[nbrPointI].first() <= 1
1309 && rawPatchConstraints[nbrPointI].first() > 1
1312 const vector& nbrFeatVec =
1313 rawPatchConstraints[pointI].second();
1315 if (
mag(featVec&nbrFeatVec) > featureCos)
1322 rawPatchAttraction[nbrPointI]
1325 const point featPt =
1327 + rawPatchAttraction[nbrPointI];
1328 const scalar cosAngle =
1329 (featVec & (featPt-pt));
1333 if (!hasPos && d2 < minPosDistSqr)
1336 bestPosPointI = nbrPointI;
1341 if (!hasNeg && d2 < minNegDistSqr)
1344 bestNegPointI = nbrPointI;
1351 if (bestPosPointI != -1)
1361 patchAttraction[bestPosPointI] =
1362 0.5*rawPatchAttraction[bestPosPointI];
1363 patchConstraints[bestPosPointI] =
1364 rawPatchConstraints[bestPosPointI];
1368 if (bestNegPointI != -1)
1378 patchAttraction[bestNegPointI] =
1379 0.5*rawPatchAttraction[bestNegPointI];
1380 patchConstraints[bestNegPointI] =
1381 rawPatchConstraints[bestNegPointI];
1391 Info<<
"Stringing feature edges : changed " << nChanged <<
" points"
1404 const scalar featureCos,
1420 if (debug&meshRefinement::ATTRACTION)
1426 meshRefiner_.mesh().time().path()
1427 /
"multiPatch_" +
name(iter) +
".obj"
1430 Info<<
"Dumping removed constraints due to same-face"
1431 <<
" multi-patch points to "
1432 << multiPatchStr().name() <<
endl;
1439 forAll(pointFacePatchID, pointI)
1444 pointFacePatchID[pointI],
1445 pointFaceCentres[pointI]
1447 isMultiPatchPoint[pointI] = multiPatchPt.
hit();
1451 forAll(isMultiPatchPoint, pointI)
1453 if (isMultiPatchPoint[pointI])
1457 patchConstraints[pointI].first() <= 1
1458 && rawPatchConstraints[pointI].first() > 1
1461 patchAttraction[pointI] = rawPatchAttraction[pointI];
1462 patchConstraints[pointI] = rawPatchConstraints[pointI];
1485 label nMultiPatchPoints = 0;
1491 isMultiPatchPoint[pointI]
1492 && patchConstraints[pointI].first() > 1
1495 nMultiPatchPoints++;
1499 if (nMultiPatchPoints > 0)
1506 !isMultiPatchPoint[pointI]
1507 && patchConstraints[pointI].first() > 1
1513 patchAttraction[pointI] = vector::zero;
1517 if (multiPatchStr.
valid())
1527 Info<<
"Removing constraints near multi-patch points : changed "
1528 << nChanged <<
" points" <<
endl;
1548 for (
label startFp = 0; startFp <
f.size()-2; startFp++)
1550 label minFp =
f.rcIndex(startFp);
1554 label endFp =
f.fcIndex(
f.fcIndex(startFp));
1555 endFp <
f.size() && endFp != minFp;
1561 patchConstraints[
f[startFp]].first() >= 2
1562 && patchConstraints[
f[endFp]].first() >= 2
1565 attractIndices =
labelPair(startFp, endFp);
1571 return attractIndices;
1577 const scalar featureCos,
1585 scalar magD =
mag(d);
1621 const scalar concaveCos
1625 scalar magN0 =
mag(n0);
1634 scalar d = (
c1-c0)&n0;
1645 scalar magN1 =
mag(n1);
1653 if ((n0&n1) < concaveCos)
1667 const scalar featureCos,
1668 const scalar concaveCos,
1669 const scalar minAreaRatio,
1685 if (localF.
size() >= 4)
1725 for (
label startFp = 0; startFp < localF.
size()-2; startFp++)
1727 label minFp = localF.rcIndex(startFp);
1731 label endFp = localF.fcIndex(localF.fcIndex(startFp));
1732 endFp < localF.
size() && endFp != minFp;
1736 label startPtI = localF[startFp];
1737 label endPtI = localF[endFp];
1742 if (startPc.
first() >= 2 && endPc.
first() >= 2)
1744 if (startPc.
first() == 2 || endPc.
first() == 2)
1749 point start = localPts[startPtI]+patchAttr[startPtI];
1750 point end = localPts[endPtI]+patchAttr[endPtI];
1754 !isSplitAlignedWithFeature
1782 for (
label fp = startFp; fp <= endFp; fp++)
1784 f0[i0++] = localF[fp];
1790 points0.
append(localPts[f0[0]] + patchAttr[f0[0]]);
1791 for (
label fp=1; fp < f0.size()-1; fp++)
1794 points0.
append(localPts[pI] + nearestAttr[pI]);
1798 localPts[f0.last()] + patchAttr[f0.last()]
1804 f1.setSize(localF.
size()+2-f0.size());
1810 fp = localF.fcIndex(fp)
1813 f1[i1++] = localF[fp];
1815 f1[i1++] = localF[startFp];
1821 points1.
append(localPts[
f1[0]] + patchAttr[
f1[0]]);
1822 for (
label fp=1; fp <
f1.size()-1; fp++)
1825 points1.
append(localPts[pI] + nearestAttr[pI]);
1829 localPts[
f1.last()] + patchAttr[
f1.last()]
1841 compact0.
centre(points0),
1842 compact0.
normal(points0),
1843 compact1.
centre(points1),
1844 compact1.
normal(points1),
1864 const scalar area0 = f0.mag(localPts);
1865 const scalar area1 =
f1.mag(localPts);
1869 area0/area1 >= minAreaRatio
1870 && area1/area0 >= minAreaRatio
1873 attractIndices =
labelPair(startFp, endFp);
1880 return attractIndices;
1886 const scalar featureCos,
1887 const scalar concaveCos,
1888 const scalar minAreaRatio,
1900 const labelList& bFaces = pp.addressing();
1916 findDiagonalAttraction
1937 splitFaces.
append(bFaces[faceI]);
1950 && patchConstraints[
f[fp]].first() >= 2
1958 nearestNormal[
f[fp]]
1961 patchAttraction[
f[fp]] = nearestAttraction[
f[fp]];
1972 const scalar featureCos,
1992 if (
diag[0] != -1 &&
diag[1] != -1)
2002 const point mid = 0.5*(pt0+pt1);
2004 const scalar cosAngle =
mag
2006 patchConstraints[i0].second()
2007 & patchConstraints[i1].second()
2016 if (cosAngle > featureCos)
2022 scalar minDistSqr = GREAT;
2026 if (patchConstraints[pointI].first() <= 1)
2029 scalar distSqr =
magSqr(mid-pt);
2030 if (distSqr < minDistSqr)
2032 distSqr = minDistSqr;
2039 label minPointI =
f[minFp];
2040 patchAttraction[minPointI] =
2042 patchConstraints[minPointI] = patchConstraints[
f[
diag[0]]];
2070 const bool isRegionEdge,
2075 const point& estimatedPt,
2113 label featI = nearEdgeFeat[0];
2124 edgeConstraints[featI][
nearInfo.index()].append(
c);
2128 patchConstraints[pointI] =
c;
2137 const bool isRegionPoint,
2142 const point& estimatedPt,
2169 label featI = nearFeat[0];
2177 scalar distSqr =
magSqr(featPt-pt);
2180 label oldPointI = pointAttractor[featI][featPointI];
2182 if (oldPointI != -1)
2194 pointAttractor[featI][featPointI] = pointI;
2199 patchAttraction[pointI] = featPt-pt;
2203 patchAttraction[oldPointI] = vector::zero;
2225 pointAttractor[featI][featPointI] = pointI;
2230 patchAttraction[pointI] = featPt-pt;
2244 const scalar featureCos,
2245 const bool multiRegionFeatureSnap,
2273 if (debug&meshRefinement::ATTRACTION)
2275 featureEdgeStr.
reset
2279 meshRefiner_.mesh().time().path()
2280 /
"featureEdge_" +
name(iter) +
".obj"
2283 Info<<
"Dumping feature-edge sampling to "
2284 << featureEdgeStr().name() <<
endl;
2290 meshRefiner_.mesh().time().path()
2291 /
"missedFeatureEdge_" +
name(iter) +
".obj"
2294 Info<<
"Dumping feature-edges that are too far away to "
2295 << missedEdgeStr().name() <<
endl;
2297 featurePointStr.
reset
2301 meshRefiner_.mesh().time().path()
2302 /
"featurePoint_" +
name(iter) +
".obj"
2305 Info<<
"Dumping feature-point sampling to "
2306 << featurePointStr().name() <<
endl;
2312 meshRefiner_.mesh().time().path()
2313 /
"missedFeatureEdgeFromMPEdge_" +
name(iter) +
".obj"
2316 Info<<
"Dumping region-edges that are too far away to "
2317 << missedMP0Str().name() <<
endl;
2323 meshRefiner_.mesh().time().path()
2324 /
"missedFeatureEdgeFromMPPoint_" +
name(iter) +
".obj"
2327 Info<<
"Dumping region-points that are too far away to "
2328 << missedMP1Str().name() <<
endl;
2349 vector attraction = vector::zero;
2352 featureAttractionUsingReconstruction
2363 pointFaceSurfNormals,
2408 (constraint.
first() > patchConstraints[pointI].first())
2410 (constraint.
first() == patchConstraints[pointI].first())
2411 && (
magSqr(attraction) <
magSqr(patchAttraction[pointI]))
2415 patchAttraction[pointI] = attraction;
2416 patchConstraints[pointI] = constraint;
2419 if (patchConstraints[pointI].first() == 1)
2422 if (multiRegionFeatureSnap)
2424 const point estimatedPt(pt + nearestDisp[pointI]);
2430 pointFacePatchID[pointI],
2436 if (multiPatchPt.
hit())
2461 if (featureEdgeStr.
valid())
2463 featureEdgeStr().write
2471 if (missedEdgeStr.
valid())
2473 missedEdgeStr().write
2482 else if (patchConstraints[pointI].first() == 2)
2487 const point estimatedPt(pt + patchAttraction[pointI]);
2492 bool hasSnapped =
false;
2493 if (multiRegionFeatureSnap)
2500 pointFacePatchID[pointI],
2505 if (multiPatchPt.
hit())
2507 if (multiPatchPt.
index() == 0)
2529 missedMP0Str.
valid()
2533 missedMP0Str().write
2598 missedMP1Str.
valid()
2602 missedMP1Str().write
2640 patchConstraints[pointI].first() == 3
2641 && featurePointStr.
valid()
2644 featurePointStr().write
2651 patchConstraints[pointI].first() == 2
2652 && featureEdgeStr.
valid()
2655 featureEdgeStr().write
2663 if (missedEdgeStr.
valid())
2665 missedEdgeStr().write
2672 else if (patchConstraints[pointI].first() == 3)
2675 const point estimatedPt(pt + patchAttraction[pointI]);
2679 if (multiRegionFeatureSnap)
2686 pointFacePatchID[pointI],
2691 if (multiPatchPt.
hit())
2759 if (info.
hit() && featurePointStr.
valid())
2761 featurePointStr().write
2786 const bool baffleFeaturePoints,
2787 const scalar featureCos,
2817 label faceI = eFaces[i];
2828 syncTools::syncEdgeList
2846 if (debug&meshRefinement::ATTRACTION)
2852 meshRefiner_.mesh().time().path()
2853 /
"baffleEdge_" +
name(iter) +
".obj"
2856 Info<<
nl <<
"Dumping baffle-edges to "
2857 << baffleEdgeStr().name() <<
endl;
2863 label nBaffleEdges = 0;
2870 forAll(edgeFaceNormals, edgeI)
2874 if (efn.
size() == 2 && (efn[0]&efn[1]) < baffleFeatureCos)
2876 isBaffleEdge[edgeI] =
true;
2879 pointStatus[
e[0]] = 0;
2880 pointStatus[
e[1]] = 0;
2882 if (baffleEdgeStr.
valid())
2893 Info<<
"Detected " << nBaffleEdges
2894 <<
" baffle edges out of "
2896 <<
" edges." <<
endl;
2921 label nBafflePoints = 0;
2922 forAll(pointStatus, pointI)
2924 if (pointStatus[pointI] != -1)
2932 label nPointAttract = 0;
2933 label nEdgeAttract = 0;
2935 forAll(pointStatus, pointI)
2939 if (pointStatus[pointI] == 0)
2966 if (baffleFeaturePoints)
2996 else if (pointStatus[pointI] == 1)
3008 label featI = nearFeat[0];
3016 scalar distSqr =
magSqr(featPt-pt);
3019 label oldPointI = pointAttractor[featI][featPointI];
3030 pointAttractor[featI][featPointI] = pointI;
3036 patchAttraction[pointI] = featPt-pt;
3037 patchConstraints[pointI] =
3040 if (oldPointI != -1)
3101 Info<<
"Baffle points : " << nBafflePoints
3102 <<
" of which attracted to :" <<
nl
3103 <<
" feature point : " << nPointAttract <<
nl
3104 <<
" feature edge : " << nEdgeAttract <<
nl
3105 <<
" rest : " << nBafflePoints-nPointAttract-nEdgeAttract
3149 bb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
3150 bb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
3160 forAll(rawPatchConstraints, pointI)
3162 if (rawPatchConstraints[pointI].first() >= 2)
3164 isFeatureEdgeOrPoint[pointI] =
true;
3170 <<
" mesh points out of "
3172 <<
" for reverse attraction." <<
endl;
3176 syncTools::syncPointList
3180 isFeatureEdgeOrPoint,
3185 for (
label nGrow = 0; nGrow < 1; nGrow++)
3187 boolList newIsFeatureEdgeOrPoint(isFeatureEdgeOrPoint);
3195 if (isFeatureEdgeOrPoint[
f[fp]])
3200 newIsFeatureEdgeOrPoint[
f[fp]] =
true;
3207 isFeatureEdgeOrPoint = newIsFeatureEdgeOrPoint;
3209 syncTools::syncPointList
3213 isFeatureEdgeOrPoint,
3221 forAll(isFeatureEdgeOrPoint, pointI)
3223 if (isFeatureEdgeOrPoint[pointI])
3225 attractPoints.
append(pointI);
3231 <<
" mesh points out of "
3233 <<
" for reverse attraction." <<
endl;
3247 patchAttraction.setSize(pp.
nPoints());
3248 patchAttraction = vector::zero;
3252 forAll(edgeAttractors, featI)
3256 edgeConstraints[featI];
3258 forAll(edgeAttr, featEdgeI)
3264 const point& featPt = attr[i];
3281 patchConstraints[pointI].first() <= 1
3282 ||
magSqr(attraction) <
magSqr(patchAttraction[pointI])
3285 patchAttraction[pointI] = attraction;
3286 patchConstraints[pointI] = edgeConstr[featEdgeI][i];
3292 <<
"Did not find pp point near " << featPt
3309 forAll(pointAttractor, featI)
3311 const labelList& pointAttr = pointAttractor[featI];
3314 forAll(pointAttr, featPointI)
3316 if (pointAttr[featPointI] != -1)
3318 const point& featPt = features[featI].points()
3336 const point attraction = featPt-pt;
3341 if (patchConstraints[pointI].first() <= 1)
3343 patchAttraction[pointI] = attraction;
3344 patchConstraints[pointI] = pointConstr[featPointI];
3346 else if (patchConstraints[pointI].first() == 2)
3348 patchAttraction[pointI] = attraction;
3349 patchConstraints[pointI] = pointConstr[featPointI];
3351 else if (patchConstraints[pointI].first() == 3)
3357 <
magSqr(patchAttraction[pointI])
3360 patchAttraction[pointI] = attraction;
3361 patchConstraints[pointI] =
3362 pointConstr[featPointI];
3375 const bool multiRegionFeatureSnap,
3377 const bool detectBaffles,
3378 const bool baffleFeaturePoints,
3380 const bool releasePoints,
3381 const bool stringFeatures,
3382 const bool avoidDiagonal,
3384 const scalar featureCos,
3405 meshRefinement::getMasterPoints
3425 label nFeatEdges = features[featI].edges().
size();
3426 edgeAttractors[featI].
setSize(nFeatEdges);
3427 edgeConstraints[featI].
setSize(nFeatEdges);
3437 label nFeatPoints = features[featI].points().
size();
3438 pointAttractor[featI].
setSize(nFeatPoints, -1);
3450 multiRegionFeatureSnap,
3456 pointFaceSurfNormals,
3475 Info<<
"Raw geometric feature analysis : ";
3476 writeStats(pp, isPatchMasterPoint, rawPatchConstraints);
3492 determineBaffleFeatures
3495 baffleFeaturePoints,
3516 Info<<
"After baffle feature analysis : ";
3517 writeStats(pp, isPatchMasterPoint, rawPatchConstraints);
3525 reverseAttractMeshPoints
3541 rawPatchConstraints,
3551 Info<<
"Reverse attract feature analysis : ";
3552 writeStats(pp, isPatchMasterPoint, patchConstraints);
3556 if (debug&meshRefinement::ATTRACTION)
3560 meshRefiner_.mesh().time().path()
3561 /
"edgeAttractors_" +
name(iter) +
".obj"
3563 Info<<
"Dumping feature-edge attraction to "
3568 meshRefiner_.mesh().time().path()
3569 /
"pointAttractors_" +
name(iter) +
".obj"
3571 Info<<
"Dumping feature-point attraction to "
3574 forAll(patchConstraints, pointI)
3577 const vector& attr = patchAttraction[pointI];
3579 if (patchConstraints[pointI].first() == 2)
3583 else if (patchConstraints[pointI].first() == 3)
3597 releasePointsNextToMultiPatch
3609 rawPatchConstraints,
3632 rawPatchConstraints,
3645 avoidDiagonalAttraction
3656 if (debug&meshRefinement::ATTRACTION)
3660 meshRefiner_.mesh().time().path()
3661 /
"patchAttraction_" +
name(iter) +
".obj",
3673 const scalar featureCos,
3684 if (debug&meshRefinement::ATTRACTION)
3690 meshRefiner_.mesh().time().path()
3691 /
"faceSqueeze_" +
name(iter) +
".obj"
3694 Info<<
"Dumping faceSqueeze corrections to "
3695 << strPtr().name() <<
endl;
3704 if (
f.size() !=
points.size())
3708 for (
label i = 0; i <
f.size(); i++)
3713 label nConstraints = 0;
3719 if (patchConstraints[pointI].first() > 1)
3721 points[fp] = pt + patchAttraction[pointI];
3730 if (nConstraints ==
f.size())
3753 label pointI =
f.prevLabel(maxFp);
3764 patchAttraction[pointI] = nearestAttraction[pointI];
3779 if (newArea < 0.1*oldArea)
3786 scalar
s =
magSqr(patchAttraction[
f[fp]]);
3797 patchAttraction[pointI] *= 0.5;
3809 const bool alignMeshEdges,
3811 const scalar featureCos,
3812 const scalar featureAttract,
3829 Info<<
"Overriding displacement on features :" <<
nl
3830 <<
" implicit features : " << implicitFeatureAttraction <<
nl
3831 <<
" explicit features : " << explicitFeatureAttraction <<
nl
3832 <<
" multi-patch features : " << multiRegionFeatureSnap <<
nl
3844 meshRefinement::getMasterPoints
3869 faceSnapDist[faceI] =
max(faceSnapDist[faceI], snapDist[
f[fp]]);
3880 vectorField faceSurfaceNormal(pp.size(), vector::zero);
3881 labelList faceSurfaceGlobalRegion(pp.size(), -1);
3891 faceSurfaceGlobalRegion
3901 calcNearestFacePointProperties
3908 faceSurfaceGlobalRegion,
3910 pointFaceSurfNormals,
3929 patchAttraction.setSize(localPoints.size());
3930 patchAttraction = vector::zero;
3932 patchConstraints.
setSize(localPoints.size());
3935 if (implicitFeatureAttraction)
3940 featureAttractionUsingReconstruction
3949 pointFaceSurfNormals,
3959 if (explicitFeatureAttraction)
3962 bool releasePoints =
false;
3963 bool stringFeatures =
false;
3964 bool avoidDiagonal =
false;
3979 featureAttractionUsingFeatureEdges
3982 multiRegionFeatureSnap,
3999 pointFaceSurfNormals,
4009 if (!alignMeshEdges)
4017 Info<<
"Experimental: introducing face splits to avoid rotating"
4018 <<
" mesh edges. Splitting faces when" <<
nl
4019 <<
indent <<
"- angle not concave by more than "
4021 <<
indent <<
"- resulting triangles of similar area "
4022 <<
" (ratio within " << minAreaRatio <<
")" <<
nl
4043 Info<<
"Diagonal attraction feature correction : ";
4044 writeStats(pp, isPatchMasterPoint, patchConstraints);
4076 <<
" avg:" << avgPatchDisp <<
endl
4077 <<
" feature : max:" <<
gMaxMagSqr(patchAttraction)
4078 <<
" avg:" << avgPatchAttr <<
endl;
4092 forAll(patchConstraints, pointI)
4094 if (patchConstraints[pointI].first() > 1)
4097 (1.0-featureAttract)*patchDisp[pointI]
4098 + featureAttract*patchAttraction[pointI];
4106 Info<<
"Feature analysis : ";
4107 writeStats(pp, isPatchMasterPoint, patchConstraints);
4122 if (featureAttract < 1-0.001)
4131 meshRefinement::getMasterEdges
4140 PatchTools::pointNormals
4161 tangPatchDisp -= (pointNormals & patchDisp) * pointNormals;
4172 tangPatchDisp += (pointNormals & patchDisp) * pointNormals;
4174 if (debug&meshRefinement::ATTRACTION)
4179 /
"tangPatchDispConstrained_" +
name(iter) +
".obj",
4186 (1.0-featureAttract)*smoothedPatchDisp
4187 + featureAttract*tangPatchDisp;
4191 const scalar
relax = featureAttract;
4197 syncTools::syncPointList
4203 vector(GREAT, GREAT, GREAT)