64void Foam::globalMeshData::initProcAddr()
67 processorPatchIndices_ = -1;
70 processorPatchNeighbours_ = -1;
76 label nNeighbours = 0;
82 processorPatches_[nNeighbours] = patchi;
83 processorPatchIndices_[patchi] = nNeighbours++;
86 processorPatches_.resize(nNeighbours);
94 PstreamBuffers pBufs(mesh_.comm());
97 for (
const label patchi : processorPatches_)
103 mesh_.boundaryMesh()[patchi]
108 toNeighbour << processorPatchIndices_[patchi];
111 pBufs.finishedSends();
113 for (
const label patchi : processorPatches_)
115 UIPstream fromNeighbour
119 mesh_.boundaryMesh()[patchi]
124 fromNeighbour >> processorPatchNeighbours_[patchi];
133void Foam::globalMeshData::calcSharedPoints()
const
138 || sharedPointLabelsPtr_
139 || sharedPointAddrPtr_
155 forAll(parallelPoints.pointPoints(), i)
157 const labelList& pPoints = parallelPoints.pointPoints()[i];
159 parallelPoints.transformedPointPoints()[i];
161 if (pPoints.size()+transPPoints.size() > 0)
170 nGlobalPoints_ = masterNumbering.totalSize();
177 labelList master(parallelPoints.map().constructSize(), -1);
178 forAll(parallelPoints.pointPoints(), i)
180 const labelList& pPoints = parallelPoints.pointPoints()[i];
182 parallelPoints.transformedPointPoints()[i];
184 if (pPoints.size()+transPPoints.size() > 0)
186 master[i] = masterNumbering.toGlobal(nMaster);
207 parallelPoints.map().reverseDistribute
209 parallelPoints.map().constructSize(),
216 forAll(parallelPoints.pointPoints(), i)
224 sharedPointLabelsPtr_.reset(
new labelList(nMaster));
225 labelList& sharedPointLabels = sharedPointLabelsPtr_();
226 sharedPointAddrPtr_.reset(
new labelList(nMaster));
227 labelList& sharedPointAddr = sharedPointAddrPtr_();
230 forAll(parallelPoints.pointPoints(), i)
235 sharedPointLabels[nMaster] = i;
236 sharedPointAddr[nMaster] = master[i];
246 Pout<<
"globalMeshData : nGlobalPoints_:" << nGlobalPoints_ <<
nl
247 <<
"globalMeshData : sharedPointLabels_:"
248 << sharedPointLabelsPtr_().size() <<
nl
249 <<
"globalMeshData : sharedPointAddr_:"
250 << sharedPointAddrPtr_().size() <<
endl;
255void Foam::globalMeshData::countSharedEdges
265 const edge&
e = iter.key();
267 auto globalFnd = globalShared.
find(
e);
269 if (globalFnd.good())
271 if (globalFnd() == -1)
275 globalFnd() = sharedEdgeI++;
281 if (iter().size() == 1)
284 globalShared.insert(
e, -1);
290 globalShared.insert(
e, sharedEdgeI++);
297void Foam::globalMeshData::calcSharedEdges()
const
307 || sharedEdgeLabelsPtr_
308 || sharedEdgeAddrPtr_
316 const labelList& sharedPtAddr = sharedPointAddr();
317 const labelList& sharedPtLabels = sharedPointLabels();
329 const edgeList& edges = mesh_.edges();
333 const edge&
e = edges[edgei];
335 const auto e0Fnd = meshToShared.cfind(
e[0]);
339 const auto e1Fnd = meshToShared.cfind(
e[1]);
349 sharedPtAddr[e0Fnd.val()],
350 sharedPtAddr[e1Fnd.val()]
354 localShared(sharedEdge).push_back(edgei);
376 label sharedEdgeI = 0;
381 Pout<<
"globalMeshData::calcSharedEdges : Merging in from proc0 : "
382 << localShared.size() <<
endl;
384 countSharedEdges(localShared, globalShared, sharedEdgeI);
397 Pout<<
"globalMeshData::calcSharedEdges : "
398 <<
"Merging in from proc"
399 << proci <<
" : " << procSharedEdges.size()
402 countSharedEdges(procSharedEdges, globalShared, sharedEdgeI);
411 globalShared.clear();
415 if (iter.val() != -1)
417 globalShared.insert(iter.key(), iter.val());
423 Pout<<
"globalMeshData::calcSharedEdges : Filtered "
424 << oldSharedEdges.size()
425 <<
" down to " << globalShared.size() <<
endl;
445 nGlobalEdges_ = globalShared.size();
452 const edge&
e = iter.key();
454 const auto edgeFnd = globalShared.cfind(
e);
460 const labelList& edgeLabels = iter.val();
462 for (
const label edgei : edgeLabels)
465 dynSharedEdgeLabels.append(edgei);
468 dynSharedEdgeAddr.append(edgeFnd());
474 sharedEdgeLabelsPtr_.reset
476 new labelList(std::move(dynSharedEdgeLabels))
479 sharedEdgeAddrPtr_.reset
481 new labelList(std::move(dynSharedEdgeAddr))
489 Pout<<
"globalMeshData : nGlobalEdges_:" << nGlobalEdges_ <<
nl
490 <<
"globalMeshData : sharedEdgeLabels:"
491 << sharedEdgeLabelsPtr_().size() <<
nl
492 <<
"globalMeshData : sharedEdgeAddr:"
493 << sharedEdgeAddrPtr_().size() <<
endl;
498void Foam::globalMeshData::calcGlobalPointSlaves()
const
502 Pout<<
"globalMeshData::calcGlobalPointSlaves() :"
503 <<
" calculating coupled master to slave point addressing."
511 globalPoints globalData(mesh_, coupledPatch(),
true,
true);
513 globalPointSlavesPtr_.reset
517 std::move(globalData.pointPoints())
520 globalPointTransformedSlavesPtr_.reset
524 std::move(globalData.transformedPointPoints())
528 globalPointSlavesMapPtr_.reset
532 std::move(globalData.map())
541void Foam::globalMeshData::calcPointConnectivity
548 const labelListList& transformedSlaves = globalPointTransformedSlaves();
549 const auto& slavesMap = globalPointSlavesMap();
559 myData[pointi] = transforms.encode
563 transforms.nullTransformIndex()
571 allPointConnectivity.setSize(slavesMap.constructSize());
579 const labelList& pSlaves = slaves[pointi];
580 const labelList& pTransformSlaves = transformedSlaves[pointi];
582 if (pSlaves.size()+pTransformSlaves.size())
586 pConnectivity.setSize(1+pSlaves.size()+pTransformSlaves.size());
590 pConnectivity[connI++] = myData[pointi];
594 pConnectivity[connI++] = myData[pSlaves[i]];
597 forAll(pTransformSlaves, i)
600 label transformI = slavesMap.whichTransform
605 const labelPair&
n = myData[pTransformSlaves[i]];
606 label proci = transforms.processor(
n);
607 label index = transforms.index(
n);
608 pConnectivity[connI++] = transforms.encode
619 allPointConnectivity[pSlaves[i]] = pConnectivity;
621 forAll(pTransformSlaves, i)
623 allPointConnectivity[pTransformSlaves[i]] = pConnectivity;
634 if (pConnectivity.size() == 0)
636 pConnectivity.setSize(1, myData[pointi]);
641 slavesMap.reverseDistribute
644 allPointConnectivity,
654void Foam::globalMeshData::calcGlobalPointEdges
660 const edgeList& edges = coupledPatch().edges();
661 const labelListList& pointEdges = coupledPatch().pointEdges();
662 const globalIndex& globalEdgeNumbers = globalEdgeNumbering();
664 const labelListList& transformedSlaves = globalPointTransformedSlaves();
669 globalPointEdges.setSize(globalPointSlavesMap().constructSize());
670 globalPointPoints.setSize(globalPointSlavesMap().constructSize());
671 forAll(pointEdges, pointi)
673 const labelList& pEdges = pointEdges[pointi];
674 globalPointEdges[pointi] = globalEdgeNumbers.toGlobal(pEdges);
677 globalPPoints.setSize(pEdges.size());
680 label otherPointi = edges[pEdges[i]].otherVertex(pointi);
681 globalPPoints[i] = transforms.encode
685 transforms.nullTransformIndex()
695 globalPointSlavesMap().distribute
703 globalPointSlavesMap().distribute
713 const labelList& pSlaves = slaves[pointi];
714 const labelList& pTransformSlaves = transformedSlaves[pointi];
719 n += globalPointEdges[pSlaves[i]].size();
721 forAll(pTransformSlaves, i)
723 n += globalPointEdges[pTransformSlaves[i]].size();
728 labelList& globalPEdges = globalPointEdges[pointi];
729 label sz = globalPEdges.size();
730 globalPEdges.setSize(sz+
n);
733 const labelList& otherData = globalPointEdges[pSlaves[i]];
736 globalPEdges[sz++] = otherData[j];
739 forAll(pTransformSlaves, i)
742 globalPointEdges[pTransformSlaves[i]];
745 globalPEdges[sz++] = otherData[j];
752 globalPointEdges[pSlaves[i]] = globalPEdges;
754 forAll(pTransformSlaves, i)
756 globalPointEdges[pTransformSlaves[i]] = globalPEdges;
764 label sz = globalPPoints.size();
765 globalPPoints.setSize(sz +
n);
770 const labelPairList& otherData = globalPointPoints[pSlaves[i]];
773 globalPPoints[sz++] = otherData[j];
777 forAll(pTransformSlaves, i)
780 label transformI = globalPointSlavesMap().whichTransform
786 globalPointPoints[pTransformSlaves[i]];
791 label proci = transforms.processor(
n);
792 label index = transforms.index(
n);
793 globalPPoints[sz++] = transforms.encode
805 globalPointPoints[pSlaves[i]] = globalPPoints;
807 forAll(pTransformSlaves, i)
809 globalPointPoints[pTransformSlaves[i]] = globalPPoints;
814 globalPointSlavesMap().reverseDistribute
822 globalPointSlavesMap().reverseDistribute
835Foam::label Foam::globalMeshData::findTransform
839 const label localPoint
844 const label remoteProci = transforms.processor(remotePoint);
845 const label remoteIndex = transforms.index(remotePoint);
847 label remoteTransformI = -1;
848 label localTransformI = -1;
851 label proci = transforms.processor(info[i]);
852 label pointi = transforms.index(info[i]);
853 label transformI = transforms.transformIndex(info[i]);
857 localTransformI = transformI;
862 if (proci == remoteProci && pointi == remoteIndex)
864 remoteTransformI = transformI;
872 if (remoteTransformI == -1 || localTransformI == -1)
875 <<
"Problem. Cannot find " << remotePoint
876 <<
" or " << localPoint <<
" "
877 << coupledPatch().localPoints()[localPoint]
880 <<
"remoteTransformI:" << remoteTransformI <<
endl
881 <<
"localTransformI:" << localTransformI
885 return transforms.subtractTransformIndex
893void Foam::globalMeshData::calcGlobalEdgeSlaves()
const
897 Pout<<
"globalMeshData::calcGlobalEdgeSlaves() :"
898 <<
" calculating coupled master to slave edge addressing." <<
endl;
901 const edgeList& edges = coupledPatch().edges();
902 const globalIndex& globalEdgeNumbers = globalEdgeNumbering();
919 calcPointConnectivity(allPointConnectivity);
926 calcGlobalPointEdges(globalPointEdges, globalPointPoints);
943 const edge&
e = edges[edgeI];
944 const labelList& pEdges0 = globalPointEdges[
e[0]];
946 const labelList& pEdges1 = globalPointEdges[
e[1]];
958 transforms.nullTransformIndex()
968 pEdges0[i] == pEdges1[j]
969 && pEdges0[i] != globalEdgeNumbers.toGlobal(edgeI)
981 label transform0 = findTransform
983 allPointConnectivity[
e[0]],
987 label transform1 = findTransform
989 allPointConnectivity[
e[1]],
994 if (transform0 == transform1)
996 label proci = globalEdgeNumbers.whichProcID(pEdges0[i]);
1002 globalEdgeNumbers.toLocal(proci, pEdges0[i]),
1011 allEdgeConnectivity[edgeI].transfer(eEdges);
1014 allEdgeConnectivity[edgeI],
1023 globalEdgeSlavesPtr_.reset(
new labelListList(edges.size()));
1026 forAll(allEdgeConnectivity, edgeI)
1029 if (edgeInfo.size() >= 2)
1031 const labelPair& masterInfo = edgeInfo[0];
1037 transforms.processor(masterInfo)
1040 && (transforms.index(masterInfo) == edgeI)
1044 labelList& eEdges = globalEdgeSlaves[edgeI];
1045 eEdges.setSize(edgeInfo.size()-1);
1048 trafoEEdges.setSize(edgeInfo.size()-1);
1050 label nonTransformI = 0;
1051 label transformI = 0;
1053 for (label i = 1; i < edgeInfo.size(); i++)
1056 label proci = transforms.processor(info);
1057 label index = transforms.index(info);
1058 label
transform = transforms.transformIndex
1063 if (
transform == transforms.nullTransformIndex())
1065 eEdges[nonTransformI++] = globalEdgeNumbers.toGlobal
1073 trafoEEdges[transformI++] = info;
1077 eEdges.setSize(nonTransformI);
1078 trafoEEdges.setSize(transformI);
1088 globalEdgeSlavesMapPtr_.reset
1097 globalEdgeTransformedSlavesPtr_(),
1109 Pout<<
"globalMeshData::calcGlobalEdgeSlaves() :"
1110 <<
" coupled edges:" << edges.size()
1111 <<
" additional coupled edges:"
1112 << globalEdgeSlavesMapPtr_().constructSize() - edges.size()
1118void Foam::globalMeshData::calcGlobalEdgeOrientation()
const
1122 Pout<<
"globalMeshData::calcGlobalEdgeOrientation() :"
1123 <<
" calculating edge orientation w.r.t. master edge." <<
endl;
1136 masterPoint.setSize(map.constructSize());
1139 for (label pointi = 0; pointi < coupledPatch().nPoints(); pointi++)
1146 globalPointSlaves(),
1147 globalPointTransformedSlaves(),
1160 const labelListList& transformedSlaves = globalEdgeTransformedSlaves();
1166 for (label edgeI = 0; edgeI < coupledPatch().nEdges(); edgeI++)
1171 slaves[edgeI].size()
1172 + transformedSlaves[edgeI].size()
1179 const edge&
e = coupledPatch().edges()[edgeI];
1197 globalEdgeOrientationPtr_.reset
1199 new bitSet(coupledPatch().nEdges())
1201 bitSet& globalEdgeOrientation = globalEdgeOrientationPtr_();
1203 forAll(coupledPatch().edges(), edgeI)
1208 const edge&
e = coupledPatch().edges()[edgeI];
1218 masterEdgeVerts[edgeI]
1223 <<
"problem : my edge:" <<
e
1224 <<
" in master points:" << masterE
1225 <<
" v.s. masterEdgeVerts:" << masterEdgeVerts[edgeI]
1230 globalEdgeOrientation.set(edgeI, (stat == 1));
1235 globalEdgeOrientation.set(edgeI,
true);
1245 Pout<<
"globalMeshData::calcGlobalEdgeOrientation() :"
1246 <<
" finished calculating edge orientation."
1252void Foam::globalMeshData::calcPointBoundaryFaces
1258 const Map<label>& meshPointMap = coupledPatch().meshPointMap();
1272 const auto iter = meshPointMap.cfind(
f[fp]);
1275 nPointFaces[iter.val()]++;
1285 pointBoundaryFaces.setSize(coupledPatch().
nPoints());
1286 forAll(nPointFaces, pointi)
1288 pointBoundaryFaces[pointi].setSize(nPointFaces[pointi]);
1306 const auto iter = meshPointMap.cfind(
f[fp]);
1311 pp.start() + i - mesh_.nInternalFaces();
1312 pointBoundaryFaces[iter()][nPointFaces[iter()]++] =
1322void Foam::globalMeshData::calcGlobalPointBoundaryFaces()
const
1326 Pout<<
"globalMeshData::calcGlobalPointBoundaryFaces() :"
1327 <<
" calculating coupled point to boundary face addressing."
1338 calcPointBoundaryFaces(pointBoundaryFaces);
1342 globalBoundaryFaceNumberingPtr_.reset
1346 const auto& globalIndices = *globalBoundaryFaceNumberingPtr_;
1350 globalPointBoundaryFacesPtr_.reset
1354 auto& globalPointBoundaryFaces = *globalPointBoundaryFacesPtr_;
1356 forAll(pointBoundaryFaces, pointi)
1358 globalPointBoundaryFaces[pointi] = globalIndices.toGlobal
1361 pointBoundaryFaces[pointi]
1367 globalPointSlavesMap().distribute
1369 globalPointBoundaryFaces,
1378 globalPointTransformedSlaves();
1386 forAll(pointSlaves, pointi)
1388 const labelList& slaves = pointSlaves[pointi];
1389 const labelList& transformedSlaves = pointTransformSlaves[pointi];
1391 if (slaves.size() > 0)
1393 labelList& myBFaces = globalPointBoundaryFaces[pointi];
1394 label sz = myBFaces.size();
1400 n += globalPointBoundaryFaces[slaves[i]].size();
1403 myBFaces.setSize(sz+
n);
1408 globalPointBoundaryFaces[slaves[i]];
1413 for (
const label slave : slaveBFaces)
1417 myBFaces[
n++] = slave;
1421 myBFaces.setSize(
n);
1425 if (transformedSlaves.size() > 0)
1427 const labelList& untrafoFaces = globalPointBoundaryFaces[pointi];
1430 label sz = myBFaces.size();
1434 forAll(transformedSlaves, i)
1436 n += globalPointBoundaryFaces[transformedSlaves[i]].size();
1439 myBFaces.setSize(sz+
n);
1441 forAll(transformedSlaves, i)
1443 label transformI = globalPointSlavesMap().whichTransform
1445 transformedSlaves[i]
1449 globalPointBoundaryFaces[transformedSlaves[i]];
1451 for (
const label slave : slaveBFaces)
1454 if (!untrafoFaces.found(slave))
1456 label proci = globalIndices.whichProcID(slave);
1457 label facei = globalIndices.toLocal(proci, slave);
1459 myBFaces[
n++] = transforms.encode
1468 myBFaces.setSize(
n);
1472 if (slaves.size() + transformedSlaves.size() == 0)
1474 globalPointBoundaryFaces[pointi].clear();
1481 globalPointTransformedBoundaryFacesPtr_.reset
1486 globalPointBoundaryFacesMapPtr_.reset
1491 globalPointBoundaryFaces,
1495 globalPointTransformedBoundaryFacesPtr_(),
1500 globalPointBoundaryFaces.setSize(coupledPatch().
nPoints());
1501 globalPointTransformedBoundaryFacesPtr_().setSize(coupledPatch().
nPoints());
1508 Pout<<
"globalMeshData::calcGlobalPointBoundaryFaces() :"
1509 <<
" coupled points:" << coupledPatch().nPoints()
1510 <<
" local boundary faces:" << globalIndices.localSize()
1511 <<
" additional coupled faces:"
1512 << globalPointBoundaryFacesMapPtr_().constructSize()
1513 - globalIndices.localSize()
1519void Foam::globalMeshData::calcGlobalPointBoundaryCells()
const
1523 Pout<<
"globalMeshData::calcGlobalPointBoundaryCells() :"
1524 <<
" calculating coupled point to boundary cell addressing."
1540 forAll(coupledPatch().meshPoints(), pointi)
1542 label meshPointi = coupledPatch().meshPoints()[pointi];
1543 const labelList& pCells = mesh_.pointCells(meshPointi);
1545 labelList& bCells = pointBoundaryCells[pointi];
1546 bCells.setSize(pCells.size());
1550 const label celli = pCells[i];
1551 const auto fnd = meshCellMap.cfind(celli);
1559 meshCellMap.insert(celli, bCelli);
1560 cellMap.append(celli);
1568 boundaryCellsPtr_.reset(
new labelList(std::move(cellMap)));
1569 labelList& boundaryCells = boundaryCellsPtr_();
1579 globalBoundaryCellNumberingPtr_.reset
1583 const auto& globalIndices = *globalBoundaryCellNumberingPtr_;
1587 globalPointBoundaryCellsPtr_.reset
1591 auto& globalPointBoundaryCells = *globalPointBoundaryCellsPtr_;
1593 forAll(pointBoundaryCells, pointi)
1595 globalPointBoundaryCells[pointi] = globalIndices.toGlobal
1598 pointBoundaryCells[pointi]
1604 globalPointSlavesMap().distribute
1606 globalPointBoundaryCells,
1614 globalPointTransformedSlaves();
1620 forAll(pointSlaves, pointi)
1622 const labelList& slaves = pointSlaves[pointi];
1623 const labelList& transformedSlaves = pointTransformSlaves[pointi];
1625 if (slaves.size() > 0)
1627 labelList& myBCells = globalPointBoundaryCells[pointi];
1628 label sz = myBCells.size();
1634 n += globalPointBoundaryCells[slaves[i]].size();
1637 myBCells.setSize(sz+
n);
1642 globalPointBoundaryCells[slaves[i]];
1647 for (
const label slave : slaveBCells)
1651 myBCells[
n++] = slave;
1655 myBCells.setSize(
n);
1659 if (transformedSlaves.size() > 0)
1661 const labelList& untrafoCells = globalPointBoundaryCells[pointi];
1664 label sz = myBCells.size();
1668 forAll(transformedSlaves, i)
1670 n += globalPointBoundaryCells[transformedSlaves[i]].size();
1673 myBCells.setSize(sz+
n);
1675 forAll(transformedSlaves, i)
1677 label transformI = globalPointSlavesMap().whichTransform
1679 transformedSlaves[i]
1683 globalPointBoundaryCells[transformedSlaves[i]];
1685 for (
const label slave : slaveBCells)
1688 if (!untrafoCells.found(slave))
1690 label proci = globalIndices.whichProcID(slave);
1691 label celli = globalIndices.toLocal(proci, slave);
1692 myBCells[
n++] = transforms.encode
1701 myBCells.setSize(
n);
1704 if (slaves.size() + transformedSlaves.size() == 0)
1706 globalPointBoundaryCells[pointi].clear();
1713 globalPointTransformedBoundaryCellsPtr_.reset
1718 globalPointBoundaryCellsMapPtr_.reset
1723 globalPointBoundaryCells,
1727 globalPointTransformedBoundaryCellsPtr_(),
1732 globalPointBoundaryCells.setSize(coupledPatch().
nPoints());
1733 globalPointTransformedBoundaryCellsPtr_().setSize(coupledPatch().
nPoints());
1740 Pout<<
"globalMeshData::calcGlobalPointBoundaryCells() :"
1741 <<
" coupled points:" << coupledPatch().nPoints()
1742 <<
" local boundary cells:" << globalIndices.localSize()
1743 <<
" additional coupled cells:"
1744 << globalPointBoundaryCellsMapPtr_().constructSize()
1745 - globalIndices.localSize()
1751void Foam::globalMeshData::calcGlobalCoPointSlaves()
const
1755 Pout<<
"globalMeshData::calcGlobalCoPointSlaves() :"
1756 <<
" calculating coupled master to collocated"
1757 <<
" slave point addressing." <<
endl;
1764 globalPoints globalData(mesh_, coupledPatch(),
true,
false);
1766 globalCoPointSlavesPtr_.reset
1770 std::move(globalData.pointPoints())
1773 globalCoPointSlavesMapPtr_.reset
1777 std::move(globalData.map())
1785 Pout<<
"globalMeshData::calcGlobalCoPointSlaves() :"
1786 <<
" finished calculating coupled master to collocated"
1787 <<
" slave point addressing." <<
endl;
1799 processorTopology::
New<processorPolyPatch>
1801 mesh.boundaryMesh(),
1822 nGlobalPoints_ = -1;
1823 sharedPointLabelsPtr_.clear();
1824 sharedPointAddrPtr_.clear();
1825 sharedPointGlobalLabelsPtr_.clear();
1829 sharedEdgeLabelsPtr_.clear();
1830 sharedEdgeAddrPtr_.clear();
1833 coupledPatchPtr_.clear();
1834 coupledPatchMeshEdgesPtr_.clear();
1835 coupledPatchMeshEdgeMapPtr_.clear();
1836 globalTransformsPtr_.clear();
1839 globalPointNumberingPtr_.clear();
1840 globalPointSlavesPtr_.clear();
1841 globalPointTransformedSlavesPtr_.clear();
1842 globalPointSlavesMapPtr_.clear();
1845 globalEdgeNumberingPtr_.clear();
1846 globalEdgeSlavesPtr_.clear();
1847 globalEdgeTransformedSlavesPtr_.clear();
1848 globalEdgeOrientationPtr_.clear();
1849 globalEdgeSlavesMapPtr_.clear();
1852 globalBoundaryFaceNumberingPtr_.clear();
1853 globalPointBoundaryFacesPtr_.clear();
1854 globalPointTransformedBoundaryFacesPtr_.clear();
1855 globalPointBoundaryFacesMapPtr_.clear();
1858 boundaryCellsPtr_.clear();
1859 globalBoundaryCellNumberingPtr_.clear();
1860 globalPointBoundaryCellsPtr_.clear();
1861 globalPointTransformedBoundaryCellsPtr_.clear();
1862 globalPointBoundaryCellsMapPtr_.clear();
1865 globalCoPointSlavesPtr_.clear();
1866 globalCoPointSlavesMapPtr_.clear();
1874 if (!sharedPointGlobalLabelsPtr_)
1876 sharedPointGlobalLabelsPtr_.reset
1878 new labelList(sharedPointLabels().size())
1880 labelList& sharedPointGlobalLabels = sharedPointGlobalLabelsPtr_();
1884 "pointProcAddressing",
1894 Pout<<
"globalMeshData::sharedPointGlobalLabels : "
1895 <<
"Reading pointProcAddressing" <<
endl;
1907 sharedPointGlobalLabels[i] = pointProcAddressing[pointi];
1912 Pout<<
"globalMeshData::sharedPointGlobalLabels :"
1913 <<
" Setting pointProcAddressing to -1" <<
endl;
1915 sharedPointGlobalLabels = -1;
1919 return *sharedPointGlobalLabelsPtr_;
1932 const labelList& pointAddr = sharedPointAddr();
1941 label sharedPointi = pointAddr[i];
1943 sharedPoints[sharedPointi] = mesh_.points()[
pointLabels[i]];
1953 fromProc >> nbrSharedPointAddr >> nbrSharedPoints;
1955 forAll(nbrSharedPointAddr, i)
1957 label sharedPointi = nbrSharedPointAddr[i];
1959 sharedPoints[sharedPointi] = nbrSharedPoints[i];
1995 pointField sharedPoints(mesh_.points(), sharedPointLabels());
2001 scalar tolDim = matchTol_ * mesh_.bounds().mag();
2021 if (nGlobalPoints_ == -1)
2025 return nGlobalPoints_;
2031 if (!sharedPointLabelsPtr_)
2035 return *sharedPointLabelsPtr_;
2041 if (!sharedPointAddrPtr_)
2045 return *sharedPointAddrPtr_;
2051 if (nGlobalEdges_ == -1)
2055 return nGlobalEdges_;
2061 if (!sharedEdgeLabelsPtr_)
2065 return *sharedEdgeLabelsPtr_;
2071 if (!sharedEdgeAddrPtr_)
2075 return *sharedEdgeAddrPtr_;
2081 if (!coupledPatchPtr_)
2083 const polyBoundaryMesh&
bMesh = mesh_.boundaryMesh();
2089 const polyPatch&
pp =
bMesh[patchi];
2093 nCoupled +=
pp.size();
2105 label facei =
pp.start();
2109 coupledFaces[nCoupled++] = facei++;
2114 coupledPatchPtr_.reset
2129 Pout<<
"globalMeshData::coupledPatch() :"
2130 <<
" constructed coupled faces patch:"
2131 <<
" faces:" << coupledPatchPtr_().size()
2132 <<
" points:" << coupledPatchPtr_().nPoints()
2136 return *coupledPatchPtr_;
2142 if (!coupledPatchMeshEdgesPtr_)
2144 coupledPatchMeshEdgesPtr_.reset
2148 coupledPatch().meshEdges
2156 return *coupledPatchMeshEdgesPtr_;
2163 if (!coupledPatchMeshEdgeMapPtr_)
2165 const labelList& me = coupledPatchMeshEdges();
2167 coupledPatchMeshEdgeMapPtr_.reset
2172 return *coupledPatchMeshEdgeMapPtr_;
2178 if (!globalPointNumberingPtr_)
2183 globalPointNumberingPtr_.reset
2185 new globalIndex(coupledPatch().
nPoints())
2191 return *globalPointNumberingPtr_;
2198 if (!globalTransformsPtr_)
2203 globalTransformsPtr_.reset(
new globalIndexAndTransform(mesh_));
2208 return *globalTransformsPtr_;
2214 if (!globalPointSlavesPtr_)
2216 calcGlobalPointSlaves();
2218 return *globalPointSlavesPtr_;
2225 if (!globalPointTransformedSlavesPtr_)
2227 calcGlobalPointSlaves();
2229 return *globalPointTransformedSlavesPtr_;
2235 if (!globalPointSlavesMapPtr_)
2237 calcGlobalPointSlaves();
2239 return *globalPointSlavesMapPtr_;
2245 if (!globalEdgeNumberingPtr_)
2250 globalEdgeNumberingPtr_.reset
2252 new globalIndex(coupledPatch().nEdges())
2258 return *globalEdgeNumberingPtr_;
2264 if (!globalEdgeSlavesPtr_)
2266 calcGlobalEdgeSlaves();
2268 return *globalEdgeSlavesPtr_;
2275 if (!globalEdgeTransformedSlavesPtr_)
2277 calcGlobalEdgeSlaves();
2279 return *globalEdgeTransformedSlavesPtr_;
2285 if (!globalEdgeOrientationPtr_)
2287 calcGlobalEdgeOrientation();
2289 return *globalEdgeOrientationPtr_;
2295 if (!globalEdgeSlavesMapPtr_)
2297 calcGlobalEdgeSlaves();
2299 return *globalEdgeSlavesMapPtr_;
2306 if (!globalBoundaryFaceNumberingPtr_)
2308 calcGlobalPointBoundaryFaces();
2310 return *globalBoundaryFaceNumberingPtr_;
2317 if (!globalPointBoundaryFacesPtr_)
2319 calcGlobalPointBoundaryFaces();
2321 return *globalPointBoundaryFacesPtr_;
2328 if (!globalPointTransformedBoundaryFacesPtr_)
2330 calcGlobalPointBoundaryFaces();
2332 return *globalPointTransformedBoundaryFacesPtr_;
2339 if (!globalPointBoundaryFacesMapPtr_)
2341 calcGlobalPointBoundaryFaces();
2343 return *globalPointBoundaryFacesMapPtr_;
2349 if (!boundaryCellsPtr_)
2351 calcGlobalPointBoundaryCells();
2353 return *boundaryCellsPtr_;
2360 if (!globalBoundaryCellNumberingPtr_)
2362 calcGlobalPointBoundaryCells();
2364 return *globalBoundaryCellNumberingPtr_;
2371 if (!globalPointBoundaryCellsPtr_)
2373 calcGlobalPointBoundaryCells();
2375 return *globalPointBoundaryCellsPtr_;
2382 if (!globalPointTransformedBoundaryCellsPtr_)
2384 calcGlobalPointBoundaryCells();
2386 return *globalPointTransformedBoundaryCellsPtr_;
2393 if (!globalPointBoundaryCellsMapPtr_)
2395 calcGlobalPointBoundaryCells();
2397 return *globalPointBoundaryCellsMapPtr_;
2403 if (!globalCoPointSlavesPtr_)
2405 calcGlobalCoPointSlaves();
2407 return *globalCoPointSlavesPtr_;
2413 if (!globalCoPointSlavesMapPtr_)
2415 calcGlobalCoPointSlaves();
2417 return *globalCoPointSlavesMapPtr_;
2428 const globalIndex& globalCoupledPoints = globalPointNumbering();
2431 const mapDistribute& pointSlavesMap = globalCoPointSlavesMap();
2441 labelList masterGlobalPoint(cpp.nPoints(), -1);
2442 forAll(masterGlobalPoint, pointi)
2444 const labelList& slavePoints = pointSlaves[pointi];
2445 if (slavePoints.size() > 0)
2447 masterGlobalPoint[pointi] = globalCoupledPoints.toGlobal(pointi);
2464 bitSet isMaster(mesh_.nPoints(),
true);
2465 forAll(pointSlaves, pointi)
2467 if (masterGlobalPoint[pointi] == -1)
2474 masterGlobalPoint[pointi]
2475 == globalCoupledPoints.toGlobal(pointi)
2484 isMaster.unset(cpp.meshPoints()[pointi]);
2488 label myUniquePoints = mesh_.nPoints() - cpp.nPoints() + nMaster;
2502 pointToGlobal.setSize(mesh_.nPoints());
2504 uniquePoints.setSize(myUniquePoints);
2507 forAll(isMaster, meshPointi)
2509 if (isMaster[meshPointi])
2511 pointToGlobal[meshPointi] = globalPointsPtr().toGlobal(nMaster);
2512 uniquePoints[nMaster] = meshPointi;
2520 labelList masterToGlobal(pointSlavesMap.constructSize(), -1);
2522 forAll(pointSlaves, pointi)
2524 const labelList& slaves = pointSlaves[pointi];
2526 if (slaves.size() > 0)
2529 label meshPointi = cpp.meshPoints()[pointi];
2530 masterToGlobal[pointi] = pointToGlobal[meshPointi];
2533 masterToGlobal[slaves[i]] = masterToGlobal[pointi];
2539 pointSlavesMap.reverseDistribute(cpp.nPoints(), masterToGlobal);
2542 forAll(pointSlaves, pointi)
2544 label meshPointi = cpp.meshPoints()[pointi];
2546 if (!isMaster[meshPointi])
2548 pointToGlobal[meshPointi] = masterToGlobal[pointi];
2556 return globalPointsPtr;
2570 const mapDistribute& pointSlavesMap = globalCoPointSlavesMap();
2598 forAll(meshPoints, patchPointi)
2600 label meshPointi = meshPoints[patchPointi];
2606 patchToCoupled[patchPointi] = iter();
2607 coupledToGlobalPatch[iter()] = globalPPoints.toGlobal(patchPointi);
2625 pointSlavesMap.
distribute(coupledToGlobalPatch);
2626 forAll(pointSlaves, coupledPointi)
2628 const labelList& slaves = pointSlaves[coupledPointi];
2630 if (slaves.size() > 0)
2634 if (coupledToGlobalPatch[coupledPointi] != -1)
2637 masterI = coupledToGlobalPatch[coupledPointi];
2644 label slavePp = coupledToGlobalPatch[slaves[i]];
2645 if (slavePp != -1 && slavePp < masterI)
2655 coupledToGlobalPatch[coupledPointi] = masterI;
2658 coupledToGlobalPatch[slaves[i]] = masterI;
2673 forAll(meshPoints, patchPointi)
2675 if (patchToCoupled[patchPointi] == -1)
2681 label coupledPointi = patchToCoupled[patchPointi];
2684 globalPPoints.toGlobal(patchPointi)
2685 == coupledToGlobalPatch[coupledPointi]
2708 uniqueMeshPoints.
setSize(nMasters);
2715 forAll(meshPoints, patchPointi)
2717 if (patchToCoupled[patchPointi] == -1)
2719 uniqueMeshPoints[nMasters++] = meshPoints[patchPointi];
2723 label coupledPointi = patchToCoupled[patchPointi];
2726 globalPPoints.toGlobal(patchPointi)
2727 == coupledToGlobalPatch[coupledPointi]
2730 globalMaster[coupledPointi] =
2731 globalPointsPtr().toGlobal(nMasters);
2732 uniqueMeshPoints[nMasters++] = meshPoints[patchPointi];
2752 forAll(meshPoints, patchPointi)
2754 if (patchToCoupled[patchPointi] == -1)
2756 pointToGlobal[patchPointi] = globalPointsPtr().toGlobal(nMasters++);
2760 label coupledPointi = patchToCoupled[patchPointi];
2761 pointToGlobal[patchPointi] = globalMaster[coupledPointi];
2765 globalPPoints.toGlobal(patchPointi)
2766 == coupledToGlobalPatch[coupledPointi]
2777 return globalPointsPtr;
2798 scalar tolDim = matchTol_ * mesh_.bounds().mag();
2802 Pout<<
"globalMeshData : merge dist:" << tolDim <<
endl;
2806 const label comm = mesh_.comm();
2817 label* tup = allSizes.begin(3*myProci);
2818 tup[0] = mesh_.nPoints();
2819 tup[1] = mesh_.nFaces();
2820 tup[2] = mesh_.nCells();
2829 for (label proci = 0, idx = 0; proci < numProc; ++proci, idx += 3)
2831 counts[proci] = allSizes[idx];
2833 globalMeshPointAddr_.reset(counts);
2835 for (label proci = 0, idx = 1; proci < numProc; ++proci, idx += 3)
2837 counts[proci] = allSizes[idx];
2839 globalMeshFaceAddr_.reset(counts);
2841 for (label proci = 0, idx = 2; proci < numProc; ++proci, idx += 3)
2843 counts[proci] = allSizes[idx];
2845 globalMeshCellAddr_.reset(counts);
2859 Info<<
"globalMeshData : Total points/faces/cells : ("
2860 << nTotalPoints() <<
' '
2861 << nTotalFaces() <<
' '
2862 << nTotalCells() <<
')' <<
endl;
Various functions to operate on Lists.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
@ MUST_READ
Reading required.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info. A void type suppresses trait and t...
Input inter-processor communications stream.
static void recv(Type &value, const int fromProcNo, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Receive and deserialize a value. Uses operator>> for de-serialization.
A List with indirect addressing.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void setSize(label n)
Alias for resize().
A HashTable to objects of type <T> with a label key.
Output inter-processor communications stream.
static int compare(const Pair< label > &a, const Pair< label > &b)
label nPoints() const
Number of points supporting patch faces.
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
static void combineReduce(T &value, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine value from different processors.
A non-owning sub-view of a List (allocated or unallocated storage).
iterator begin() noexcept
Return an iterator to begin traversing the UList.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void size(const label n)
Older name for setAddressableSize.
label find(const T &val) const
Find index of the first occurrence of the value.
bool send()
Send buffer contents now and not in destructor [advanced usage]. Returns true on success.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
@ scheduled
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static int & msgType() noexcept
Message tag of standard messages.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
static void mpiAllGather(Type *allData, int count, const int communicator=UPstream::worldComm)
Gather/scatter identically-sized data.
static label commWarn(const label communicator) noexcept
Alter communicator debugging setting. Warns for use of any communicator differing from specified....
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
@ broadcast
broadcast [MPI]
static bool & parRun() noexcept
Test if this a parallel run.
label size() const noexcept
The number of entries in the list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A face is a list of labels corresponding to mesh vertices.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
label toGlobal(const label proci, const label i) const
From local to global on proci.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const mapDistribute & globalCoPointSlavesMap() const
void movePoints(const pointField &newPoints)
Update for moving points.
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points list.
const bitSet & globalEdgeOrientation() const
Is my edge same orientation as master edge.
const labelListList & globalPointTransformedBoundaryCells() const
globalMeshData(const globalMeshData &)=delete
No copy construct.
const labelListList & globalEdgeTransformedSlaves() const
const Map< label > & coupledPatchMeshEdgeMap() const
Return map from mesh edges to coupledPatch edges.
const labelList & sharedEdgeAddr() const
Return addressing into the complete globally shared edge list.
pointField geometricSharedPoints() const
Like sharedPoints but keeps cyclic points separate. (does geometric merging; uses matchTol_*bb as mer...
static const Foam::scalar matchTol_
Geometric tolerance (fraction of bounding box).
label nGlobalPoints() const
Return number of globally shared points.
const mapDistribute & globalPointBoundaryCellsMap() const
const mapDistribute & globalPointBoundaryFacesMap() const
const mapDistribute & globalPointSlavesMap() const
const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
const labelListList & globalPointTransformedBoundaryFaces() const
const labelList & boundaryCells() const
From boundary cell to mesh cell.
const labelListList & globalPointBoundaryFaces() const
const mapDistribute & globalEdgeSlavesMap() const
const globalIndex & globalBoundaryFaceNumbering() const
Numbering of boundary faces is face-mesh.nInternalFaces().
static void syncData(List< Type > &elems, const labelListList &slaves, const labelListList &transformedSlaves, const mapDistribute &slavesMap, const globalIndexAndTransform &, const CombineOp &cop, const TransformOp &top)
Helper: synchronise data with transforms.
label nGlobalEdges() const
Return number of globally shared edges.
const labelList & coupledPatchMeshEdges() const
Return map from coupledPatch edges to mesh edges.
~globalMeshData()
Destructor.
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
const labelList & sharedPointGlobalLabels() const
Return shared point global labels. Tries to read 'pointProcAddressing' and returns list or -1 if none...
const labelListList & globalCoPointSlaves() const
pointField sharedPoints() const
Collect coordinates of shared points on all processors. (does parallel communication!...
label nTotalFaces() const noexcept
Total global number of mesh faces. Not compensated for duplicate faces!
const globalIndex & globalBoundaryCellNumbering() const
Numbering of boundary cells is according to boundaryCells().
const labelListList & globalPointSlaves() const
const globalIndex & globalEdgeNumbering() const
const polyMesh & mesh() const noexcept
Return the mesh reference.
const globalIndexAndTransform & globalTransforms() const
Global transforms numbering.
const labelList & sharedEdgeLabels() const
Return indices of local edges that are globally shared.
label nTotalPoints() const noexcept
Total global number of mesh points. Not compensated for duplicate points!
const labelListList & globalPointTransformedSlaves() const
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
label nTotalCells() const noexcept
Total global number of mesh cells.
void updateMesh()
Change global mesh data given a topological change. Does a.
const labelListList & globalPointBoundaryCells() const
void clearOut()
Remove all demand driven data.
const labelListList & globalEdgeSlaves() const
const globalIndex & globalPointNumbering() const
Numbering of coupled points is according to coupledPatch.
Calculates points shared by more than two processor patches or cyclic patches.
label constructSize() const noexcept
Constructed data size.
Class containing processor-to-processor mapping information.
void reverseDistribute(const label constructSize, List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute List data using default commsType, default flip/negate operator.
void operator()(labelPair &x, const labelPair &y) const
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
A patch is a list of labels that address the faces in the global face list.
Neighbour processor patch.
Determines/represents processor-processor connection. After instantiation contains the processor-proc...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Geometric merging of points. See below.
Namespace for handling debugging switches.
List< edge > edgeList
List of edge.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Pair< label > labelPair
A pair of labels.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
List< labelPair > labelPairList
List of labelPair.
List< labelList > labelListList
List of labelList.
Map< label > invertToMap(const labelUList &values)
Create inverse mapping, which is a lookup table into the given list.
List< label > labelList
A List of labels.
UIndirectList< label > labelUIndList
UIndirectList of labels.
IOList< label > labelIOList
IO for a List of label.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
void sort(UList< T > &list)
Sort the list.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
label inplaceMergePoints(PointList &points, const scalar mergeTol, const bool verbose, labelList &pointToUnique)
Inplace merge points, preserving the original point order. All points closer/equal mergeTol are to be...
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points).
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
Define the processor-processor connection table by walking a list of patches and detecting the proces...
labelList pointLabels(nPoints, -1)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
List helper to append y elements onto the end of x.
Dispatch tag: Construct with a single (local size) entry, no communication.
void operator()(T &x, const T &y) const