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());
985 indexedOctree<treeDataFace> tree
993 overallBb.extend(
rndGen, 1e-4),
1001 Pout<<
"findSlavesCoveringMaster :" 1002 <<
" constructed octree for mesh0 boundary faces" <<
endl;
1007 labelHashSet mesh0Set(mesh0.nFaces() - mesh0.nInternalFaces());
1008 labelHashSet mesh1Set(mesh1.nFaces() - mesh1.nInternalFaces());
1012 label mesh1Facei = mesh1.nInternalFaces();
1013 mesh1Facei < mesh1.nFaces();
1017 const face& f1 = mesh1.faces()[mesh1Facei];
1020 point fc(f1.centre(mesh1.points()));
1026 label mesh0Facei = tree.shapes().faceLabels()[nearInfo.index()];
1039 mesh0.faces()[mesh0Facei],
1045 mesh0Set.insert(mesh0Facei);
1046 mesh1Set.insert(mesh1Facei);
1053 Pout<<
"findSlavesCoveringMaster :" 1054 <<
" matched " << mesh1Set.size() <<
" mesh1 faces to " 1055 << mesh0Set.size() <<
" mesh0 faces" <<
endl;
1058 mesh0Faces = mesh0Set.toc();
1059 mesh1Faces = mesh1Set.toc();
1066 Map<labelList>& candidates
1071 Pout<<
"growCutFaces :" 1072 <<
" growing cut faces to masterPatch" <<
endl;
1075 label nTotChanged = 0;
1084 forAll(cutToMasterFaces_, cutFacei)
1086 const label masterFacei = cutToMasterFaces_[cutFacei];
1088 if (masterFacei != -1)
1094 const labelList& fEdges = cutFaceEdges[cutFacei];
1098 const label cutEdgeI = fEdges[i];
1100 if (cutToMasterEdges[cutEdgeI] == -1)
1108 const labelList& eFaces = cutEdgeFaces[cutEdgeI];
1112 const label facei = eFaces[j];
1114 if (cutToMasterFaces_[facei] == -1)
1116 cutToMasterFaces_[facei] = masterFacei;
1117 candidates.erase(facei);
1120 else if (cutToMasterFaces_[facei] != masterFacei)
1123 cutFaces().points();
1125 masterPatch().points();
1127 const edge& e = cutFaces().edges()[cutEdgeI];
1129 label myMaster = cutToMasterFaces_[facei];
1130 const face& myF = masterPatch()[myMaster];
1132 const face& nbrF = masterPatch()[masterFacei];
1136 << cutFaces()[facei].points(cutPoints)
1139 <<
" but also connects to nbr face " 1140 << cutFaces()[cutFacei].points(cutPoints)
1141 <<
" with master " << masterFacei
1144 << myF.points(masterPoints)
1145 <<
" nbrMasterFace:" 1146 << nbrF.points(masterPoints) << nl
1147 <<
"Across cut edge " << cutEdgeI
1149 << cutFaces().localPoints()[e[0]]
1150 << cutFaces().localPoints()[e[1]]
1161 Pout<<
"growCutFaces : Grown an additional " << nChanged
1162 <<
" cut to master face" <<
" correspondence" <<
endl;
1165 nTotChanged += nChanged;
1177 void Foam::faceCoupleInfo::checkMatch(
const labelList& cutToMasterEdges)
const 1179 const pointField& cutLocalPoints = cutFaces().localPoints();
1181 const pointField& masterLocalPoints = masterPatch().localPoints();
1182 const faceList& masterLocalFaces = masterPatch().localFaces();
1184 forAll(cutToMasterEdges, cutEdgeI)
1186 const edge& e = cutFaces().edges()[cutEdgeI];
1188 if (cutToMasterEdges[cutEdgeI] == -1)
1191 const labelList& cutEFaces = cutFaces().edgeFaces()[cutEdgeI];
1193 label masterFacei = -1;
1197 label cutFacei = cutEFaces[i];
1199 if (cutToMasterFaces_[cutFacei] != -1)
1201 if (masterFacei == -1)
1203 masterFacei = cutToMasterFaces_[cutFacei];
1205 else if (masterFacei != cutToMasterFaces_[cutFacei])
1207 label myMaster = cutToMasterFaces_[cutFacei];
1208 const face& myF = masterLocalFaces[myMaster];
1210 const face& nbrF = masterLocalFaces[masterFacei];
1213 <<
"Internal CutEdge " << e
1215 << cutLocalPoints[e[0]]
1216 << cutLocalPoints[e[1]]
1217 <<
" connects to master " << myMaster
1218 <<
" and to master " << masterFacei << nl
1220 << myF.points(masterLocalPoints)
1221 <<
" nbrMasterFace:" 1222 << nbrF.points(masterLocalPoints)
1235 Map<labelList>& candidates
1244 candidates.resize(cutFaces().size());
1248 forAll(cutToMasterEdges, cutEdgeI)
1250 label masterEdgeI = cutToMasterEdges[cutEdgeI];
1252 if (masterEdgeI != -1)
1257 const labelList& cutEFaces = cutFaces().edgeFaces()[cutEdgeI];
1259 masterPatch().edgeFaces()[masterEdgeI];
1263 label cutFacei = cutEFaces[i];
1265 if (cutToMasterFaces_[cutFacei] == -1)
1276 if (fnd == candidates.end())
1280 candidates.insert(cutFacei, masterEFaces);
1289 DynamicList<label> newCandidates(masterFaces.size());
1293 if (
findIndex(masterFaces, masterEFaces[j]) != -1)
1295 newCandidates.append(masterEFaces[j]);
1299 if (newCandidates.size() == 1)
1303 cutToMasterFaces_[cutFacei] = newCandidates[0];
1304 candidates.erase(cutFacei);
1317 fnd() = newCandidates.shrink();
1328 Pout<<
"matchEdgeFaces : Found " << nChanged
1329 <<
" faces where there was" 1330 <<
" only one remaining choice for cut-master correspondence" 1338 Foam::label Foam::faceCoupleInfo::geometricMatchEdgeFaces
1340 Map<labelList>& candidates
1343 const pointField& cutPoints = cutFaces().points();
1353 masterPatch().size(),
1360 label cutFacei = iter.key();
1362 const face& cutF = cutFaces()[cutFacei];
1364 if (cutToMasterFaces_[cutFacei] == -1)
1369 scalar minDist = GREAT;
1370 label minMasterFacei = -1;
1374 label masterFacei = masterFaces[i];
1376 if (masterToCutFaces[masterFaces[i]].empty())
1378 scalar dist = maxDistance
1382 masterPatch()[masterFacei],
1389 minMasterFacei = masterFacei;
1394 if (minMasterFacei != -1)
1396 cutToMasterFaces_[cutFacei] = minMasterFacei;
1397 masterToCutFaces[minMasterFacei] = cutFacei;
1404 forAll(cutToMasterFaces_, cutFacei)
1406 if (cutToMasterFaces_[cutFacei] != -1)
1408 candidates.erase(cutFacei);
1415 Pout<<
"geometricMatchEdgeFaces : Found " << nChanged
1416 <<
" faces where there was" 1417 <<
" only one remaining choice for cut-master correspondence" 1425 void Foam::faceCoupleInfo::perfectPointMatch
1427 const scalar absTol,
1428 const bool slaveFacesOrdered
1436 Pout<<
"perfectPointMatch :" 1437 <<
" Matching master and slave to cut." 1438 <<
" Master and slave faces are identical" <<
nl;
1440 if (slaveFacesOrdered)
1442 Pout<<
"and master and slave faces are ordered" 1443 <<
" (on coupled patches)" <<
endl;
1447 Pout<<
"and master and slave faces are not ordered" 1448 <<
" (on coupled patches)" <<
endl;
1452 cutToMasterFaces_ =
identity(masterPatch().size());
1453 cutPoints_ = masterPatch().localPoints();
1458 masterPatch().localFaces(),
1462 masterToCutPoints_ =
identity(cutPoints_.size());
1466 bool matchedAllFaces =
false;
1468 if (slaveFacesOrdered)
1470 cutToSlaveFaces_ =
identity(cutFaces().size());
1471 matchedAllFaces = (cutFaces().size() == slavePatch().size());
1480 calcFaceCentres<List>
1487 calcFaceCentres<IndirectList>
1501 if (!matchedAllFaces)
1504 <<
"Did not match all of the master faces to the slave faces" 1506 <<
"This usually means that the slave patch and master patch" 1507 <<
" do not align to within " << absTol <<
" metre." 1517 matchPointsThroughFaces
1520 cutFaces().localPoints(),
1521 reorder(cutToSlaveFaces_, cutFaces().localFaces()),
1522 slavePatch().localPoints(),
1523 slavePatch().localFaces(),
1533 cutPoints_ = UIndirectList<point>(cutPoints_, compactToCut)();
1535 const faceList& cutLocalFaces = cutFaces().localFaces();
1537 faceList compactFaces(cutLocalFaces.size());
1540 compactFaces[i] =
renumber(cutToCompact, cutLocalFaces[i]);
1556 void Foam::faceCoupleInfo::subDivisionMatch
1558 const polyMesh& slaveMesh,
1559 const bool patchDivision,
1565 Pout<<
"subDivisionMatch :" 1566 <<
" Matching master and slave to cut." 1567 <<
" Slave can be subdivision of master but all master edges" 1568 <<
" have to be covered by slave edges." <<
endl;
1573 cutPoints_ = slavePatch().localPoints();
1575 faceList cutFaces(slavePatch().size());
1579 cutFaces[i] = slavePatch().localFaces()[i].reverseFace();
1585 cutToSlaveFaces_ =
identity(cutFaces().size());
1602 OFstream str(
"regionEdges.obj");
1604 Pout<<
"subDivisionMatch :" 1605 <<
" addressing for slave patch fully done." 1606 <<
" Dumping region edges to " << str.
name() <<
endl;
1610 forAll(slavePatch().edges(), slaveEdgeI)
1612 if (regionEdge(slaveMesh, slaveEdgeI))
1614 const edge& e = slavePatch().edges()[slaveEdgeI];
1620 str<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
1633 Pout<<
"subDivisionMatch :" 1634 <<
" matching master points to cut points" <<
endl;
1639 masterPatch().localPoints(),
1646 if (!matchedAllPoints)
1649 <<
"Did not match all of the master points to the slave points" 1651 <<
"This usually means that the slave patch is not a" 1652 <<
" subdivision of the master patch" 1664 Pout<<
"subDivisionMatch :" 1665 <<
" matching cut edges to master edges" <<
endl;
1668 const edgeList& masterEdges = masterPatch().edges();
1669 const pointField& masterPoints = masterPatch().localPoints();
1671 const edgeList& cutEdges = cutFaces().edges();
1673 labelList cutToMasterEdges(cutFaces().nEdges(), -1);
1675 forAll(masterEdges, masterEdgeI)
1677 const edge& masterEdge = masterEdges[masterEdgeI];
1679 label cutPoint0 = masterToCutPoints_[masterEdge[0]];
1680 label cutPoint1 = masterToCutPoints_[masterEdge[1]];
1684 label cutPointi = cutPoint0;
1717 Pout<<
"Dumping unmatched pointEdges to errorEdges.obj" 1728 cutFaces().pointEdges()[cutPointi]
1731 cutFaces().localPoints(),
1736 <<
"Problem in finding cut edges corresponding to" 1737 <<
" master edge " << masterEdge
1738 <<
" points:" << masterPoints[masterEdge[0]]
1739 <<
' ' << masterPoints[masterEdge[1]]
1740 <<
" corresponding cut edge: (" << cutPoint0
1741 <<
") " << cutPoint1
1745 cutToMasterEdges[cutEdgeI] = masterEdgeI;
1747 cutPointi = cutEdges[cutEdgeI].otherVertex(cutPointi);
1749 }
while (cutPointi != cutPoint1);
1755 writeEdges(cutToMasterEdges, cutToSlaveEdges);
1760 setCutEdgeToPoints(cutToMasterEdges);
1774 Pout<<
"subDivisionMatch :" 1775 <<
" matching (topological) cut faces to masterPatch" <<
endl;
1779 Map<labelList> candidates(cutFaces().size());
1781 cutToMasterFaces_.setSize(cutFaces().size());
1782 cutToMasterFaces_ = -1;
1788 label nChanged = matchEdgeFaces(cutToMasterEdges, candidates);
1790 checkMatch(cutToMasterEdges);
1797 nChanged += growCutFaces(cutToMasterEdges, candidates);
1799 checkMatch(cutToMasterEdges);
1809 Pout<<
"subDivisionMatch :" 1810 <<
" matching (geometric) cut faces to masterPatch" <<
endl;
1819 label nChanged = geometricMatchEdgeFaces(candidates);
1821 checkMatch(cutToMasterEdges);
1823 nChanged += growCutFaces(cutToMasterEdges, candidates);
1825 checkMatch(cutToMasterEdges);
1835 forAll(cutToMasterFaces_, cutFacei)
1837 if (cutToMasterFaces_[cutFacei] == -1)
1839 const face& cutF = cutFaces()[cutFacei];
1842 <<
"Did not match all of cutFaces to a master face" << nl
1843 <<
"First unmatched cut face:" << cutFacei <<
" with points:" 1844 << UIndirectList<point>(cutFaces().points(), cutF)()
1846 <<
"This usually means that the slave patch is not a" 1847 <<
" subdivision of the master patch" 1854 Pout<<
"subDivisionMatch :" 1855 <<
" finished matching master and slave to cut" <<
endl;
1871 const scalar absTol,
1872 const bool perfectMatch
1875 masterPatchPtr_(NULL),
1876 slavePatchPtr_(NULL),
1879 cutToMasterFaces_(0),
1880 masterToCutPoints_(0),
1881 cutToSlaveFaces_(0),
1882 slaveToCutPoints_(0),
1894 findPerfectMatchingFaces
1907 findSlavesCoveringMaster
1918 masterPatchPtr_.reset
1927 slavePatchPtr_.reset
1940 perfectPointMatch(absTol,
false);
1945 subDivisionMatch(slaveMesh,
false, absTol);
1961 const scalar absTol,
1962 const bool perfectMatch,
1963 const bool orderedFaces,
1964 const bool patchDivision
1985 cutToMasterFaces_(0),
1986 masterToCutPoints_(0),
1987 cutToSlaveFaces_(0),
1988 slaveToCutPoints_(0),
1991 if (perfectMatch && (masterAddressing.
size() != slaveAddressing.
size()))
1994 <<
"Perfect match specified but number of master and slave faces" 1995 <<
" differ." << endl
1996 <<
"master:" << masterAddressing.
size()
1997 <<
" slave:" << slaveAddressing.
size()
2003 masterAddressing.
size()
2008 <<
"Supplied internal face on master mesh to couple." << nl
2009 <<
"Faces to be coupled have to be boundary faces." 2014 slaveAddressing.
size()
2019 <<
"Supplied internal face on slave mesh to couple." << nl
2020 <<
"Faces to be coupled have to be boundary faces." 2027 perfectPointMatch(absTol, orderedFaces);
2032 subDivisionMatch(slaveMesh, patchDivision, absTol);
2072 map.insert(i, lst[i]);
2090 map.insert(i, lst[i]);
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
cachedRandom rndGen(label(0),-1)
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.
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< face, IndirectList, 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.
label start() const
Return start label of this patch in the polyMesh face list.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual const fileName & name() const
Return the name of the stream.
List< label > labelList
A List of labels.
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 > &)
prefixOSstream Pout(cout,"Pout")
~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 occurence of given element and return index,.
PrimitivePatch< face, List, 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.
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.
virtual const faceList & faces() const
Return raw faces.
label nInternalFaces() const
A List with indirect addressing.
A HashTable to objects of type <T> with a label key.