63 void Foam::globalMeshData::initProcAddr()
66 processorPatchIndices_ = -1;
69 processorPatchNeighbours_ = -1;
75 label nNeighbours = 0;
79 if (isA<processorPolyPatch>(mesh_.
boundaryMesh()[patchi]))
81 processorPatches_[nNeighbours] = patchi;
82 processorPatchIndices_[patchi] = nNeighbours++;
85 processorPatches_.
resize(nNeighbours);
98 for (
const label patchi : processorPatches_)
100 UOPstream toNeighbour
102 refCast<const processorPolyPatch>
109 toNeighbour << processorPatchIndices_[patchi];
112 pBufs.finishedSends();
114 for (
const label patchi : processorPatches_)
116 UIPstream fromNeighbour
118 refCast<const processorPolyPatch>
125 fromNeighbour >> processorPatchNeighbours_[patchi];
131 void Foam::globalMeshData::calcSharedPoints()
const 136 || sharedPointLabelsPtr_
137 || sharedPointAddrPtr_
146 const globalPoints parallelPoints(mesh_,
false,
true);
150 forAll(parallelPoints.pointPoints(), i)
152 const labelList& pPoints = parallelPoints.pointPoints()[i];
154 parallelPoints.transformedPointPoints()[i];
156 if (pPoints.size()+transPPoints.size() > 0)
163 const globalIndex masterNumbering(nMaster);
165 nGlobalPoints_ = masterNumbering.totalSize();
172 labelList master(parallelPoints.map().constructSize(), -1);
173 forAll(parallelPoints.pointPoints(), i)
175 const labelList& pPoints = parallelPoints.pointPoints()[i];
177 parallelPoints.transformedPointPoints()[i];
179 if (pPoints.size()+transPPoints.size() > 0)
181 master[i] = masterNumbering.toGlobal(nMaster);
184 master[pPoints[j]] = master[i];
188 master[transPPoints[j]] = master[i];
206 parallelPoints.map().reverseDistribute
208 parallelPoints.map().constructSize(),
215 forAll(parallelPoints.pointPoints(), i)
223 sharedPointLabelsPtr_.reset(
new labelList(nMaster));
224 labelList& sharedPointLabels = sharedPointLabelsPtr_();
225 sharedPointAddrPtr_.reset(
new labelList(nMaster));
226 labelList& sharedPointAddr = sharedPointAddrPtr_();
229 forAll(parallelPoints.pointPoints(), i)
234 sharedPointLabels[nMaster] = i;
235 sharedPointAddr[nMaster] = master[i];
242 Pout<<
"globalMeshData : nGlobalPoints_:" << nGlobalPoints_ <<
nl 243 <<
"globalMeshData : sharedPointLabels_:" 244 << sharedPointLabelsPtr_().size() <<
nl 245 <<
"globalMeshData : sharedPointAddr_:" 246 << sharedPointAddrPtr_().size() <<
endl;
251 void Foam::globalMeshData::countSharedEdges
253 const EdgeMap<labelList>& procSharedEdges,
254 EdgeMap<label>& globalShared,
261 const edge&
e = iter.key();
263 auto globalFnd = globalShared.find(
e);
265 if (globalFnd.good())
267 if (globalFnd() == -1)
271 globalFnd() = sharedEdgeI++;
277 if (iter().size() == 1)
280 globalShared.insert(
e, -1);
286 globalShared.insert(
e, sharedEdgeI++);
293 void Foam::globalMeshData::calcSharedEdges()
const 303 || sharedEdgeLabelsPtr_
304 || sharedEdgeAddrPtr_
312 const labelList& sharedPtAddr = sharedPointAddr();
313 const labelList& sharedPtLabels = sharedPointLabels();
317 Map<label> meshToShared(2*sharedPtLabels.size());
320 meshToShared.insert(sharedPtLabels[i], i);
326 EdgeMap<labelList> localShared(2*sharedPtAddr.size());
328 const edgeList& edges = mesh_.edges();
332 const edge&
e = edges[edgeI];
334 const auto e0Fnd = meshToShared.cfind(
e[0]);
338 const auto e1Fnd = meshToShared.cfind(
e[1]);
348 sharedPtAddr[e0Fnd()],
349 sharedPtAddr[e1Fnd()]
352 auto iter = localShared.find(sharedEdge);
357 localShared.insert(sharedEdge,
labelList(1, edgeI));
364 const label sz = edgeLabels.size();
365 edgeLabels.setSize(sz+1);
366 edgeLabels[sz] = edgeI;
382 EdgeMap<label> globalShared(nGlobalPoints());
386 label sharedEdgeI = 0;
391 Pout<<
"globalMeshData::calcSharedEdges : Merging in from proc0 : " 392 << localShared.size() <<
endl;
394 countSharedEdges(localShared, globalShared, sharedEdgeI);
403 EdgeMap<labelList> procSharedEdges(fromProc);
407 Pout<<
"globalMeshData::calcSharedEdges : " 408 <<
"Merging in from proc" 409 << proci <<
" : " << procSharedEdges.size()
412 countSharedEdges(procSharedEdges, globalShared, sharedEdgeI);
420 EdgeMap<label> oldSharedEdges(globalShared);
422 globalShared.clear();
428 globalShared.insert(iter.key(), iter());
433 Pout<<
"globalMeshData::calcSharedEdges : Filtered " 434 << oldSharedEdges.size()
435 <<
" down to " << globalShared.size() <<
endl;
449 toMaster << localShared;
460 nGlobalEdges_ = globalShared.size();
462 DynamicList<label> dynSharedEdgeLabels(globalShared.size());
463 DynamicList<label> dynSharedEdgeAddr(globalShared.size());
467 const edge&
e = iter.key();
469 const auto edgeFnd = globalShared.cfind(
e);
477 for (
const label edgei : edgeLabels)
480 dynSharedEdgeLabels.append(edgei);
483 dynSharedEdgeAddr.append(edgeFnd());
489 sharedEdgeLabelsPtr_.reset(
new labelList());
490 labelList& sharedEdgeLabels = sharedEdgeLabelsPtr_();
491 sharedEdgeLabels.transfer(dynSharedEdgeLabels);
493 sharedEdgeAddrPtr_.reset(
new labelList());
494 labelList& sharedEdgeAddr = sharedEdgeAddrPtr_();
495 sharedEdgeAddr.transfer(dynSharedEdgeAddr);
499 Pout<<
"globalMeshData : nGlobalEdges_:" << nGlobalEdges_ <<
nl 500 <<
"globalMeshData : sharedEdgeLabels:" << sharedEdgeLabels.size()
502 <<
"globalMeshData : sharedEdgeAddr:" << sharedEdgeAddr.size()
508 void Foam::globalMeshData::calcGlobalPointSlaves()
const 512 Pout<<
"globalMeshData::calcGlobalPointSlaves() :" 513 <<
" calculating coupled master to slave point addressing." 518 globalPoints globalData(mesh_, coupledPatch(),
true,
true);
520 globalPointSlavesPtr_.reset
524 std::move(globalData.pointPoints())
527 globalPointTransformedSlavesPtr_.reset
531 std::move(globalData.transformedPointPoints())
535 globalPointSlavesMapPtr_.reset
539 std::move(globalData.map())
545 void Foam::globalMeshData::calcPointConnectivity
547 List<labelPairList>& allPointConnectivity
550 const globalIndexAndTransform& transforms = globalTransforms();
552 const labelListList& transformedSlaves = globalPointTransformedSlaves();
556 labelPairList myData(globalPointSlavesMap().constructSize());
559 myData[pointi] = transforms.encode
563 transforms.nullTransformIndex()
567 globalPointSlavesMap().distribute(myData);
571 allPointConnectivity.setSize(globalPointSlavesMap().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 = globalPointSlavesMap().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 globalPointSlavesMap().reverseDistribute
649 void Foam::globalMeshData::calcGlobalPointEdges
652 List<labelPairList>& globalPointPoints
655 const edgeList& edges = coupledPatch().edges();
656 const labelListList& pointEdges = coupledPatch().pointEdges();
657 const globalIndex& globalEdgeNumbers = globalEdgeNumbering();
659 const labelListList& transformedSlaves = globalPointTransformedSlaves();
660 const globalIndexAndTransform& transforms = globalTransforms();
664 globalPointEdges.setSize(globalPointSlavesMap().constructSize());
665 globalPointPoints.setSize(globalPointSlavesMap().constructSize());
666 forAll(pointEdges, pointi)
668 const labelList& pEdges = pointEdges[pointi];
669 globalPointEdges[pointi] = globalEdgeNumbers.toGlobal(pEdges);
672 globalPPoints.setSize(pEdges.size());
675 label otherPointi = edges[pEdges[i]].otherVertex(pointi);
676 globalPPoints[i] = transforms.encode
680 transforms.nullTransformIndex()
686 globalPointSlavesMap().distribute(globalPointEdges);
687 globalPointSlavesMap().distribute(globalPointPoints);
691 const labelList& pSlaves = slaves[pointi];
692 const labelList& pTransformSlaves = transformedSlaves[pointi];
697 n += globalPointEdges[pSlaves[i]].size();
699 forAll(pTransformSlaves, i)
701 n += globalPointEdges[pTransformSlaves[i]].size();
706 labelList& globalPEdges = globalPointEdges[pointi];
707 label sz = globalPEdges.
size();
708 globalPEdges.setSize(sz+
n);
711 const labelList& otherData = globalPointEdges[pSlaves[i]];
714 globalPEdges[sz++] = otherData[j];
717 forAll(pTransformSlaves, i)
720 globalPointEdges[pTransformSlaves[i]];
723 globalPEdges[sz++] = otherData[j];
730 globalPointEdges[pSlaves[i]] = globalPEdges;
732 forAll(pTransformSlaves, i)
734 globalPointEdges[pTransformSlaves[i]] = globalPEdges;
742 label sz = globalPPoints.size();
743 globalPPoints.setSize(sz +
n);
748 const labelPairList& otherData = globalPointPoints[pSlaves[i]];
751 globalPPoints[sz++] = otherData[j];
755 forAll(pTransformSlaves, i)
758 label transformI = globalPointSlavesMap().whichTransform
764 globalPointPoints[pTransformSlaves[i]];
769 label proci = transforms.processor(
n);
770 label index = transforms.index(
n);
771 globalPPoints[sz++] = transforms.encode
783 globalPointPoints[pSlaves[i]] = globalPPoints;
785 forAll(pTransformSlaves, i)
787 globalPointPoints[pTransformSlaves[i]] = globalPPoints;
792 globalPointSlavesMap().reverseDistribute
798 globalPointSlavesMap().reverseDistribute
806 Foam::label Foam::globalMeshData::findTransform
810 const label localPoint
813 const globalIndexAndTransform& transforms = globalTransforms();
815 const label remoteProci = transforms.processor(remotePoint);
816 const label remoteIndex = transforms.index(remotePoint);
818 label remoteTransformI = -1;
819 label localTransformI = -1;
822 label proci = transforms.processor(info[i]);
823 label pointi = transforms.index(info[i]);
824 label transformI = transforms.transformIndex(info[i]);
828 localTransformI = transformI;
833 if (proci == remoteProci && pointi == remoteIndex)
835 remoteTransformI = transformI;
843 if (remoteTransformI == -1 || localTransformI == -1)
846 <<
"Problem. Cannot find " << remotePoint
847 <<
" or " << localPoint <<
" " 848 << coupledPatch().localPoints()[localPoint]
851 <<
"remoteTransformI:" << remoteTransformI <<
endl 852 <<
"localTransformI:" << localTransformI
856 return transforms.subtractTransformIndex
864 void Foam::globalMeshData::calcGlobalEdgeSlaves()
const 868 Pout<<
"globalMeshData::calcGlobalEdgeSlaves() :" 869 <<
" calculating coupled master to slave edge addressing." <<
endl;
872 const edgeList& edges = coupledPatch().edges();
873 const globalIndex& globalEdgeNumbers = globalEdgeNumbering();
874 const globalIndexAndTransform& transforms = globalTransforms();
887 List<labelPairList> allPointConnectivity;
888 calcPointConnectivity(allPointConnectivity);
894 List<labelPairList> globalPointPoints;
895 calcGlobalPointEdges(globalPointEdges, globalPointPoints);
908 List<labelPairList> allEdgeConnectivity(edges.size());
912 const edge&
e = edges[edgeI];
913 const labelList& pEdges0 = globalPointEdges[
e[0]];
915 const labelList& pEdges1 = globalPointEdges[
e[1]];
919 DynamicList<labelPair> eEdges(2);
927 transforms.nullTransformIndex()
937 pEdges0[i] == pEdges1[j]
938 && pEdges0[i] != globalEdgeNumbers.toGlobal(edgeI)
950 label transform0 = findTransform
952 allPointConnectivity[
e[0]],
956 label transform1 = findTransform
958 allPointConnectivity[
e[1]],
963 if (transform0 == transform1)
965 label proci = globalEdgeNumbers.whichProcID(pEdges0[i]);
971 globalEdgeNumbers.toLocal(proci, pEdges0[i]),
980 allEdgeConnectivity[edgeI].transfer(eEdges);
983 allEdgeConnectivity[edgeI],
994 List<labelPairList> transformedEdges(edges.size());
995 forAll(allEdgeConnectivity, edgeI)
998 if (edgeInfo.size() >= 2)
1000 const labelPair& masterInfo = edgeInfo[0];
1006 transforms.processor(masterInfo)
1009 && (transforms.index(masterInfo) == edgeI)
1013 labelList& eEdges = globalEdgeSlaves[edgeI];
1014 eEdges.
setSize(edgeInfo.size()-1);
1017 trafoEEdges.setSize(edgeInfo.size()-1);
1019 label nonTransformI = 0;
1020 label transformI = 0;
1022 for (label i = 1; i < edgeInfo.size(); i++)
1025 label proci = transforms.processor(info);
1026 label index = transforms.index(info);
1027 label
transform = transforms.transformIndex
1032 if (
transform == transforms.nullTransformIndex())
1034 eEdges[nonTransformI++] = globalEdgeNumbers.toGlobal
1042 trafoEEdges[transformI++] = info;
1046 eEdges.setSize(nonTransformI);
1047 trafoEEdges.setSize(transformI);
1057 globalEdgeSlavesMapPtr_.reset
1066 globalEdgeTransformedSlavesPtr_(),
1075 Pout<<
"globalMeshData::calcGlobalEdgeSlaves() :" 1076 <<
" coupled edges:" << edges.size()
1077 <<
" additional coupled edges:" 1078 << globalEdgeSlavesMapPtr_().constructSize() - edges.size()
1084 void Foam::globalMeshData::calcGlobalEdgeOrientation()
const 1088 Pout<<
"globalMeshData::calcGlobalEdgeOrientation() :" 1089 <<
" calculating edge orientation w.r.t. master edge." <<
endl;
1092 const globalIndex& globalPoints = globalPointNumbering();
1097 const mapDistribute& map = globalPointSlavesMap();
1099 masterPoint.setSize(map.constructSize());
1102 for (label pointi = 0; pointi < coupledPatch().nPoints(); pointi++)
1104 masterPoint[pointi] = globalPoints.toGlobal(pointi);
1109 globalPointSlaves(),
1110 globalPointTransformedSlaves(),
1121 const mapDistribute& map = globalEdgeSlavesMap();
1123 const labelListList& transformedSlaves = globalEdgeTransformedSlaves();
1129 for (label edgeI = 0; edgeI < coupledPatch().nEdges(); edgeI++)
1134 slaves[edgeI].size()
1135 + transformedSlaves[edgeI].size()
1142 const edge&
e = coupledPatch().edges()[edgeI];
1156 minEqOp<labelPair>()
1160 globalEdgeOrientationPtr_.reset
1162 new bitSet(coupledPatch().nEdges())
1164 bitSet& globalEdgeOrientation = globalEdgeOrientationPtr_();
1166 forAll(coupledPatch().edges(), edgeI)
1171 const edge&
e = coupledPatch().edges()[edgeI];
1181 masterEdgeVerts[edgeI]
1186 <<
"problem : my edge:" <<
e 1187 <<
" in master points:" << masterE
1188 <<
" v.s. masterEdgeVerts:" << masterEdgeVerts[edgeI]
1193 globalEdgeOrientation.set(edgeI, (stat == 1));
1198 globalEdgeOrientation.set(edgeI,
true);
1205 Pout<<
"globalMeshData::calcGlobalEdgeOrientation() :" 1206 <<
" finished calculating edge orientation." 1212 void Foam::globalMeshData::calcPointBoundaryFaces
1217 const polyBoundaryMesh&
bMesh = mesh_.boundaryMesh();
1218 const Map<label>& meshPointMap = coupledPatch().meshPointMap();
1224 for (
const polyPatch&
pp :
bMesh)
1228 for (
const face&
f :
pp)
1232 const auto iter = meshPointMap.cfind(
f[fp]);
1235 nPointFaces[iter.val()]++;
1245 pointBoundaryFaces.setSize(coupledPatch().
nPoints());
1246 forAll(nPointFaces, pointi)
1248 pointBoundaryFaces[pointi].setSize(nPointFaces[pointi]);
1257 const polyPatch&
pp =
bMesh[patchi];
1263 const face&
f =
pp[i];
1266 const auto iter = meshPointMap.cfind(
f[fp]);
1271 pp.start() + i - mesh_.nInternalFaces();
1272 pointBoundaryFaces[iter()][nPointFaces[iter()]++] =
1282 void Foam::globalMeshData::calcGlobalPointBoundaryFaces()
const 1286 Pout<<
"globalMeshData::calcGlobalPointBoundaryFaces() :" 1287 <<
" calculating coupled point to boundary face addressing." 1293 calcPointBoundaryFaces(pointBoundaryFaces);
1297 globalBoundaryFaceNumberingPtr_.reset
1299 new globalIndex(mesh_.nBoundaryFaces())
1301 globalIndex& globalIndices = globalBoundaryFaceNumberingPtr_();
1305 globalPointBoundaryFacesPtr_.reset
1309 labelListList& globalPointBoundaryFaces = globalPointBoundaryFacesPtr_();
1311 forAll(pointBoundaryFaces, pointi)
1313 const labelList& bFaces = pointBoundaryFaces[pointi];
1314 labelList& globalFaces = globalPointBoundaryFaces[pointi];
1315 globalFaces.
setSize(bFaces.size());
1318 globalFaces[i] = globalIndices.toGlobal(bFaces[i]);
1324 globalPointSlavesMap().distribute
1326 globalPointBoundaryFaces,
1335 globalPointTransformedSlaves();
1336 const globalIndexAndTransform& transforms = globalTransforms();
1340 List<labelPairList> transformedFaces(pointSlaves.size());
1343 forAll(pointSlaves, pointi)
1345 const labelList& slaves = pointSlaves[pointi];
1346 const labelList& transformedSlaves = pointTransformSlaves[pointi];
1348 if (slaves.size() > 0)
1350 labelList& myBFaces = globalPointBoundaryFaces[pointi];
1351 label sz = myBFaces.
size();
1357 n += globalPointBoundaryFaces[slaves[i]].size();
1360 myBFaces.setSize(sz+
n);
1365 globalPointBoundaryFaces[slaves[i]];
1370 for (
const label slave : slaveBFaces)
1372 if (!SubList<label>(myBFaces, sz).
found(slave))
1374 myBFaces[
n++] = slave;
1382 if (transformedSlaves.size() > 0)
1384 const labelList& untrafoFaces = globalPointBoundaryFaces[pointi];
1387 label sz = myBFaces.size();
1391 forAll(transformedSlaves, i)
1393 n += globalPointBoundaryFaces[transformedSlaves[i]].size();
1396 myBFaces.setSize(sz+
n);
1398 forAll(transformedSlaves, i)
1400 label transformI = globalPointSlavesMap().whichTransform
1402 transformedSlaves[i]
1406 globalPointBoundaryFaces[transformedSlaves[i]];
1408 for (
const label slave : slaveBFaces)
1411 if (!untrafoFaces.found(slave))
1413 label proci = globalIndices.whichProcID(slave);
1414 label facei = globalIndices.toLocal(proci, slave);
1416 myBFaces[
n++] = transforms.encode
1429 if (slaves.size() + transformedSlaves.size() == 0)
1431 globalPointBoundaryFaces[pointi].clear();
1438 globalPointTransformedBoundaryFacesPtr_.reset
1443 globalPointBoundaryFacesMapPtr_.reset
1448 globalPointBoundaryFaces,
1452 globalPointTransformedBoundaryFacesPtr_(),
1457 globalPointBoundaryFaces.setSize(coupledPatch().
nPoints());
1458 globalPointTransformedBoundaryFacesPtr_().setSize(coupledPatch().
nPoints());
1462 Pout<<
"globalMeshData::calcGlobalPointBoundaryFaces() :" 1463 <<
" coupled points:" << coupledPatch().nPoints()
1464 <<
" local boundary faces:" << globalIndices.localSize()
1465 <<
" additional coupled faces:" 1466 << globalPointBoundaryFacesMapPtr_().constructSize()
1467 - globalIndices.localSize()
1473 void Foam::globalMeshData::calcGlobalPointBoundaryCells()
const 1477 Pout<<
"globalMeshData::calcGlobalPointBoundaryCells() :" 1478 <<
" calculating coupled point to boundary cell addressing." 1486 Map<label> meshCellMap(4*coupledPatch().
nPoints());
1487 DynamicList<label> cellMap(meshCellMap.size());
1492 forAll(coupledPatch().meshPoints(), pointi)
1494 label meshPointi = coupledPatch().meshPoints()[pointi];
1495 const labelList& pCells = mesh_.pointCells(meshPointi);
1497 labelList& bCells = pointBoundaryCells[pointi];
1498 bCells.
setSize(pCells.size());
1502 const label celli = pCells[i];
1503 const auto fnd = meshCellMap.cfind(celli);
1511 meshCellMap.insert(celli, bCelli);
1512 cellMap.append(celli);
1520 boundaryCellsPtr_.reset(
new labelList(std::move(cellMap)));
1521 labelList& boundaryCells = boundaryCellsPtr_();
1527 globalBoundaryCellNumberingPtr_.reset
1529 new globalIndex(boundaryCells.size())
1531 globalIndex& globalIndices = globalBoundaryCellNumberingPtr_();
1534 globalPointBoundaryCellsPtr_.reset
1538 labelListList& globalPointBoundaryCells = globalPointBoundaryCellsPtr_();
1540 forAll(pointBoundaryCells, pointi)
1542 const labelList& pCells = pointBoundaryCells[pointi];
1543 labelList& globalCells = globalPointBoundaryCells[pointi];
1544 globalCells.
setSize(pCells.size());
1547 globalCells[i] = globalIndices.toGlobal(pCells[i]);
1553 globalPointSlavesMap().distribute
1555 globalPointBoundaryCells,
1563 globalPointTransformedSlaves();
1564 const globalIndexAndTransform& transforms = globalTransforms();
1566 List<labelPairList> transformedCells(pointSlaves.size());
1569 forAll(pointSlaves, pointi)
1571 const labelList& slaves = pointSlaves[pointi];
1572 const labelList& transformedSlaves = pointTransformSlaves[pointi];
1574 if (slaves.size() > 0)
1576 labelList& myBCells = globalPointBoundaryCells[pointi];
1577 label sz = myBCells.
size();
1583 n += globalPointBoundaryCells[slaves[i]].size();
1586 myBCells.setSize(sz+
n);
1591 globalPointBoundaryCells[slaves[i]];
1596 for (
const label slave : slaveBCells)
1598 if (!SubList<label>(myBCells, sz).
found(slave))
1600 myBCells[
n++] = slave;
1608 if (transformedSlaves.size() > 0)
1610 const labelList& untrafoCells = globalPointBoundaryCells[pointi];
1613 label sz = myBCells.size();
1617 forAll(transformedSlaves, i)
1619 n += globalPointBoundaryCells[transformedSlaves[i]].size();
1622 myBCells.setSize(sz+
n);
1624 forAll(transformedSlaves, i)
1626 label transformI = globalPointSlavesMap().whichTransform
1628 transformedSlaves[i]
1632 globalPointBoundaryCells[transformedSlaves[i]];
1634 for (
const label slave : slaveBCells)
1637 if (!untrafoCells.found(slave))
1639 label proci = globalIndices.whichProcID(slave);
1640 label celli = globalIndices.toLocal(proci, slave);
1641 myBCells[
n++] = transforms.encode
1653 if (slaves.size() + transformedSlaves.size() == 0)
1655 globalPointBoundaryCells[pointi].clear();
1662 globalPointTransformedBoundaryCellsPtr_.reset
1667 globalPointBoundaryCellsMapPtr_.reset
1672 globalPointBoundaryCells,
1676 globalPointTransformedBoundaryCellsPtr_(),
1681 globalPointBoundaryCells.setSize(coupledPatch().
nPoints());
1682 globalPointTransformedBoundaryCellsPtr_().setSize(coupledPatch().
nPoints());
1686 Pout<<
"globalMeshData::calcGlobalPointBoundaryCells() :" 1687 <<
" coupled points:" << coupledPatch().nPoints()
1688 <<
" local boundary cells:" << globalIndices.localSize()
1689 <<
" additional coupled cells:" 1690 << globalPointBoundaryCellsMapPtr_().constructSize()
1691 - globalIndices.localSize()
1697 void Foam::globalMeshData::calcGlobalCoPointSlaves()
const 1701 Pout<<
"globalMeshData::calcGlobalCoPointSlaves() :" 1702 <<
" calculating coupled master to collocated" 1703 <<
" slave point addressing." <<
endl;
1707 globalPoints globalData(mesh_, coupledPatch(),
true,
false);
1709 globalCoPointSlavesPtr_.reset
1713 std::move(globalData.pointPoints())
1716 globalCoPointSlavesMapPtr_.reset
1720 std::move(globalData.map())
1726 Pout<<
"globalMeshData::calcGlobalCoPointSlaves() :" 1727 <<
" finished calculating coupled master to collocated" 1728 <<
" slave point addressing." <<
endl;
1743 processorTopology::
New<processorPolyPatch>
1745 mesh.boundaryMesh(),
1749 processorPatches_(),
1750 processorPatchIndices_(),
1751 processorPatchNeighbours_(),
1753 sharedPointLabelsPtr_(nullptr),
1754 sharedPointAddrPtr_(nullptr),
1755 sharedPointGlobalLabelsPtr_(nullptr),
1757 sharedEdgeLabelsPtr_(nullptr),
1758 sharedEdgeAddrPtr_(nullptr)
1774 nGlobalPoints_ = -1;
1775 sharedPointLabelsPtr_.clear();
1776 sharedPointAddrPtr_.clear();
1777 sharedPointGlobalLabelsPtr_.clear();
1781 sharedEdgeLabelsPtr_.clear();
1782 sharedEdgeAddrPtr_.clear();
1785 coupledPatchPtr_.clear();
1786 coupledPatchMeshEdgesPtr_.clear();
1787 coupledPatchMeshEdgeMapPtr_.clear();
1788 globalTransformsPtr_.clear();
1791 globalPointNumberingPtr_.clear();
1792 globalPointSlavesPtr_.clear();
1793 globalPointTransformedSlavesPtr_.clear();
1794 globalPointSlavesMapPtr_.clear();
1797 globalEdgeNumberingPtr_.clear();
1798 globalEdgeSlavesPtr_.clear();
1799 globalEdgeTransformedSlavesPtr_.clear();
1800 globalEdgeOrientationPtr_.clear();
1801 globalEdgeSlavesMapPtr_.clear();
1804 globalBoundaryFaceNumberingPtr_.clear();
1805 globalPointBoundaryFacesPtr_.clear();
1806 globalPointTransformedBoundaryFacesPtr_.clear();
1807 globalPointBoundaryFacesMapPtr_.clear();
1810 boundaryCellsPtr_.clear();
1811 globalBoundaryCellNumberingPtr_.clear();
1812 globalPointBoundaryCellsPtr_.clear();
1813 globalPointTransformedBoundaryCellsPtr_.clear();
1814 globalPointBoundaryCellsMapPtr_.clear();
1817 globalCoPointSlavesPtr_.clear();
1818 globalCoPointSlavesMapPtr_.clear();
1826 if (!sharedPointGlobalLabelsPtr_)
1828 sharedPointGlobalLabelsPtr_.reset
1830 new labelList(sharedPointLabels().size())
1832 labelList& sharedPointGlobalLabels = sharedPointGlobalLabelsPtr_();
1836 "pointProcAddressing",
1846 Pout<<
"globalMeshData::sharedPointGlobalLabels : " 1847 <<
"Reading pointProcAddressing" <<
endl;
1859 sharedPointGlobalLabels[i] = pointProcAddressing[pointi];
1864 Pout<<
"globalMeshData::sharedPointGlobalLabels :" 1865 <<
" Setting pointProcAddressing to -1" <<
endl;
1867 sharedPointGlobalLabels = -1;
1871 return *sharedPointGlobalLabelsPtr_;
1881 const labelList& pointAddr = sharedPointAddr();
1890 label sharedPointi = pointAddr[i];
1892 sharedPoints[sharedPointi] = mesh_.points()[
pointLabels[i]];
1902 fromProc >> nbrSharedPointAddr >> nbrSharedPoints;
1904 forAll(nbrSharedPointAddr, i)
1906 label sharedPointi = nbrSharedPointAddr[i];
1908 sharedPoints[sharedPointi] = nbrSharedPoints[i];
1932 return sharedPoints;
1939 pointField sharedPoints(mesh_.points(), sharedPointLabels());
1945 scalar tolDim = matchTol_ * mesh_.bounds().mag();
1956 return sharedPoints;
1962 if (nGlobalPoints_ == -1)
1966 return nGlobalPoints_;
1972 if (!sharedPointLabelsPtr_)
1976 return *sharedPointLabelsPtr_;
1982 if (!sharedPointAddrPtr_)
1986 return *sharedPointAddrPtr_;
1992 if (nGlobalEdges_ == -1)
1996 return nGlobalEdges_;
2002 if (!sharedEdgeLabelsPtr_)
2006 return *sharedEdgeLabelsPtr_;
2012 if (!sharedEdgeAddrPtr_)
2016 return *sharedEdgeAddrPtr_;
2022 if (!coupledPatchPtr_)
2024 const polyBoundaryMesh&
bMesh = mesh_.boundaryMesh();
2030 const polyPatch&
pp =
bMesh[patchi];
2034 nCoupled +=
pp.size();
2042 const polyPatch&
pp =
bMesh[patchi];
2046 label facei =
pp.start();
2050 coupledFaces[nCoupled++] = facei++;
2055 coupledPatchPtr_.reset
2070 Pout<<
"globalMeshData::coupledPatch() :" 2071 <<
" constructed coupled faces patch:" 2072 <<
" faces:" << coupledPatchPtr_().size()
2073 <<
" points:" << coupledPatchPtr_().nPoints()
2077 return *coupledPatchPtr_;
2083 if (!coupledPatchMeshEdgesPtr_)
2085 coupledPatchMeshEdgesPtr_.reset
2089 coupledPatch().meshEdges
2097 return *coupledPatchMeshEdgesPtr_;
2104 if (!coupledPatchMeshEdgeMapPtr_)
2108 coupledPatchMeshEdgeMapPtr_.reset(
new Map<label>(2*
me.size()));
2109 Map<label>& em = coupledPatchMeshEdgeMapPtr_();
2116 return *coupledPatchMeshEdgeMapPtr_;
2122 if (!globalPointNumberingPtr_)
2124 globalPointNumberingPtr_.
reset 2126 new globalIndex(coupledPatch().
nPoints())
2129 return *globalPointNumberingPtr_;
2136 if (!globalTransformsPtr_)
2140 return *globalTransformsPtr_;
2146 if (!globalPointSlavesPtr_)
2148 calcGlobalPointSlaves();
2150 return *globalPointSlavesPtr_;
2157 if (!globalPointTransformedSlavesPtr_)
2159 calcGlobalPointSlaves();
2161 return *globalPointTransformedSlavesPtr_;
2167 if (!globalPointSlavesMapPtr_)
2169 calcGlobalPointSlaves();
2171 return *globalPointSlavesMapPtr_;
2177 if (!globalEdgeNumberingPtr_)
2179 globalEdgeNumberingPtr_.
reset 2184 return *globalEdgeNumberingPtr_;
2190 if (!globalEdgeSlavesPtr_)
2192 calcGlobalEdgeSlaves();
2194 return *globalEdgeSlavesPtr_;
2201 if (!globalEdgeTransformedSlavesPtr_)
2203 calcGlobalEdgeSlaves();
2205 return *globalEdgeTransformedSlavesPtr_;
2211 if (!globalEdgeOrientationPtr_)
2213 calcGlobalEdgeOrientation();
2215 return *globalEdgeOrientationPtr_;
2221 if (!globalEdgeSlavesMapPtr_)
2223 calcGlobalEdgeSlaves();
2225 return *globalEdgeSlavesMapPtr_;
2232 if (!globalBoundaryFaceNumberingPtr_)
2234 calcGlobalPointBoundaryFaces();
2236 return *globalBoundaryFaceNumberingPtr_;
2243 if (!globalPointBoundaryFacesPtr_)
2245 calcGlobalPointBoundaryFaces();
2247 return *globalPointBoundaryFacesPtr_;
2254 if (!globalPointTransformedBoundaryFacesPtr_)
2256 calcGlobalPointBoundaryFaces();
2258 return *globalPointTransformedBoundaryFacesPtr_;
2265 if (!globalPointBoundaryFacesMapPtr_)
2267 calcGlobalPointBoundaryFaces();
2269 return *globalPointBoundaryFacesMapPtr_;
2275 if (!boundaryCellsPtr_)
2277 calcGlobalPointBoundaryCells();
2279 return *boundaryCellsPtr_;
2286 if (!globalBoundaryCellNumberingPtr_)
2288 calcGlobalPointBoundaryCells();
2290 return *globalBoundaryCellNumberingPtr_;
2297 if (!globalPointBoundaryCellsPtr_)
2299 calcGlobalPointBoundaryCells();
2301 return *globalPointBoundaryCellsPtr_;
2308 if (!globalPointTransformedBoundaryCellsPtr_)
2310 calcGlobalPointBoundaryCells();
2312 return *globalPointTransformedBoundaryCellsPtr_;
2319 if (!globalPointBoundaryCellsMapPtr_)
2321 calcGlobalPointBoundaryCells();
2323 return *globalPointBoundaryCellsMapPtr_;
2329 if (!globalCoPointSlavesPtr_)
2331 calcGlobalCoPointSlaves();
2333 return *globalCoPointSlavesPtr_;
2339 if (!globalCoPointSlavesMapPtr_)
2341 calcGlobalCoPointSlaves();
2343 return *globalCoPointSlavesMapPtr_;
2354 const globalIndex& globalCoupledPoints = globalPointNumbering();
2357 const mapDistribute& pointSlavesMap = globalCoPointSlavesMap();
2365 labelList masterGlobalPoint(cpp.nPoints(), -1);
2366 forAll(masterGlobalPoint, pointi)
2368 const labelList& slavePoints = pointSlaves[pointi];
2369 if (slavePoints.size() > 0)
2371 masterGlobalPoint[pointi] = globalCoupledPoints.toGlobal(pointi);
2388 bitSet isMaster(mesh_.nPoints(),
true);
2389 forAll(pointSlaves, pointi)
2391 if (masterGlobalPoint[pointi] == -1)
2398 masterGlobalPoint[pointi]
2399 == globalCoupledPoints.toGlobal(pointi)
2408 isMaster.unset(cpp.meshPoints()[pointi]);
2412 label myUniquePoints = mesh_.nPoints() - cpp.nPoints() + nMaster;
2422 autoPtr<globalIndex> globalPointsPtr(
new globalIndex(myUniquePoints));
2426 pointToGlobal.setSize(mesh_.nPoints());
2428 uniquePoints.setSize(myUniquePoints);
2431 forAll(isMaster, meshPointi)
2433 if (isMaster[meshPointi])
2435 pointToGlobal[meshPointi] = globalPointsPtr().toGlobal(nMaster);
2436 uniquePoints[nMaster] = meshPointi;
2444 labelList masterToGlobal(pointSlavesMap.constructSize(), -1);
2446 forAll(pointSlaves, pointi)
2448 const labelList& slaves = pointSlaves[pointi];
2450 if (slaves.size() > 0)
2453 label meshPointi = cpp.meshPoints()[pointi];
2454 masterToGlobal[pointi] = pointToGlobal[meshPointi];
2457 masterToGlobal[slaves[i]] = masterToGlobal[pointi];
2463 pointSlavesMap.reverseDistribute(cpp.nPoints(), masterToGlobal);
2466 forAll(pointSlaves, pointi)
2468 label meshPointi = cpp.meshPoints()[pointi];
2470 if (!isMaster[meshPointi])
2472 pointToGlobal[meshPointi] = masterToGlobal[pointi];
2477 return globalPointsPtr;
2491 const mapDistribute& pointSlavesMap = globalCoPointSlavesMap();
2509 const globalIndex globalPPoints(meshPoints.size());
2511 labelList patchToCoupled(meshPoints.size(), -1);
2512 labelList coupledToGlobalPatch(pointSlavesMap.constructSize(), -1);
2516 forAll(meshPoints, patchPointi)
2518 label meshPointi = meshPoints[patchPointi];
2520 const auto iter = cpp.meshPointMap().cfind(meshPointi);
2524 patchToCoupled[patchPointi] = iter();
2525 coupledToGlobalPatch[iter()] = globalPPoints.toGlobal(patchPointi);
2543 pointSlavesMap.distribute(coupledToGlobalPatch);
2544 forAll(pointSlaves, coupledPointi)
2546 const labelList& slaves = pointSlaves[coupledPointi];
2548 if (slaves.size() > 0)
2552 if (coupledToGlobalPatch[coupledPointi] != -1)
2555 masterI = coupledToGlobalPatch[coupledPointi];
2562 label slavePp = coupledToGlobalPatch[slaves[i]];
2563 if (slavePp != -1 && slavePp < masterI)
2573 coupledToGlobalPatch[coupledPointi] = masterI;
2576 coupledToGlobalPatch[slaves[i]] = masterI;
2581 pointSlavesMap.reverseDistribute(cpp.nPoints(), coupledToGlobalPatch);
2591 forAll(meshPoints, patchPointi)
2593 if (patchToCoupled[patchPointi] == -1)
2599 label coupledPointi = patchToCoupled[patchPointi];
2602 globalPPoints.toGlobal(patchPointi)
2603 == coupledToGlobalPatch[coupledPointi]
2612 autoPtr<globalIndex> globalPointsPtr(
new globalIndex(nMasters));
2624 pointToGlobal.setSize(meshPoints.size());
2626 uniqueMeshPoints.setSize(nMasters);
2630 labelList globalMaster(cpp.nPoints(), -1);
2633 forAll(meshPoints, patchPointi)
2635 if (patchToCoupled[patchPointi] == -1)
2637 uniqueMeshPoints[nMasters++] = meshPoints[patchPointi];
2641 label coupledPointi = patchToCoupled[patchPointi];
2644 globalPPoints.toGlobal(patchPointi)
2645 == coupledToGlobalPatch[coupledPointi]
2648 globalMaster[coupledPointi] =
2649 globalPointsPtr().toGlobal(nMasters);
2650 uniqueMeshPoints[nMasters++] = meshPoints[patchPointi];
2670 forAll(meshPoints, patchPointi)
2672 if (patchToCoupled[patchPointi] == -1)
2674 pointToGlobal[patchPointi] = globalPointsPtr().toGlobal(nMasters++);
2678 label coupledPointi = patchToCoupled[patchPointi];
2679 pointToGlobal[patchPointi] = globalMaster[coupledPointi];
2683 globalPPoints.toGlobal(patchPointi)
2684 == coupledToGlobalPatch[coupledPointi]
2692 return globalPointsPtr;
2713 scalar tolDim = matchTol_ * mesh_.bounds().mag();
2717 Pout<<
"globalMeshData : merge dist:" << tolDim <<
endl;
2723 UPstream::communicator dupComm
2729 const label comm = dupComm.comm();
2732 FixedList<label, 3> totals;
2734 totals[0] = mesh_.nPoints();
2735 totals[1] = mesh_.nFaces();
2736 totals[2] = mesh_.nCells();
2740 nTotalPoints_ = totals[0];
2741 nTotalFaces_ = totals[1];
2742 nTotalCells_ = totals[2];
2749 Info<<
"globalMeshData : Total points/faces/cells : " const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
const Map< label > & coupledPatchMeshEdgeMap() const
Return map from mesh edges to coupledPatch edges.
void reset(const label localSize, const label comm=UPstream::worldComm, const bool parallel=UPstream::parRun())
Reset from local size, using gather/broadcast with default/specified communicator if parallel...
label comm() const noexcept
The communicator used for parallel communication.
const labelListList & globalPointSlaves() const
void size(const label n)
Older name for setAddressableSize.
const mapDistribute & globalCoPointSlavesMap() const
"blocking" : (MPI_Bsend, MPI_Recv)
const labelListList & globalPointTransformedSlaves() const
pointField geometricSharedPoints() const
Like sharedPoints but keeps cyclic points separate.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const globalIndex & globalBoundaryCellNumbering() const
Numbering of boundary cells is according to boundaryCells()
labelList pointLabels(nPoints, -1)
void resize(const label len)
Adjust allocated size of list.
const labelList & sharedPointGlobalLabels() const
Return shared point global labels. Tries to read.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< edge > edgeList
List of edge.
const labelListList & globalPointTransformedBoundaryFaces() const
const mapDistribute & globalEdgeSlavesMap() const
static const Foam::scalar matchTol_
Geometric tolerance (fraction of bounding box)
constexpr char nl
The newline '\n' character (0x0a)
void clearOut()
Remove all demand driven data.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
const mapDistribute & globalPointSlavesMap() const
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.
const bitSet & globalEdgeOrientation() const
Is my edge same orientation as master edge.
const labelListList & globalPointBoundaryCells() const
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
static int & msgType() noexcept
Message tag of standard messages.
List< labelPair > labelPairList
List of labelPair.
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
const labelListList & globalEdgeSlaves() const
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
const labelList & coupledPatchMeshEdges() const
Return map from coupledPatch edges to mesh edges.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field...
List< labelList > labelListList
List of labelList.
const labelListList & globalPointBoundaryFaces() const
const dimensionedScalar me
Electron mass.
static bool less(const vector &x, const vector &y)
To compare normals.
UList< label > labelUList
A UList of labels.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
#define forAll(list, i)
Loop across all elements in list.
const labelList & boundaryCells() const
From boundary cell to mesh cell.
static label commWarn(const label communicator) noexcept
Alter communicator debugging setting. Warns for use of any communicator differing from specified...
label nGlobalEdges() const
Return number of globally shared edges. Demand-driven.
List helper to append y elements onto the end of x.
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
const globalIndex & globalEdgeNumbering() const
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
label nGlobalPoints() const
Return number of globally shared points.
vectorField pointField
pointField is a vectorField.
const labelList & sharedEdgeAddr() const
Return addressing into the complete globally shared edge.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
const globalIndexAndTransform & globalTransforms() const
Global transforms numbering.
static int compare(const Pair< label > &a, const Pair< label > &b)
Compare Pairs.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
void sort(UList< T > &list)
Sort the list.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
label size() const noexcept
The number of entries in the list.
const globalIndex & globalPointNumbering() const
Numbering of coupled points is according to coupledPatch.
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...
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
static void combineReduce(const List< commsStruct > &comms, T &value, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine value from different processors...
void reset(const dimensionSet &ds)
Copy assign the exponents from the dimensionSet.
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
~globalMeshData()
Destructor.
defineTypeNameAndDebug(combustionModel, 0)
Geometric merging of points. See below.
Define the processor-processor connection table by walking a list of patches and detecting the proces...
void movePoints(const pointField &newPoints)
Update for moving points.
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
const labelListList & globalPointTransformedBoundaryCells() const
void operator()(T &x, const T &y) const
Class containing processor-to-processor mapping information.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
void updateMesh()
Change global mesh data given a topological change. Does a.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
List< label > labelList
A List of labels.
const mapDistribute & globalPointBoundaryFacesMap() const
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points.
Defines the attributes of an object for which implicit objectRegistry management is supported...
pointField sharedPoints() const
Collect coordinates of shared points on all processors.
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points) ...
const mapDistribute & globalPointBoundaryCellsMap() const
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const labelList & sharedEdgeLabels() const
Return indices of local edges that are globally shared.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)
const labelListList & globalCoPointSlaves() const
A HashTable to objects of type <T> with a label key.
const labelListList & globalEdgeTransformedSlaves() const
globalMeshData(const globalMeshData &)=delete
No copy construct.
static constexpr const zero Zero
Global zero (0)
const globalIndex & globalBoundaryFaceNumbering() const
Numbering of boundary faces is face-mesh.nInternalFaces()