29 #include "primitiveMesh.H"
72 Pout<<
"void slidingInterface::coupleInterface"
73 <<
"(polyTopoChange& ref) : "
74 <<
"Coupling sliding interface " <<
name() <<
endl;
129 <<
"Point projection addressing not available."
157 forAll(slavePointPointHits, pointI)
159 if (slavePointPointHits[pointI] >= 0)
167 slaveMeshPoints[pointI],
168 masterMeshPoints[slavePointPointHits[pointI]]
178 forAll(slavePointPointHits, pointI)
181 const labelList& curSlaveEdges = slavePointEdges[pointI];
183 if (slavePointPointHits[pointI] > -1)
186 masterPointEdges[slavePointPointHits[pointI]];
190 forAll(curSlaveEdges, slaveEdgeI)
192 labelHashSet& sm = usedMasterEdges[curSlaveEdges[slaveEdgeI]];
194 forAll(curMasterEdges, masterEdgeI)
196 sm.
insert(curMasterEdges[masterEdgeI]);
200 else if (slavePointEdgeHits[pointI] > -1)
203 forAll(curSlaveEdges, slaveEdgeI)
205 usedMasterEdges[curSlaveEdges[slaveEdgeI]].insert
207 slavePointEdgeHits[pointI]
216 forAll(masterPointEdgeHits, masterPointI)
218 if (masterPointEdgeHits[masterPointI] > -1)
220 const labelList& curMasterEdges = masterPointEdges[masterPointI];
223 usedMasterEdges[masterPointEdgeHits[masterPointI]];
225 forAll(curMasterEdges, masterEdgeI)
227 sm.
insert(curMasterEdges[masterEdgeI]);
246 forAll(slavePointEdgeHits, pointI)
248 if (slavePointEdgeHits[pointI] > -1)
253 masterEdges[slavePointEdgeHits[pointI]].line
256 ).nearestDist(projectedSlavePoints[pointI]).hitPoint();
264 slaveMeshPoints[pointI],
278 pointMergeMap.insert(slaveMeshPoints[pointI], newPoint);
280 pointsIntoMasterEdges[slavePointEdgeHits[pointI]].
append
306 forAll(slavePointFaceHits, pointI)
310 slavePointPointHits[pointI] < 0
311 && slavePointEdgeHits[pointI] < 0
312 && slavePointFaceHits[pointI].hit()
320 projectedSlavePoints[pointI],
321 slaveMeshPoints[pointI],
333 pointMergeMap.insert(slaveMeshPoints[pointI], newPoint);
339 projectedSlavePoints[pointI]
344 Pout<<
"f: " << newPoint <<
" = "
345 << projectedSlavePoints[pointI] <<
endl;
350 forAll(masterPointEdgeHits, pointI)
352 if (masterPointEdgeHits[pointI] > -1)
354 pointsIntoSlaveEdges[masterPointEdgeHits[pointI]].
append
356 masterMeshPoints[pointI]
393 Pout<<
"Processing slave edges " <<
endl;
399 <<
"Cut point edge pair map pointer not set."
418 const edge& curEdge = slaveEdges[edgeI];
422 slavePointFaceHits[curEdge.
start()].hit()
423 || slavePointFaceHits[curEdge.
end()].hit()
438 const label startFace =
439 slavePointFaceHits[curEdge.
start()].hitObject();
440 const label endFace = slavePointFaceHits[curEdge.
end()].hitObject();
447 curFaceMap.
insert(startFace);
448 addedFaces.
insert(startFace);
453 bool completed =
false;
459 if (addedFaces.
found(endFace))
470 const labelList& curNbrs = masterFaceFaces[cf[cfI]];
474 if (!curFaceMap.
found(curNbrs[nbrI]))
476 curFaceMap.
insert(curNbrs[nbrI]);
477 addedFaces.
insert(curNbrs[nbrI]);
482 if (completed)
break;
500 label nReverseSweeps = 0;
503 addedFaces.
insert(endFace);
509 if (addedFaces.
found(startFace))
520 const labelList& curNbrs = masterFaceFaces[cf[cfI]];
524 if (!curFaceMap.
found(curNbrs[nbrI]))
526 curFaceMap.
insert(curNbrs[nbrI]);
527 addedFaces.
insert(curNbrs[nbrI]);
532 if (completed)
break;
576 const labelList&
me = masterFaceEdges[curFaces[faceI]];
584 const labelList curMasterEdges = curMasterEdgesMap.
toc();
597 const point& a = projectedSlavePoints[curEdge.
start()];
598 const point&
b = projectedSlavePoints[curEdge.
end()];
603 slaveLocalPoints[curEdge.
start()]
604 + slavePointNormals[curEdge.
start()]
605 + slaveLocalPoints[curEdge.
end()]
606 + slavePointNormals[curEdge.
end()]
619 const scalar curSlaveLineMag = curSlaveLine.
mag();
623 forAll(curMasterEdges, masterEdgeI)
625 if (!curUme.
found(curMasterEdges[masterEdgeI]))
633 const label cmeIndex = curMasterEdges[masterEdgeI];
634 const edge& cme = masterEdges[cmeIndex];
644 cme.
line(masterLocalPoints)
654 point masterCutPoint =
655 masterLocalPoints[cme.
start()]
656 + cutOnMaster*cme.
vec(masterLocalPoints);
669 - curSlaveLine.
start()
670 ) & curSlaveLine.
vec()
671 )/
sqr(curSlaveLineMag);
706 masterMeshPoints[cme.
start()],
720 pointsIntoSlaveEdges[edgeI].
append(newPoint);
721 pointsIntoMasterEdges[cmeIndex].
append
742 masterMeshPoints[cme.
start()],
743 masterMeshPoints[cme.
end()]
747 slaveMeshPoints[curEdge.
start()],
748 slaveMeshPoints[curEdge.
end()]
755 Pout<<
" " << newPoint <<
" = "
756 << masterCutPoint <<
" ";
808 forAll(pointsIntoMasterEdges, i)
810 pime[i].
transfer(pointsIntoMasterEdges[i]);
815 forAll(pointsIntoSlaveEdges, i)
817 pise[i].
transfer(pointsIntoSlaveEdges[i]);
847 boolList orphanedMaster(masterPatch.size(),
false);
848 boolList orphanedSlave(slavePatch.size(),
false);
852 const face& curCutFace = cutFaces[faceI];
853 const label curMaster = cutFaceMaster[faceI];
854 const label curSlave = cutFaceSlave[faceI];
859 bool insertedFace =
false;
864 if (curCutFace == masterPatch[curMaster])
876 if (masterFc[curMaster] < slaveFc[curSlave])
885 masterPatchAddr[curMaster],
892 masterPatchFlip[curMaster]
911 masterPatchAddr[curMaster],
918 !masterPatchFlip[curMaster]
924 orphanedSlave[curSlave] =
true;
934 masterPatchAddr[curMaster],
941 masterPatchFlip[curMaster]
949 else if (curSlave >= 0)
954 face rsf(slavePatch[curSlave]);
960 if (mpIter != pointMergeMap.end())
966 if (curCutFace == rsf)
974 if (masterFc[curMaster] < slaveFc[curSlave])
981 slavePatchAddr[curSlave],
988 !slavePatchFlip[curMaster]
1002 slavePatchAddr[curSlave],
1004 masterFc[curMaster],
1009 slavePatchFlip[curSlave]
1015 orphanedMaster[curMaster] =
true;
1025 slavePatchAddr[curSlave],
1032 slavePatchFlip[curSlave]
1037 insertedFace =
true;
1043 <<
"Face " << faceI <<
" in cut faces has neither a master "
1044 <<
"nor a slave. Error in the cutting algorithm on modify."
1058 if (masterFc[curMaster] < slaveFc[curSlave])
1072 masterFc[curMaster],
1076 masterPatchAddr[curMaster],
1093 masterFc[curMaster],
1096 masterPatchAddr[curMaster],
1106 orphanedSlave[curSlave] =
true;
1121 masterFc[curMaster],
1125 masterPatchAddr[curMaster],
1135 orphanedMaster[curMaster] =
true;
1137 else if (curSlave >= 0)
1154 slavePatchAddr[curSlave],
1163 orphanedSlave[curSlave] =
true;
1168 <<
"Face " << faceI <<
" in cut faces has neither a master "
1169 <<
"nor a slave. Error in the cutting algorithm on add."
1179 label nOrphanedMasters = 0;
1181 forAll(orphanedMaster, faceI)
1183 if (orphanedMaster[faceI])
1210 label nOrphanedSlaves = 0;
1212 forAll(orphanedSlave, faceI)
1214 if (orphanedSlave[faceI])
1243 Pout<<
"Number of orphaned faces: "
1244 <<
"master = " << nOrphanedMasters <<
" out of "
1245 << orphanedMaster.
size()
1246 <<
" slave = " << nOrphanedSlaves <<
" out of "
1271 forAll(masterStickOuts, faceI)
1275 const label curFaceID = masterStickOuts[faceI];
1277 const face& oldRichFace = faces[curFaceID];
1279 bool changed =
false;
1285 forAll(oldRichFace, pointI)
1294 oldFace[nOldFace] = oldRichFace[pointI];
1309 if (masterMeshPointMap.found(oldFace[pointI]))
1315 if (pointMergeMap.found(oldFace[pointI]))
1320 pointMergeMap.find(oldFace[pointI])()
1325 newFaceLabels.
append(oldFace[pointI]);
1334 const label localFirstLabel =
1335 masterMeshPointMap.find(oldFace[pointI])();
1337 const labelList& curEdges = masterPointEdges[localFirstLabel];
1342 masterMeshPointMap.find(nextLabel);
1344 if (mmpmIter != masterMeshPointMap.end())
1349 const label localNextLabel = mmpmIter();
1351 forAll(curEdges, curEdgeI)
1355 masterEdges[curEdges[curEdgeI]].otherVertex
1366 const labelList& curPime = pime[curEdges[curEdgeI]];
1374 const point& startPoint =
1375 masterLocalPoints[localFirstLabel];
1378 masterLocalPoints[localNextLabel]
1385 forAll(curPime, curPimeI)
1387 edgePointWeights[curPimeI] =
1391 pointMap.find(curPime[curPimeI])()
1401 min(edgePointWeights) < 0
1402 ||
max(edgePointWeights) > 1
1406 <<
"Error in master stick-out edge "
1407 <<
"point collection."
1419 passI < edgePointWeights.size();
1426 label nextPoint = -1;
1429 forAll(edgePointWeights, wI)
1431 if (edgePointWeights[wI] < dist)
1433 dist = edgePointWeights[wI];
1441 newFaceLabels.
append(curPime[nextPoint]);
1442 edgePointWeights[nextPoint] = GREAT;
1453 newFaceLabels.
append(oldFace[pointI]);
1459 if (newFaceLabels.size() < 3)
1462 <<
"Face " << curFaceID <<
" reduced to less than "
1463 <<
"3 points. Topological/cutting error A." <<
nl
1464 <<
"Old face: " << oldFace <<
" new face: " << newFaceLabels
1470 bool modifiedFaceZoneFlip =
false;
1472 if (modifiedFaceZone >= 0)
1474 modifiedFaceZoneFlip =
1475 faceZones[modifiedFaceZone].flipMap()
1477 faceZones[modifiedFaceZone].whichFace(curFaceID)
1490 if (
mesh.isInternalFace(curFaceID))
1504 modifiedFaceZoneFlip
1519 mesh.boundaryMesh().whichPatch(curFaceID),
1523 modifiedFaceZoneFlip
1543 forAll(slaveStickOuts, faceI)
1546 const label curFaceID = slaveStickOuts[faceI];
1548 const face& oldRichFace = faces[curFaceID];
1550 bool changed =
false;
1556 forAll(oldRichFace, pointI)
1560 rpm.found(oldRichFace[pointI])
1561 || slaveMeshPointMap.found(oldRichFace[pointI])
1565 oldFace[nOldFace] = oldRichFace[pointI];
1571 || masterMeshPointMap.found(oldRichFace[pointI])
1582 oldFace[nOldFace] = oldRichFace[pointI];
1598 label curP = oldFace[pointI];
1602 if (rpmIter != rpm.end())
1608 if (slaveMeshPointMap.found(curP))
1614 if (pointMergeMap.found(curP))
1619 pointMergeMap.find(curP)()
1624 newFaceLabels.
append(curP);
1634 const label localFirstLabel =
1635 slaveMeshPointMap.find(curP)();
1637 const labelList& curEdges = slavePointEdges[localFirstLabel];
1642 rpm.find(nextLabel);
1644 if (rpmNextIter != rpm.end())
1646 nextLabel = rpmNextIter();
1650 slaveMeshPointMap.find(nextLabel);
1652 if (mmpmIter != slaveMeshPointMap.end())
1656 const label localNextLabel = mmpmIter();
1658 forAll(curEdges, curEdgeI)
1662 slaveEdges[curEdges[curEdgeI]].otherVertex
1673 const labelList& curPise = pise[curEdges[curEdgeI]];
1681 const point& startPoint =
1682 projectedSlavePoints[localFirstLabel];
1685 projectedSlavePoints[localNextLabel]
1692 forAll(curPise, curPiseI)
1694 edgePointWeights[curPiseI] =
1698 pointMap.find(curPise[curPiseI])()
1708 min(edgePointWeights) < 0
1709 ||
max(edgePointWeights) > 1
1713 <<
"Error in slave stick-out edge "
1714 <<
"point collection."
1726 passI < edgePointWeights.size();
1733 label nextPoint = -1;
1736 forAll(edgePointWeights, wI)
1738 if (edgePointWeights[wI] < dist)
1740 dist = edgePointWeights[wI];
1748 newFaceLabels.
append(curPise[nextPoint]);
1749 edgePointWeights[nextPoint] = GREAT;
1760 newFaceLabels.
append(oldFace[pointI]);
1766 if (newFaceLabels.size() < 3)
1769 <<
"Face " << curFaceID <<
" reduced to less than "
1770 <<
"3 points. Topological/cutting error B." <<
nl
1771 <<
"Old face: " << oldFace <<
" new face: " << newFaceLabels
1777 bool modifiedFaceZoneFlip =
false;
1779 if (modifiedFaceZone >= 0)
1781 modifiedFaceZoneFlip =
1782 faceZones[modifiedFaceZone].flipMap()
1784 faceZones[modifiedFaceZone].whichFace(curFaceID)
1797 if (
mesh.isInternalFace(curFaceID))
1811 modifiedFaceZoneFlip
1826 mesh.boundaryMesh().whichPatch(curFaceID),
1830 modifiedFaceZoneFlip
1844 <<
"Retired point map pointer not set."
1853 label nRetiredPoints = 0;
1855 forAll(slaveMeshPoints, pointI)
1857 if (pointMergeMap.found(slaveMeshPoints[pointI]))
1882 slaveMeshPoints[pointI]
1888 pointMergeMap.find(slaveMeshPoints[pointI])(),
1889 slaveMeshPoints[pointI]
1898 slaveMeshPoints[pointI],
1899 points[slaveMeshPoints[pointI]],
1901 mesh.pointZones().whichZone(slaveMeshPoints[pointI]),
1910 Pout<<
"Retired " << nRetiredPoints <<
" out of "
1911 << slaveMeshPoints.
size() <<
" points." <<
endl;
1926 Pout<<
"void slidingInterface::coupleInterface("
1927 <<
"polyTopoChange& ref) : "
1928 <<
"Finished coupling sliding interface " <<
name() <<
endl;