40 const scalar faceCoupleInfo::angleTol_ = 1e-3;
46 void Foam::faceCoupleInfo::writeOBJ
48 const fileName& fName,
64 const edge& e = edges[edgeI];
70 if (pointMap[pointi] == -1)
72 pointMap[pointi] = newPointi++;
91 const edge& e = edges[edgeI];
93 str<<
"l " << pointMap[e[0]]+1 <<
' ' << pointMap[e[1]]+1 <<
nl;
98 void Foam::faceCoupleInfo::writeOBJ
100 const fileName& fName,
105 Pout<<
"Writing connections as edges to " << fName <<
endl;
117 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
122 void Foam::faceCoupleInfo::writePointsFaces()
const 130 OFstream str(
"masterPatch.obj");
135 OFstream str(
"slavePatch.obj");
140 OFstream str(
"cutFaces.obj");
147 Pout<<
"Writing cutToMasterPoints to cutToMasterPoints.obj" <<
endl;
151 "cutToMasterPoints.obj",
153 pointField(c.localPoints(), masterToCutPoints_));
156 Pout<<
"Writing cutToSlavePoints to cutToSlavePoints.obj" <<
endl;
160 "cutToSlavePoints.obj",
162 pointField(c.localPoints(), slaveToCutPoints_)
168 Pout<<
"Writing cutToMasterFaces to cutToMasterFaces.obj" <<
endl;
172 forAll(cutToMasterFaces(), cutFacei)
174 label masterFacei = cutToMasterFaces()[cutFacei];
176 if (masterFacei != -1)
178 equivMasterFaces[cutFacei] = m[masterFacei].centre(m.points());
183 <<
"No master face for cut face " << cutFacei
184 <<
" at position " << c[cutFacei].centre(c.points())
187 equivMasterFaces[cutFacei] =
Zero;
193 "cutToMasterFaces.obj",
194 calcFaceCentres<List>(c, cutPoints(), 0, c.size()),
200 Pout<<
"Writing cutToSlaveFaces to cutToSlaveFaces.obj" <<
endl;
204 forAll(cutToSlaveFaces(), cutFacei)
206 label slaveFacei = cutToSlaveFaces()[cutFacei];
208 equivSlaveFaces[cutFacei] = s[slaveFacei].centre(s.points());
213 "cutToSlaveFaces.obj",
214 calcFaceCentres<List>(c, cutPoints(), 0, c.size()),
223 void Foam::faceCoupleInfo::writeEdges
235 OFstream str(
"cutToMasterEdges.obj");
236 Pout<<
"Writing cutToMasterEdges to " << str.
name() <<
endl;
240 forAll(cutToMasterEdges, cutEdgeI)
242 if (cutToMasterEdges[cutEdgeI] != -1)
244 const edge& masterEdge =
245 m.edges()[cutToMasterEdges[cutEdgeI]];
246 const edge& cutEdge = c.edges()[cutEdgeI];
256 str <<
"l " << vertI-3 <<
' ' << vertI-2 <<
nl;
257 str <<
"l " << vertI-3 <<
' ' << vertI-1 <<
nl;
258 str <<
"l " << vertI-3 <<
' ' << vertI <<
nl;
259 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
nl;
260 str <<
"l " << vertI-2 <<
' ' << vertI <<
nl;
261 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
266 OFstream str(
"cutToSlaveEdges.obj");
267 Pout<<
"Writing cutToSlaveEdges to " << str.
name() <<
endl;
275 if (slaveToCut[edgeI] != -1)
277 const edge& slaveEdge = s.edges()[edgeI];
278 const edge& cutEdge = c.edges()[slaveToCut[edgeI]];
288 str <<
"l " << vertI-3 <<
' ' << vertI-2 <<
nl;
289 str <<
"l " << vertI-3 <<
' ' << vertI-1 <<
nl;
290 str <<
"l " << vertI-3 <<
' ' << vertI <<
nl;
291 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
nl;
292 str <<
"l " << vertI-2 <<
' ' << vertI <<
nl;
293 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
311 forAll(toPatchEdges, edgeI)
313 const edge& e = edges[edgeI];
315 label v0 = pointMap[e[0]];
316 label v1 = pointMap[e[1]];
318 toPatchEdges[edgeI] =
322 patch.pointEdges()[v0],
331 bool Foam::faceCoupleInfo::regionEdge
333 const polyMesh& slaveMesh,
334 const label slaveEdgeI
337 const labelList& eFaces = slavePatch().edgeFaces()[slaveEdgeI];
339 if (eFaces.size() == 1)
351 label facei = eFaces[i];
353 label meshFacei = slavePatch().addressing()[facei];
355 label patchi = slaveMesh.boundaryMesh().whichPatch(meshFacei);
361 else if (patchi != patch0)
372 Foam::label Foam::faceCoupleInfo::mostAlignedCutEdge
375 const polyMesh& slaveMesh,
376 const bool patchDivision,
380 const label edgeStart,
388 const pointField& localPoints = cutFaces().localPoints();
390 const labelList& pEdges = cutFaces().pointEdges()[pointi];
394 Pout<<
"mostAlignedEdge : finding nearest edge among " 395 << UIndirectList<edge>(cutFaces().edges(), pEdges)()
396 <<
" connected to point " << pointi
397 <<
" coord:" << localPoints[pointi]
398 <<
" running between " << edgeStart <<
" coord:" 399 << localPoints[edgeStart]
400 <<
" and " << edgeEnd <<
" coord:" 401 << localPoints[edgeEnd]
408 scalar maxCos = -great;
412 label edgeI = pEdges[i];
418 && cutToMasterEdges[edgeI] == -1
422 && regionEdge(slaveMesh, cutToSlaveEdges[edgeI])
426 const edge& e = cutFaces().edges()[edgeI];
428 label otherPointi = e.otherVertex(pointi);
430 if (otherPointi == edgeEnd)
435 Pout<<
" mostAlignedEdge : found end point " << edgeEnd
443 vector eVec(localPoints[otherPointi] - localPoints[pointi]);
445 scalar magEVec =
mag(eVec);
447 if (magEVec < vSmall)
450 <<
"Crossing zero sized edge " << edgeI
451 <<
" coords:" << localPoints[otherPointi]
452 << localPoints[pointi]
453 <<
" when walking from " << localPoints[edgeStart]
454 <<
" to " << localPoints[edgeEnd]
461 vector eToEndPoint(localPoints[edgeEnd] - localPoints[otherPointi]);
462 eToEndPoint /=
mag(eToEndPoint);
464 scalar cosAngle = eVec & eToEndPoint;
468 Pout<<
" edge:" << e <<
" points:" << localPoints[pointi]
469 << localPoints[otherPointi]
471 <<
" vecToEnd:" << eToEndPoint
472 <<
" cosAngle:" << cosAngle
476 if (cosAngle > maxCos)
484 if (maxCos > 1 - angleTol_)
495 void Foam::faceCoupleInfo::setCutEdgeToPoints(
const labelList& cutToMasterEdges)
501 masterPatch().nEdges(),
506 const edgeList& cutEdges = cutFaces().edges();
511 masterPatch().nEdges()
512 + slavePatch().nEdges()
516 forAll(masterToCutEdges, masterEdgeI)
518 const edge& masterE = masterPatch().edges()[masterEdgeI];
523 const labelList& stringedEdges = masterToCutEdges[masterEdgeI];
525 if (stringedEdges.empty())
528 <<
"Did not match all of master edges to cutFace edges" 530 <<
"First unmatched edge:" << masterEdgeI <<
" endPoints:" 531 << masterPatch().localPoints()[masterE[0]]
532 << masterPatch().localPoints()[masterE[1]]
534 <<
"This usually means that the slave patch is not a" 535 <<
" subdivision of the master patch" 538 else if (stringedEdges.size() > 1)
543 DynamicList<label> splitPoints(stringedEdges.size()-1);
546 const edge unsplitEdge
548 masterToCutPoints_[masterE[0]],
549 masterToCutPoints_[masterE[1]]
552 label startVertI = unsplitEdge[0];
553 label startEdgeI = -1;
555 while (startVertI != unsplitEdge[1])
563 label oldStart = startVertI;
567 label edgeI = stringedEdges[i];
569 if (edgeI != startEdgeI)
571 const edge& e = cutEdges[edgeI];
577 if (e[0] == startVertI)
581 if (e[1] != unsplitEdge[1])
583 splitPoints.append(e[1]);
587 else if (e[1] == startVertI)
591 if (e[0] != unsplitEdge[1])
593 splitPoints.append(e[0]);
601 if (oldStart == startVertI)
604 <<
" unsplitEdge:" << unsplitEdge
605 <<
" does not correspond to split edges " 606 << UIndirectList<edge>(cutEdges, stringedEdges)()
621 cutEdgeToPoints_.insert(unsplitEdge, splitPoints.shrink());
634 const bool sameOrientation
637 if (f0.size() != f1.size())
640 <<
"Different sizes for supposedly matching faces." << nl
641 <<
"f0:" << f0 <<
" coords:" << UIndirectList<point>(points0, f0)()
643 <<
"f1:" << f1 <<
" coords:" << UIndirectList<point>(points1,
f1)()
647 const scalar absTolSqr =
sqr(absTol);
655 bool fullMatch =
true;
662 scalar distSqr =
Foam::magSqr(points0[f0[fp0]] - points1[f1[fp1]]);
664 if (distSqr > absTolSqr)
670 fp0 = f0.fcIndex(fp0);
674 fp1 = f1.fcIndex(fp1);
678 fp1 = f1.rcIndex(fp1);
692 <<
"No unique match between two faces" << nl
693 <<
"Face " << f0 <<
" coords " 694 << UIndirectList<point>(points0, f0)() << nl
695 <<
"Face " << f1 <<
" coords " 696 << UIndirectList<point>(points1,
f1)()
697 <<
"when using tolerance " << absTol
698 <<
" and forwardMatching:" << sameOrientation
706 bool Foam::faceCoupleInfo::matchPointsThroughFaces
713 const bool sameOrientation,
726 patchToCutPoints.setSize(patchPoints.size());
727 patchToCutPoints = -1;
731 labelList cutPointRegion(cutPoints.size(), -1);
732 DynamicList<label> cutPointRegionMaster;
734 forAll(patchFaces, patchFacei)
736 const face& patchF = patchFaces[patchFacei];
739 const face& cutF = cutFaces[patchFacei];
742 label patchFp = matchFaces
754 label cutPointi = cutF[cutFp];
755 label patchPointi = patchF[patchFp];
767 if (patchToCutPoints[patchPointi] == -1)
769 patchToCutPoints[patchPointi] = cutPointi;
771 else if (patchToCutPoints[patchPointi] != cutPointi)
775 label otherCutPointi = patchToCutPoints[patchPointi];
784 if (cutPointRegion[otherCutPointi] != -1)
787 label region = cutPointRegion[otherCutPointi];
788 cutPointRegion[cutPointi] = region;
791 cutPointRegionMaster[region] =
min 793 cutPointRegionMaster[region],
800 label region = cutPointRegionMaster.size();
801 cutPointRegionMaster.append
803 min(cutPointi, otherCutPointi)
805 cutPointRegion[cutPointi] = region;
806 cutPointRegion[otherCutPointi] = region;
812 patchFp = patchF.fcIndex(patchFp);
816 patchFp = patchF.rcIndex(patchFp);
822 compactToCut.setSize(cutPointRegion.size());
823 cutToCompact.setSize(cutPointRegion.size());
825 label compactPointi = 0;
829 if (cutPointRegion[i] == -1)
832 cutToCompact[i] = compactPointi;
833 compactToCut[compactPointi] = i;
840 label masterPointi = cutPointRegionMaster[cutPointRegion[i]];
842 if (cutToCompact[masterPointi] == -1)
844 cutToCompact[masterPointi] = compactPointi;
845 compactToCut[compactPointi] = masterPointi;
848 cutToCompact[i] = cutToCompact[masterPointi];
851 compactToCut.setSize(compactPointi);
853 return compactToCut.size() != cutToCompact.size();
857 Foam::scalar Foam::faceCoupleInfo::maxDistance
865 scalar maxDist = -great;
869 const point& cutPt = cutPoints[cutF[fp]];
871 pointHit pHit = masterF.nearestPoint(cutPt, masterPoints);
873 maxDist =
max(maxDist, pHit.distance());
879 void Foam::faceCoupleInfo::findPerfectMatchingFaces
881 const primitiveMesh& mesh0,
882 const primitiveMesh& mesh1,
894 calcFaceCentres<List>
898 mesh0.nInternalFaces(),
899 mesh0.nFaces() - mesh0.nInternalFaces()
905 calcFaceCentres<List>
909 mesh1.nInternalFaces(),
910 mesh1.nFaces() - mesh1.nInternalFaces()
917 Pout<<
"Face matching tolerance : " << absTol <<
endl;
935 <<
"Matched ALL " << fc1.size()
936 <<
" boundary faces of mesh0 to boundary faces of mesh1." << endl
937 <<
"This is only valid if the mesh to add is fully" 938 <<
" enclosed by the mesh it is added to." <<
endl;
945 mesh0Faces.setSize(fc0.size());
946 mesh1Faces.setSize(fc1.size());
950 if (from1To0[i] != -1)
952 mesh1Faces[nMatched] = i + mesh1.nInternalFaces();
953 mesh0Faces[nMatched] = from1To0[i] + mesh0.nInternalFaces();
959 mesh0Faces.setSize(nMatched);
960 mesh1Faces.setSize(nMatched);
964 void Foam::faceCoupleInfo::findSlavesCoveringMaster
966 const primitiveMesh& mesh0,
967 const primitiveMesh& mesh1,
975 labelList bndFaces(mesh0.nFaces()-mesh0.nInternalFaces());
978 bndFaces[i] = mesh0.nInternalFaces() + i;
981 treeBoundBox overallBb(mesh0.points());
983 indexedOctree<treeDataFace> tree
991 overallBb.extend(1e-4),
999 Pout<<
"findSlavesCoveringMaster :" 1000 <<
" constructed octree for mesh0 boundary faces" <<
endl;
1005 labelHashSet mesh0Set(mesh0.nFaces() - mesh0.nInternalFaces());
1006 labelHashSet mesh1Set(mesh1.nFaces() - mesh1.nInternalFaces());
1010 label mesh1Facei = mesh1.nInternalFaces();
1011 mesh1Facei < mesh1.nFaces();
1015 const face& f1 = mesh1.faces()[mesh1Facei];
1018 point fc(f1.centre(mesh1.points()));
1024 label mesh0Facei = tree.shapes().faceLabels()[nearInfo.index()];
1037 mesh0.faces()[mesh0Facei],
1043 mesh0Set.insert(mesh0Facei);
1044 mesh1Set.insert(mesh1Facei);
1051 Pout<<
"findSlavesCoveringMaster :" 1052 <<
" matched " << mesh1Set.size() <<
" mesh1 faces to " 1053 << mesh0Set.size() <<
" mesh0 faces" <<
endl;
1056 mesh0Faces = mesh0Set.toc();
1057 mesh1Faces = mesh1Set.toc();
1064 Map<labelList>& candidates
1069 Pout<<
"growCutFaces :" 1070 <<
" growing cut faces to masterPatch" <<
endl;
1073 label nTotChanged = 0;
1082 forAll(cutToMasterFaces_, cutFacei)
1084 const label masterFacei = cutToMasterFaces_[cutFacei];
1086 if (masterFacei != -1)
1092 const labelList& fEdges = cutFaceEdges[cutFacei];
1096 const label cutEdgeI = fEdges[i];
1098 if (cutToMasterEdges[cutEdgeI] == -1)
1106 const labelList& eFaces = cutEdgeFaces[cutEdgeI];
1110 const label facei = eFaces[j];
1112 if (cutToMasterFaces_[facei] == -1)
1114 cutToMasterFaces_[facei] = masterFacei;
1115 candidates.erase(facei);
1118 else if (cutToMasterFaces_[facei] != masterFacei)
1121 cutFaces().points();
1123 masterPatch().points();
1125 const edge& e = cutFaces().edges()[cutEdgeI];
1127 label myMaster = cutToMasterFaces_[facei];
1128 const face& myF = masterPatch()[myMaster];
1130 const face& nbrF = masterPatch()[masterFacei];
1134 << cutFaces()[facei].points(cutPoints)
1137 <<
" but also connects to nbr face " 1138 << cutFaces()[cutFacei].points(cutPoints)
1139 <<
" with master " << masterFacei
1142 << myF.points(masterPoints)
1143 <<
" nbrMasterFace:" 1144 << nbrF.points(masterPoints) << nl
1145 <<
"Across cut edge " << cutEdgeI
1147 << cutFaces().localPoints()[e[0]]
1148 << cutFaces().localPoints()[e[1]]
1159 Pout<<
"growCutFaces : Grown an additional " << nChanged
1160 <<
" cut to master face" <<
" correspondence" <<
endl;
1163 nTotChanged += nChanged;
1175 void Foam::faceCoupleInfo::checkMatch(
const labelList& cutToMasterEdges)
const 1177 const pointField& cutLocalPoints = cutFaces().localPoints();
1179 const pointField& masterLocalPoints = masterPatch().localPoints();
1180 const faceList& masterLocalFaces = masterPatch().localFaces();
1182 forAll(cutToMasterEdges, cutEdgeI)
1184 const edge& e = cutFaces().edges()[cutEdgeI];
1186 if (cutToMasterEdges[cutEdgeI] == -1)
1189 const labelList& cutEFaces = cutFaces().edgeFaces()[cutEdgeI];
1191 label masterFacei = -1;
1195 label cutFacei = cutEFaces[i];
1197 if (cutToMasterFaces_[cutFacei] != -1)
1199 if (masterFacei == -1)
1201 masterFacei = cutToMasterFaces_[cutFacei];
1203 else if (masterFacei != cutToMasterFaces_[cutFacei])
1205 label myMaster = cutToMasterFaces_[cutFacei];
1206 const face& myF = masterLocalFaces[myMaster];
1208 const face& nbrF = masterLocalFaces[masterFacei];
1211 <<
"Internal CutEdge " << e
1213 << cutLocalPoints[e[0]]
1214 << cutLocalPoints[e[1]]
1215 <<
" connects to master " << myMaster
1216 <<
" and to master " << masterFacei << nl
1218 << myF.points(masterLocalPoints)
1219 <<
" nbrMasterFace:" 1220 << nbrF.points(masterLocalPoints)
1233 Map<labelList>& candidates
1242 candidates.resize(cutFaces().size());
1246 forAll(cutToMasterEdges, cutEdgeI)
1248 label masterEdgeI = cutToMasterEdges[cutEdgeI];
1250 if (masterEdgeI != -1)
1255 const labelList& cutEFaces = cutFaces().edgeFaces()[cutEdgeI];
1257 masterPatch().edgeFaces()[masterEdgeI];
1261 label cutFacei = cutEFaces[i];
1263 if (cutToMasterFaces_[cutFacei] == -1)
1274 if (fnd == candidates.end())
1278 candidates.insert(cutFacei, masterEFaces);
1287 DynamicList<label> newCandidates(masterFaces.size());
1291 if (
findIndex(masterFaces, masterEFaces[j]) != -1)
1293 newCandidates.append(masterEFaces[j]);
1297 if (newCandidates.size() == 1)
1301 cutToMasterFaces_[cutFacei] = newCandidates[0];
1302 candidates.erase(cutFacei);
1315 fnd() = newCandidates.shrink();
1326 Pout<<
"matchEdgeFaces : Found " << nChanged
1327 <<
" faces where there was" 1328 <<
" only one remaining choice for cut-master correspondence" 1336 Foam::label Foam::faceCoupleInfo::geometricMatchEdgeFaces
1338 Map<labelList>& candidates
1341 const pointField& cutPoints = cutFaces().points();
1351 masterPatch().size(),
1358 label cutFacei = iter.key();
1360 const face& cutF = cutFaces()[cutFacei];
1362 if (cutToMasterFaces_[cutFacei] == -1)
1367 scalar minDist = great;
1368 label minMasterFacei = -1;
1372 label masterFacei = masterFaces[i];
1374 if (masterToCutFaces[masterFaces[i]].empty())
1376 scalar dist = maxDistance
1380 masterPatch()[masterFacei],
1387 minMasterFacei = masterFacei;
1392 if (minMasterFacei != -1)
1394 cutToMasterFaces_[cutFacei] = minMasterFacei;
1395 masterToCutFaces[minMasterFacei] = cutFacei;
1402 forAll(cutToMasterFaces_, cutFacei)
1404 if (cutToMasterFaces_[cutFacei] != -1)
1406 candidates.erase(cutFacei);
1413 Pout<<
"geometricMatchEdgeFaces : Found " << nChanged
1414 <<
" faces where there was" 1415 <<
" only one remaining choice for cut-master correspondence" 1423 void Foam::faceCoupleInfo::perfectPointMatch
1425 const scalar absTol,
1426 const bool slaveFacesOrdered
1434 Pout<<
"perfectPointMatch :" 1435 <<
" Matching master and slave to cut." 1436 <<
" Master and slave faces are identical" <<
nl;
1438 if (slaveFacesOrdered)
1440 Pout<<
"and master and slave faces are ordered" 1441 <<
" (on coupled patches)" <<
endl;
1445 Pout<<
"and master and slave faces are not ordered" 1446 <<
" (on coupled patches)" <<
endl;
1450 cutToMasterFaces_ =
identity(masterPatch().size());
1451 cutPoints_ = masterPatch().localPoints();
1456 masterPatch().localFaces(),
1460 masterToCutPoints_ =
identity(cutPoints_.size());
1464 bool matchedAllFaces =
false;
1466 if (slaveFacesOrdered)
1468 cutToSlaveFaces_ =
identity(cutFaces().size());
1469 matchedAllFaces = (cutFaces().size() == slavePatch().size());
1479 calcFaceCentres<List>
1486 calcFaceCentres<IndirectList>
1502 if (!matchedAllFaces)
1504 labelList cutToSlaveFacesTemp(cutToSlaveFaces_.size(), -1);
1508 calcFacePointAverages<List>
1515 calcFacePointAverages<IndirectList>
1527 cutToSlaveFaces_ =
max(cutToSlaveFaces_, cutToSlaveFacesTemp);
1529 matchedAllFaces =
min(cutToSlaveFaces_) != -1;
1534 if (!matchedAllFaces)
1537 <<
"Did not match all of the master faces to the slave faces" 1539 <<
"This usually means that the slave patch and master patch" 1540 <<
" do not align to within " << absTol <<
" metre." 1550 matchPointsThroughFaces
1553 cutFaces().localPoints(),
1554 reorder(cutToSlaveFaces_, cutFaces().localFaces()),
1555 slavePatch().localPoints(),
1556 slavePatch().localFaces(),
1566 cutPoints_ = UIndirectList<point>(cutPoints_, compactToCut)();
1568 const faceList& cutLocalFaces = cutFaces().localFaces();
1570 faceList compactFaces(cutLocalFaces.size());
1573 compactFaces[i] =
renumber(cutToCompact, cutLocalFaces[i]);
1589 void Foam::faceCoupleInfo::subDivisionMatch
1591 const polyMesh& slaveMesh,
1592 const bool patchDivision,
1598 Pout<<
"subDivisionMatch :" 1599 <<
" Matching master and slave to cut." 1600 <<
" Slave can be subdivision of master but all master edges" 1601 <<
" have to be covered by slave edges." <<
endl;
1606 cutPoints_ = slavePatch().localPoints();
1608 faceList cutFaces(slavePatch().size());
1612 cutFaces[i] = slavePatch().localFaces()[i].reverseFace();
1618 cutToSlaveFaces_ =
identity(cutFaces().size());
1635 OFstream str(
"regionEdges.obj");
1637 Pout<<
"subDivisionMatch :" 1638 <<
" addressing for slave patch fully done." 1639 <<
" Dumping region edges to " << str.
name() <<
endl;
1643 forAll(slavePatch().edges(), slaveEdgeI)
1645 if (regionEdge(slaveMesh, slaveEdgeI))
1647 const edge& e = slavePatch().edges()[slaveEdgeI];
1653 str<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
1666 Pout<<
"subDivisionMatch :" 1667 <<
" matching master points to cut points" <<
endl;
1672 masterPatch().localPoints(),
1679 if (!matchedAllPoints)
1682 <<
"Did not match all of the master points to the slave points" 1684 <<
"This usually means that the slave patch is not a" 1685 <<
" subdivision of the master patch" 1697 Pout<<
"subDivisionMatch :" 1698 <<
" matching cut edges to master edges" <<
endl;
1701 const edgeList& masterEdges = masterPatch().edges();
1702 const pointField& masterPoints = masterPatch().localPoints();
1704 const edgeList& cutEdges = cutFaces().edges();
1706 labelList cutToMasterEdges(cutFaces().nEdges(), -1);
1708 forAll(masterEdges, masterEdgeI)
1710 const edge& masterEdge = masterEdges[masterEdgeI];
1712 label cutPoint0 = masterToCutPoints_[masterEdge[0]];
1713 label cutPoint1 = masterToCutPoints_[masterEdge[1]];
1717 label cutPointi = cutPoint0;
1750 Pout<<
"Dumping unmatched pointEdges to errorEdges.obj" 1761 cutFaces().pointEdges()[cutPointi]
1764 cutFaces().localPoints(),
1769 <<
"Problem in finding cut edges corresponding to" 1770 <<
" master edge " << masterEdge
1771 <<
" points:" << masterPoints[masterEdge[0]]
1772 <<
' ' << masterPoints[masterEdge[1]]
1773 <<
" corresponding cut edge: (" << cutPoint0
1774 <<
") " << cutPoint1
1778 cutToMasterEdges[cutEdgeI] = masterEdgeI;
1780 cutPointi = cutEdges[cutEdgeI].otherVertex(cutPointi);
1782 }
while (cutPointi != cutPoint1);
1788 writeEdges(cutToMasterEdges, cutToSlaveEdges);
1793 setCutEdgeToPoints(cutToMasterEdges);
1807 Pout<<
"subDivisionMatch :" 1808 <<
" matching (topological) cut faces to masterPatch" <<
endl;
1812 Map<labelList> candidates(cutFaces().size());
1814 cutToMasterFaces_.setSize(cutFaces().size());
1815 cutToMasterFaces_ = -1;
1821 label nChanged = matchEdgeFaces(cutToMasterEdges, candidates);
1823 checkMatch(cutToMasterEdges);
1830 nChanged += growCutFaces(cutToMasterEdges, candidates);
1832 checkMatch(cutToMasterEdges);
1842 Pout<<
"subDivisionMatch :" 1843 <<
" matching (geometric) cut faces to masterPatch" <<
endl;
1852 label nChanged = geometricMatchEdgeFaces(candidates);
1854 checkMatch(cutToMasterEdges);
1856 nChanged += growCutFaces(cutToMasterEdges, candidates);
1858 checkMatch(cutToMasterEdges);
1868 forAll(cutToMasterFaces_, cutFacei)
1870 if (cutToMasterFaces_[cutFacei] == -1)
1872 const face& cutF = cutFaces()[cutFacei];
1875 <<
"Did not match all of cutFaces to a master face" << nl
1876 <<
"First unmatched cut face:" << cutFacei <<
" with points:" 1877 << UIndirectList<point>(cutFaces().points(), cutF)()
1879 <<
"This usually means that the slave patch is not a" 1880 <<
" subdivision of the master patch" 1887 Pout<<
"subDivisionMatch :" 1888 <<
" finished matching master and slave to cut" <<
endl;
1904 const scalar absTol,
1905 const bool perfectMatch
1908 masterPatchPtr_(
nullptr),
1909 slavePatchPtr_(
nullptr),
1911 cutFacesPtr_(
nullptr),
1912 cutToMasterFaces_(0),
1913 masterToCutPoints_(0),
1914 cutToSlaveFaces_(0),
1915 slaveToCutPoints_(0),
1927 findPerfectMatchingFaces
1940 findSlavesCoveringMaster
1951 masterPatchPtr_.reset
1960 slavePatchPtr_.reset
1973 perfectPointMatch(absTol,
false);
1978 subDivisionMatch(slaveMesh,
false, absTol);
1994 const scalar absTol,
1995 const bool perfectMatch,
1996 const bool orderedFaces,
1997 const bool patchDivision
2017 cutFacesPtr_(
nullptr),
2018 cutToMasterFaces_(0),
2019 masterToCutPoints_(0),
2020 cutToSlaveFaces_(0),
2021 slaveToCutPoints_(0),
2024 if (perfectMatch && (masterAddressing.
size() != slaveAddressing.
size()))
2027 <<
"Perfect match specified but number of master and slave faces" 2028 <<
" differ." << endl
2029 <<
"master:" << masterAddressing.
size()
2030 <<
" slave:" << slaveAddressing.
size()
2036 masterAddressing.
size()
2041 <<
"Supplied internal face on master mesh to couple." << nl
2042 <<
"Faces to be coupled have to be boundary faces." 2047 slaveAddressing.
size()
2052 <<
"Supplied internal face on slave mesh to couple." << nl
2053 <<
"Faces to be coupled have to be boundary faces." 2060 perfectPointMatch(absTol, orderedFaces);
2065 subDivisionMatch(slaveMesh, patchDivision, absTol);
2105 map.insert(i, lst[i]);
2123 map.insert(i, lst[i]);
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
virtual const fileName & name() const
Return the name of the stream.
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
static labelList faceLabels(const polyPatch &)
Utility functions.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
faceCoupleInfo(const polyMesh &mesh0, const polyMesh &mesh1, const scalar absTol, const bool perfectMatch)
Construct from two meshes and absolute tolerance.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label nInternalFaces() const
HashTable< T, label, Hash< label > >::iterator iterator
dimensionedSymmTensor sqr(const dimensionedVector &dv)
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
PointIndexHit< point > pointIndexHit
Vector< scalar > vector
A scalar version of the templated Vector.
void resize(const label)
Alias for setSize(const label)
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
Determine correspondence between points. See below.
virtual const pointField & points() const
Return raw points.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
A list of faces which address into the list of points.
bool matchPoints(const UList< point > &pts0, const UList< point > &pts1, const UList< scalar > &matchDistance, const bool verbose, labelList &from0To1, const point &origin=point::zero)
Determine correspondence between pointFields. Gets passed.
vectorField pointField
pointField is a vectorField.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< label > labelList
A List of labels.
virtual const faceList & faces() const
Return raw faces.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
ListType reorder(const labelUList &oldToNew, const ListType &)
Reorder the elements (indices, not values) of a list.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
~faceCoupleInfo()
Destructor.
defineTypeNameAndDebug(combustionModel, 0)
static Map< label > makeMap(const labelList &)
Create Map from List.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
Foam::primitiveFacePatch.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
prefixOSstream Pout(cout, "Pout")
label start() const
Return start label of this patch in the polyMesh face list.
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
PointHit< point > pointHit
A patch is a list of labels that address the faces in the global face list.
A List with indirect addressing.
A HashTable to objects of type <T> with a label key.