39 const Foam::scalar Foam::faceCoupleInfo::angleTol_ = 1
E-3;
45 void Foam::faceCoupleInfo::writeOBJ
47 const fileName& fName,
63 const edge&
e = edges[edgeI];
69 if (pointMap[pointI] == -1)
71 pointMap[pointI] = newPointI++;
90 const edge&
e = edges[edgeI];
92 str<<
"l " << pointMap[e[0]]+1 <<
' ' << pointMap[e[1]]+1 <<
nl;
100 const fileName& fName,
105 Pout<<
"Writing connections as edges to " << fName <<
endl;
117 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
123 void Foam::faceCoupleInfo::writePointsFaces()
const
131 OFstream str(
"masterPatch.obj");
136 OFstream str(
"slavePatch.obj");
141 OFstream str(
"cutFaces.obj");
148 Pout<<
"Writing cutToMasterPoints to cutToMasterPoints.obj" <<
endl;
152 "cutToMasterPoints.obj",
154 pointField(c.localPoints(), masterToCutPoints_));
157 Pout<<
"Writing cutToSlavePoints to cutToSlavePoints.obj" <<
endl;
161 "cutToSlavePoints.obj",
163 pointField(c.localPoints(), slaveToCutPoints_)
169 Pout<<
"Writing cutToMasterFaces to cutToMasterFaces.obj" <<
endl;
173 forAll(cutToMasterFaces(), cutFaceI)
175 label masterFaceI = cutToMasterFaces()[cutFaceI];
177 if (masterFaceI != -1)
179 equivMasterFaces[cutFaceI] = m[masterFaceI].centre(m.points());
184 <<
"No master face for cut face " << cutFaceI
185 <<
" at position " << c[cutFaceI].centre(c.points())
194 "cutToMasterFaces.obj",
195 calcFaceCentres<List>(c, cutPoints(), 0, c.size()),
201 Pout<<
"Writing cutToSlaveFaces to cutToSlaveFaces.obj" <<
endl;
205 forAll(cutToSlaveFaces(), cutFaceI)
207 label slaveFaceI = cutToSlaveFaces()[cutFaceI];
209 equivSlaveFaces[cutFaceI] = s[slaveFaceI].centre(s.points());
214 "cutToSlaveFaces.obj",
215 calcFaceCentres<List>(c, cutPoints(), 0, c.size()),
224 void Foam::faceCoupleInfo::writeEdges
236 OFstream str(
"cutToMasterEdges.obj");
237 Pout<<
"Writing cutToMasterEdges to " << str.
name() <<
endl;
241 forAll(cutToMasterEdges, cutEdgeI)
243 if (cutToMasterEdges[cutEdgeI] != -1)
245 const edge& masterEdge =
246 m.edges()[cutToMasterEdges[cutEdgeI]];
247 const edge& cutEdge = c.edges()[cutEdgeI];
257 str <<
"l " << vertI-3 <<
' ' << vertI-2 <<
nl;
258 str <<
"l " << vertI-3 <<
' ' << vertI-1 <<
nl;
259 str <<
"l " << vertI-3 <<
' ' << vertI <<
nl;
260 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
nl;
261 str <<
"l " << vertI-2 <<
' ' << vertI <<
nl;
262 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
267 OFstream str(
"cutToSlaveEdges.obj");
268 Pout<<
"Writing cutToSlaveEdges to " << str.
name() <<
endl;
276 if (slaveToCut[edgeI] != -1)
278 const edge& slaveEdge = s.edges()[edgeI];
279 const edge& cutEdge = c.edges()[slaveToCut[edgeI]];
289 str <<
"l " << vertI-3 <<
' ' << vertI-2 <<
nl;
290 str <<
"l " << vertI-3 <<
' ' << vertI-1 <<
nl;
291 str <<
"l " << vertI-3 <<
' ' << vertI <<
nl;
292 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
nl;
293 str <<
"l " << vertI-2 <<
' ' << vertI <<
nl;
294 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
314 forAll(toPatchEdges, edgeI)
316 const edge&
e = edges[edgeI];
318 label v0 = pointMap[e[0]];
319 label
v1 = pointMap[e[1]];
321 toPatchEdges[edgeI] =
325 patch.pointEdges()[v0],
336 bool Foam::faceCoupleInfo::regionEdge
338 const polyMesh& slaveMesh,
339 const label slaveEdgeI
342 const labelList& eFaces = slavePatch().edgeFaces()[slaveEdgeI];
344 if (eFaces.size() == 1)
356 label faceI = eFaces[i];
358 label meshFaceI = slavePatch().addressing()[faceI];
360 label patchI = slaveMesh.boundaryMesh().whichPatch(meshFaceI);
366 else if (patchI != patch0)
380 Foam::label Foam::faceCoupleInfo::mostAlignedCutEdge
383 const polyMesh& slaveMesh,
384 const bool patchDivision,
388 const label edgeStart,
392 const pointField& localPoints = cutFaces().localPoints();
394 const labelList& pEdges = cutFaces().pointEdges()[pointI];
398 Pout<<
"mostAlignedEdge : finding nearest edge among "
399 << UIndirectList<edge>(cutFaces().edges(), pEdges)()
400 <<
" connected to point " << pointI
401 <<
" coord:" << localPoints[pointI]
402 <<
" running between " << edgeStart <<
" coord:"
403 << localPoints[edgeStart]
404 <<
" and " << edgeEnd <<
" coord:"
405 << localPoints[edgeEnd]
412 scalar maxCos = -GREAT;
416 label edgeI = pEdges[i];
422 && cutToMasterEdges[edgeI] == -1
426 && regionEdge(slaveMesh, cutToSlaveEdges[edgeI])
430 const edge& e = cutFaces().edges()[edgeI];
432 label otherPointI = e.otherVertex(pointI);
434 if (otherPointI == edgeEnd)
439 Pout<<
" mostAlignedEdge : found end point " << edgeEnd
447 vector eVec(localPoints[otherPointI] - localPoints[pointI]);
449 scalar magEVec =
mag(eVec);
451 if (magEVec < VSMALL)
453 WarningIn(
"faceCoupleInfo::mostAlignedEdge")
454 <<
"Crossing zero sized edge " << edgeI
455 <<
" coords:" << localPoints[otherPointI]
456 << localPoints[pointI]
457 <<
" when walking from " << localPoints[edgeStart]
458 <<
" to " << localPoints[edgeEnd]
465 vector eToEndPoint(localPoints[edgeEnd] - localPoints[otherPointI]);
466 eToEndPoint /=
mag(eToEndPoint);
468 scalar cosAngle = eVec & eToEndPoint;
472 Pout<<
" edge:" << e <<
" points:" << localPoints[pointI]
473 << localPoints[otherPointI]
475 <<
" vecToEnd:" << eToEndPoint
476 <<
" cosAngle:" << cosAngle
480 if (cosAngle > maxCos)
488 if (maxCos > 1 - angleTol_)
500 void Foam::faceCoupleInfo::setCutEdgeToPoints(
const labelList& cutToMasterEdges)
506 masterPatch().nEdges(),
511 const edgeList& cutEdges = cutFaces().edges();
516 masterPatch().nEdges()
517 + slavePatch().nEdges()
521 forAll(masterToCutEdges, masterEdgeI)
523 const edge& masterE = masterPatch().edges()[masterEdgeI];
528 const labelList& stringedEdges = masterToCutEdges[masterEdgeI];
530 if (stringedEdges.empty())
534 "faceCoupleInfo::setCutEdgeToPoints"
536 ) <<
"Did not match all of master edges to cutFace edges"
538 <<
"First unmatched edge:" << masterEdgeI <<
" endPoints:"
539 << masterPatch().localPoints()[masterE[0]]
540 << masterPatch().localPoints()[masterE[1]]
542 <<
"This usually means that the slave patch is not a"
543 <<
" subdivision of the master patch"
546 else if (stringedEdges.size() > 1)
551 DynamicList<label> splitPoints(stringedEdges.size()-1);
554 const edge unsplitEdge
556 masterToCutPoints_[masterE[0]],
557 masterToCutPoints_[masterE[1]]
560 label startVertI = unsplitEdge[0];
561 label startEdgeI = -1;
563 while (startVertI != unsplitEdge[1])
571 label oldStart = startVertI;
575 label edgeI = stringedEdges[i];
577 if (edgeI != startEdgeI)
579 const edge& e = cutEdges[edgeI];
585 if (e[0] == startVertI)
589 if (e[1] != unsplitEdge[1])
591 splitPoints.append(e[1]);
595 else if (e[1] == startVertI)
599 if (e[0] != unsplitEdge[1])
601 splitPoints.append(e[0]);
609 if (oldStart == startVertI)
613 "faceCoupleInfo::setCutEdgeToPoints"
615 ) <<
" unsplitEdge:" << unsplitEdge
616 <<
" does not correspond to split edges "
617 << UIndirectList<edge>(cutEdges, stringedEdges)()
632 cutEdgeToPoints_.insert(unsplitEdge, splitPoints.shrink());
640 Foam::label Foam::faceCoupleInfo::matchFaces
647 const bool sameOrientation
650 if (f0.size() != f1.size())
654 "faceCoupleInfo::matchFaces"
655 "(const scalar, const face&, const pointField&"
656 ", const face&, const pointField&)"
657 ) <<
"Different sizes for supposedly matching faces." <<
nl
658 <<
"f0:" << f0 <<
" coords:" << UIndirectList<point>(points0, f0)()
660 <<
"f1:" << f1 <<
" coords:" << UIndirectList<point>(points1, f1)()
664 const scalar absTolSqr =
sqr(absTol);
672 bool fullMatch =
true;
679 scalar distSqr =
Foam::magSqr(points0[f0[fp0]] - points1[f1[fp1]]);
681 if (distSqr > absTolSqr)
687 fp0 = f0.fcIndex(fp0);
691 fp1 = f1.fcIndex(fp1);
695 fp1 = f1.rcIndex(fp1);
710 "faceCoupleInfo::matchFaces"
711 "(const scalar, const face&, const pointField&"
712 ", const face&, const pointField&)"
713 ) <<
"No unique match between two faces" <<
nl
714 <<
"Face " << f0 <<
" coords "
715 << UIndirectList<point>(points0, f0)() <<
nl
716 <<
"Face " << f1 <<
" coords "
717 << UIndirectList<point>(points1, f1)()
718 <<
"when using tolerance " << absTol
719 <<
" and forwardMatching:" << sameOrientation
732 bool Foam::faceCoupleInfo::matchPointsThroughFaces
739 const bool sameOrientation,
748 patchToCutPoints.setSize(patchPoints.size());
749 patchToCutPoints = -1;
753 labelList cutPointRegion(cutPoints.size(), -1);
754 DynamicList<label> cutPointRegionMaster;
756 forAll(patchFaces, patchFaceI)
758 const face& patchF = patchFaces[patchFaceI];
761 const face& cutF = cutFaces[patchFaceI];
764 label patchFp = matchFaces
776 label cutPointI = cutF[cutFp];
777 label patchPointI = patchF[patchFp];
789 if (patchToCutPoints[patchPointI] == -1)
791 patchToCutPoints[patchPointI] = cutPointI;
793 else if (patchToCutPoints[patchPointI] != cutPointI)
797 label otherCutPointI = patchToCutPoints[patchPointI];
806 if (cutPointRegion[otherCutPointI] != -1)
809 label region = cutPointRegion[otherCutPointI];
810 cutPointRegion[cutPointI] = region;
813 cutPointRegionMaster[region] =
min
815 cutPointRegionMaster[region],
822 label region = cutPointRegionMaster.size();
823 cutPointRegionMaster.append
825 min(cutPointI, otherCutPointI)
827 cutPointRegion[cutPointI] = region;
828 cutPointRegion[otherCutPointI] = region;
834 patchFp = patchF.fcIndex(patchFp);
838 patchFp = patchF.rcIndex(patchFp);
844 compactToCut.setSize(cutPointRegion.size());
845 cutToCompact.setSize(cutPointRegion.size());
847 label compactPointI = 0;
851 if (cutPointRegion[i] == -1)
854 cutToCompact[i] = compactPointI;
855 compactToCut[compactPointI] = i;
862 label masterPointI = cutPointRegionMaster[cutPointRegion[i]];
864 if (cutToCompact[masterPointI] == -1)
866 cutToCompact[masterPointI] = compactPointI;
867 compactToCut[compactPointI] = masterPointI;
870 cutToCompact[i] = cutToCompact[masterPointI];
873 compactToCut.setSize(compactPointI);
875 return compactToCut.size() != cutToCompact.size();
880 Foam::scalar Foam::faceCoupleInfo::maxDistance
888 scalar maxDist = -GREAT;
892 const point& cutPt = cutPoints[cutF[fp]];
894 pointHit pHit = masterF.nearestPoint(cutPt, masterPoints);
896 maxDist =
max(maxDist, pHit.distance());
902 void Foam::faceCoupleInfo::findPerfectMatchingFaces
904 const primitiveMesh& mesh0,
905 const primitiveMesh& mesh1,
917 calcFaceCentres<List>
921 mesh0.nInternalFaces(),
922 mesh0.nFaces() - mesh0.nInternalFaces()
928 calcFaceCentres<List>
932 mesh1.nInternalFaces(),
933 mesh1.nFaces() - mesh1.nInternalFaces()
940 Pout<<
"Face matching tolerance : " << absTol <<
endl;
958 <<
"faceCoupleInfo::faceCoupleInfo : "
959 <<
"Matched ALL " << fc1.size()
960 <<
" boundary faces of mesh0 to boundary faces of mesh1." << endl
961 <<
"This is only valid if the mesh to add is fully"
962 <<
" enclosed by the mesh it is added to." <<
endl;
969 mesh0Faces.setSize(fc0.size());
970 mesh1Faces.setSize(fc1.size());
974 if (from1To0[i] != -1)
976 mesh1Faces[nMatched] = i + mesh1.nInternalFaces();
977 mesh0Faces[nMatched] = from1To0[i] + mesh0.nInternalFaces();
983 mesh0Faces.setSize(nMatched);
984 mesh1Faces.setSize(nMatched);
988 void Foam::faceCoupleInfo::findSlavesCoveringMaster
990 const primitiveMesh& mesh0,
991 const primitiveMesh& mesh1,
999 labelList bndFaces(mesh0.nFaces()-mesh0.nInternalFaces());
1002 bndFaces[i] = mesh0.nInternalFaces() + i;
1005 treeBoundBox overallBb(mesh0.points());
1007 Random rndGen(123456);
1009 indexedOctree<treeDataFace> tree
1017 overallBb.extend(rndGen, 1
E-4),
1025 Pout<<
"findSlavesCoveringMaster :"
1026 <<
" constructed octree for mesh0 boundary faces" <<
endl;
1031 labelHashSet mesh0Set(mesh0.nFaces() - mesh0.nInternalFaces());
1032 labelHashSet mesh1Set(mesh1.nFaces() - mesh1.nInternalFaces());
1036 label mesh1FaceI = mesh1.nInternalFaces();
1037 mesh1FaceI < mesh1.nFaces();
1041 const face& f1 = mesh1.faces()[mesh1FaceI];
1044 point fc(f1.centre(mesh1.points()));
1050 label mesh0FaceI = tree.shapes().faceLabels()[nearInfo.index()];
1063 mesh0.faces()[mesh0FaceI],
1069 mesh0Set.insert(mesh0FaceI);
1070 mesh1Set.insert(mesh1FaceI);
1077 Pout<<
"findSlavesCoveringMaster :"
1078 <<
" matched " << mesh1Set.size() <<
" mesh1 faces to "
1079 << mesh0Set.size() <<
" mesh0 faces" <<
endl;
1082 mesh0Faces = mesh0Set.toc();
1083 mesh1Faces = mesh1Set.toc();
1088 Foam::label Foam::faceCoupleInfo::growCutFaces
1091 Map<labelList>& candidates
1096 Pout<<
"growCutFaces :"
1097 <<
" growing cut faces to masterPatch" <<
endl;
1100 label nTotChanged = 0;
1109 forAll(cutToMasterFaces_, cutFaceI)
1111 const label masterFaceI = cutToMasterFaces_[cutFaceI];
1113 if (masterFaceI != -1)
1119 const labelList& fEdges = cutFaceEdges[cutFaceI];
1123 const label cutEdgeI = fEdges[i];
1125 if (cutToMasterEdges[cutEdgeI] == -1)
1133 const labelList& eFaces = cutEdgeFaces[cutEdgeI];
1137 const label faceI = eFaces[j];
1139 if (cutToMasterFaces_[faceI] == -1)
1141 cutToMasterFaces_[faceI] = masterFaceI;
1142 candidates.erase(faceI);
1145 else if (cutToMasterFaces_[faceI] != masterFaceI)
1148 cutFaces().points();
1150 masterPatch().points();
1152 const edge& e = cutFaces().edges()[cutEdgeI];
1154 label myMaster = cutToMasterFaces_[faceI];
1155 const face& myF = masterPatch()[myMaster];
1157 const face& nbrF = masterPatch()[masterFaceI];
1161 "faceCoupleInfo::growCutFaces"
1162 "(const labelList&, Map<labelList>&)"
1164 << cutFaces()[faceI].points(cutPoints)
1167 <<
" but also connects to nbr face "
1168 << cutFaces()[cutFaceI].points(cutPoints)
1169 <<
" with master " << masterFaceI
1172 << myF.points(masterPoints)
1173 <<
" nbrMasterFace:"
1174 << nbrF.points(masterPoints) <<
nl
1175 <<
"Across cut edge " << cutEdgeI
1177 << cutFaces().localPoints()[e[0]]
1178 << cutFaces().localPoints()[e[1]]
1189 Pout<<
"growCutFaces : Grown an additional " << nChanged
1190 <<
" cut to master face" <<
" correspondence" <<
endl;
1193 nTotChanged += nChanged;
1205 void Foam::faceCoupleInfo::checkMatch(
const labelList& cutToMasterEdges)
const
1207 const pointField& cutLocalPoints = cutFaces().localPoints();
1209 const pointField& masterLocalPoints = masterPatch().localPoints();
1210 const faceList& masterLocalFaces = masterPatch().localFaces();
1212 forAll(cutToMasterEdges, cutEdgeI)
1214 const edge& e = cutFaces().edges()[cutEdgeI];
1216 if (cutToMasterEdges[cutEdgeI] == -1)
1219 const labelList& cutEFaces = cutFaces().edgeFaces()[cutEdgeI];
1221 label masterFaceI = -1;
1225 label cutFaceI = cutEFaces[i];
1227 if (cutToMasterFaces_[cutFaceI] != -1)
1229 if (masterFaceI == -1)
1231 masterFaceI = cutToMasterFaces_[cutFaceI];
1233 else if (masterFaceI != cutToMasterFaces_[cutFaceI])
1235 label myMaster = cutToMasterFaces_[cutFaceI];
1236 const face& myF = masterLocalFaces[myMaster];
1238 const face& nbrF = masterLocalFaces[masterFaceI];
1242 "faceCoupleInfo::checkMatch(const labelList&) const"
1244 <<
"Internal CutEdge " << e
1246 << cutLocalPoints[e[0]]
1247 << cutLocalPoints[e[1]]
1248 <<
" connects to master " << myMaster
1249 <<
" and to master " << masterFaceI <<
nl
1251 << myF.points(masterLocalPoints)
1252 <<
" nbrMasterFace:"
1253 << nbrF.points(masterLocalPoints)
1266 Foam::label Foam::faceCoupleInfo::matchEdgeFaces
1269 Map<labelList>& candidates
1274 candidates.resize(cutFaces().size());
1278 forAll(cutToMasterEdges, cutEdgeI)
1280 label masterEdgeI = cutToMasterEdges[cutEdgeI];
1282 if (masterEdgeI != -1)
1287 const labelList& cutEFaces = cutFaces().edgeFaces()[cutEdgeI];
1289 masterPatch().edgeFaces()[masterEdgeI];
1293 label cutFaceI = cutEFaces[i];
1295 if (cutToMasterFaces_[cutFaceI] == -1)
1306 if (fnd == candidates.end())
1310 candidates.insert(cutFaceI, masterEFaces);
1319 DynamicList<label> newCandidates(masterFaces.size());
1323 if (
findIndex(masterFaces, masterEFaces[j]) != -1)
1325 newCandidates.append(masterEFaces[j]);
1329 if (newCandidates.size() == 1)
1333 cutToMasterFaces_[cutFaceI] = newCandidates[0];
1334 candidates.erase(cutFaceI);
1347 fnd() = newCandidates.shrink();
1358 Pout<<
"matchEdgeFaces : Found " << nChanged
1359 <<
" faces where there was"
1360 <<
" only one remaining choice for cut-master correspondence"
1371 Foam::label Foam::faceCoupleInfo::geometricMatchEdgeFaces
1373 Map<labelList>& candidates
1376 const pointField& cutPoints = cutFaces().points();
1386 masterPatch().size(),
1393 label cutFaceI = iter.key();
1395 const face& cutF = cutFaces()[cutFaceI];
1397 if (cutToMasterFaces_[cutFaceI] == -1)
1402 scalar minDist = GREAT;
1403 label minMasterFaceI = -1;
1407 label masterFaceI = masterFaces[i];
1409 if (masterToCutFaces[masterFaces[i]].empty())
1411 scalar dist = maxDistance
1415 masterPatch()[masterFaceI],
1422 minMasterFaceI = masterFaceI;
1427 if (minMasterFaceI != -1)
1429 cutToMasterFaces_[cutFaceI] = minMasterFaceI;
1430 masterToCutFaces[minMasterFaceI] = cutFaceI;
1437 forAll(cutToMasterFaces_, cutFaceI)
1439 if (cutToMasterFaces_[cutFaceI] != -1)
1441 candidates.erase(cutFaceI);
1448 Pout<<
"geometricMatchEdgeFaces : Found " << nChanged
1449 <<
" faces where there was"
1450 <<
" only one remaining choice for cut-master correspondence"
1460 void Foam::faceCoupleInfo::perfectPointMatch
1462 const scalar absTol,
1463 const bool slaveFacesOrdered
1468 Pout<<
"perfectPointMatch :"
1469 <<
" Matching master and slave to cut."
1470 <<
" Master and slave faces are identical" <<
nl;
1472 if (slaveFacesOrdered)
1474 Pout<<
"and master and slave faces are ordered"
1475 <<
" (on coupled patches)" <<
endl;
1479 Pout<<
"and master and slave faces are not ordered"
1480 <<
" (on coupled patches)" <<
endl;
1484 cutToMasterFaces_ =
identity(masterPatch().size());
1485 cutPoints_ = masterPatch().localPoints();
1490 masterPatch().localFaces(),
1494 masterToCutPoints_ =
identity(cutPoints_.size());
1498 bool matchedAllFaces =
false;
1500 if (slaveFacesOrdered)
1502 cutToSlaveFaces_ =
identity(cutFaces().size());
1503 matchedAllFaces = (cutFaces().size() == slavePatch().size());
1512 calcFaceCentres<List>
1519 calcFaceCentres<IndirectList>
1533 if (!matchedAllFaces)
1537 "faceCoupleInfo::perfectPointMatch"
1538 "(const scalar&, const bool)"
1539 ) <<
"Did not match all of the master faces to the slave faces"
1541 <<
"This usually means that the slave patch and master patch"
1542 <<
" do not align to within " << absTol <<
" meter."
1552 matchPointsThroughFaces
1555 cutFaces().localPoints(),
1556 reorder(cutToSlaveFaces_, cutFaces().localFaces()),
1557 slavePatch().localPoints(),
1558 slavePatch().localFaces(),
1568 cutPoints_ = UIndirectList<point>(cutPoints_, compactToCut)();
1570 const faceList& cutLocalFaces = cutFaces().localFaces();
1572 faceList compactFaces(cutLocalFaces.size());
1575 compactFaces[i] =
renumber(cutToCompact, cutLocalFaces[i]);
1593 void Foam::faceCoupleInfo::subDivisionMatch
1595 const polyMesh& slaveMesh,
1596 const bool patchDivision,
1602 Pout<<
"subDivisionMatch :"
1603 <<
" Matching master and slave to cut."
1604 <<
" Slave can be subdivision of master but all master edges"
1605 <<
" have to be covered by slave edges." <<
endl;
1610 cutPoints_ = slavePatch().localPoints();
1612 faceList cutFaces(slavePatch().size());
1616 cutFaces[i] = slavePatch().localFaces()[i].reverseFace();
1622 cutToSlaveFaces_ =
identity(cutFaces().size());
1639 OFstream str(
"regionEdges.obj");
1641 Pout<<
"subDivisionMatch :"
1642 <<
" addressing for slave patch fully done."
1643 <<
" Dumping region edges to " << str.
name() <<
endl;
1647 forAll(slavePatch().edges(), slaveEdgeI)
1649 if (regionEdge(slaveMesh, slaveEdgeI))
1651 const edge& e = slavePatch().edges()[slaveEdgeI];
1657 str<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
1670 Pout<<
"subDivisionMatch :"
1671 <<
" matching master points to cut points" <<
endl;
1676 masterPatch().localPoints(),
1683 if (!matchedAllPoints)
1687 "faceCoupleInfo::subDivisionMatch"
1688 "(const polyMesh&, const bool, const scalar)"
1689 ) <<
"Did not match all of the master points to the slave points"
1691 <<
"This usually means that the slave patch is not a"
1692 <<
" subdivision of the master patch"
1704 Pout<<
"subDivisionMatch :"
1705 <<
" matching cut edges to master edges" <<
endl;
1708 const edgeList& masterEdges = masterPatch().edges();
1709 const pointField& masterPoints = masterPatch().localPoints();
1711 const edgeList& cutEdges = cutFaces().edges();
1713 labelList cutToMasterEdges(cutFaces().nEdges(), -1);
1715 forAll(masterEdges, masterEdgeI)
1717 const edge& masterEdge = masterEdges[masterEdgeI];
1719 label cutPoint0 = masterToCutPoints_[masterEdge[0]];
1720 label cutPoint1 = masterToCutPoints_[masterEdge[1]];
1724 label cutPointI = cutPoint0;
1757 Pout<<
"Dumping unmatched pointEdges to errorEdges.obj"
1766 cutFaces().pointEdges()[cutPointI]
1768 cutFaces().localPoints(),
1774 "faceCoupleInfo::subDivisionMatch"
1775 "(const polyMesh&, const bool, const scalar)"
1776 ) <<
"Problem in finding cut edges corresponding to"
1777 <<
" master edge " << masterEdge
1778 <<
" points:" << masterPoints[masterEdge[0]]
1779 <<
' ' << masterPoints[masterEdge[1]]
1780 <<
" corresponding cut edge: (" << cutPoint0
1785 cutToMasterEdges[cutEdgeI] = masterEdgeI;
1787 cutPointI = cutEdges[cutEdgeI].otherVertex(cutPointI);
1789 }
while(cutPointI != cutPoint1);
1795 writeEdges(cutToMasterEdges, cutToSlaveEdges);
1800 setCutEdgeToPoints(cutToMasterEdges);
1814 Pout<<
"subDivisionMatch :"
1815 <<
" matching (topological) cut faces to masterPatch" <<
endl;
1819 Map<labelList> candidates(cutFaces().size());
1821 cutToMasterFaces_.setSize(cutFaces().size());
1822 cutToMasterFaces_ = -1;
1828 label nChanged = matchEdgeFaces(cutToMasterEdges, candidates);
1830 checkMatch(cutToMasterEdges);
1837 nChanged += growCutFaces(cutToMasterEdges, candidates);
1839 checkMatch(cutToMasterEdges);
1849 Pout<<
"subDivisionMatch :"
1850 <<
" matching (geometric) cut faces to masterPatch" <<
endl;
1859 label nChanged = geometricMatchEdgeFaces(candidates);
1861 checkMatch(cutToMasterEdges);
1863 nChanged += growCutFaces(cutToMasterEdges, candidates);
1865 checkMatch(cutToMasterEdges);
1875 forAll(cutToMasterFaces_, cutFaceI)
1877 if (cutToMasterFaces_[cutFaceI] == -1)
1879 const face& cutF = cutFaces()[cutFaceI];
1883 "faceCoupleInfo::subDivisionMatch"
1884 "(const polyMesh&, const bool, const scalar)"
1885 ) <<
"Did not match all of cutFaces to a master face" << nl
1886 <<
"First unmatched cut face:" << cutFaceI <<
" with points:"
1887 << UIndirectList<point>(cutFaces().points(), cutF)()
1889 <<
"This usually means that the slave patch is not a"
1890 <<
" subdivision of the master patch"
1897 Pout<<
"subDivisionMatch :"
1898 <<
" finished matching master and slave to cut" <<
endl;
1915 const scalar absTol,
1916 const bool perfectMatch
1919 masterPatchPtr_(NULL),
1920 slavePatchPtr_(NULL),
1923 cutToMasterFaces_(0),
1924 masterToCutPoints_(0),
1925 cutToSlaveFaces_(0),
1926 slaveToCutPoints_(0),
1938 findPerfectMatchingFaces
1951 findSlavesCoveringMaster
1962 masterPatchPtr_.reset
1971 slavePatchPtr_.reset
1984 perfectPointMatch(absTol,
false);
1989 subDivisionMatch(slaveMesh,
false, absTol);
2007 const scalar absTol,
2008 const bool perfectMatch,
2009 const bool orderedFaces,
2010 const bool patchDivision
2031 cutToMasterFaces_(0),
2032 masterToCutPoints_(0),
2033 cutToSlaveFaces_(0),
2034 slaveToCutPoints_(0),
2037 if (perfectMatch && (masterAddressing.
size() != slaveAddressing.
size()))
2041 "faceCoupleInfo::faceCoupleInfo(const primitiveMesh&"
2042 ", const primitiveMesh&, const scalar, const bool"
2043 ) <<
"Perfect match specified but number of master and slave faces"
2044 <<
" differ." << endl
2045 <<
"master:" << masterAddressing.
size()
2046 <<
" slave:" << slaveAddressing.
size()
2052 masterAddressing.
size()
2058 "faceCoupleInfo::faceCoupleInfo(const primitiveMesh&"
2059 ", const primitiveMesh&, const scalar, const bool"
2060 ) <<
"Supplied internal face on master mesh to couple." << nl
2061 <<
"Faces to be coupled have to be boundary faces."
2066 slaveAddressing.
size()
2072 "faceCoupleInfo::faceCoupleInfo(const primitiveMesh&"
2073 ", const primitiveMesh&, const scalar, const bool"
2074 ) <<
"Supplied internal face on slave mesh to couple." << nl
2075 <<
"Faces to be coupled have to be boundary faces."
2082 perfectPointMatch(absTol, orderedFaces);
2087 subDivisionMatch(slaveMesh, patchDivision, absTol);
2109 label faceI = pp.
start();
2127 map.insert(i, lst[i]);
2145 map.insert(i, lst[i]);