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);
93 for (
const label patchi : processorPatches_)
97 refCast<const processorPolyPatch>
104 toNeighbour << processorPatchIndices_[patchi];
107 pBufs.finishedSends();
109 for (
const label patchi : processorPatches_)
111 UIPstream fromNeighbour
113 refCast<const processorPolyPatch>
120 fromNeighbour >> processorPatchNeighbours_[patchi];
126 void Foam::globalMeshData::calcSharedPoints()
const 131 || sharedPointLabelsPtr_
132 || sharedPointAddrPtr_
141 const globalPoints parallelPoints(mesh_,
false,
true);
145 forAll(parallelPoints.pointPoints(), i)
147 const labelList& pPoints = parallelPoints.pointPoints()[i];
149 parallelPoints.transformedPointPoints()[i];
151 if (pPoints.size()+transPPoints.size() > 0)
158 const globalIndex masterNumbering(nMaster);
160 nGlobalPoints_ = masterNumbering.totalSize();
167 labelList master(parallelPoints.map().constructSize(), -1);
168 forAll(parallelPoints.pointPoints(), i)
170 const labelList& pPoints = parallelPoints.pointPoints()[i];
172 parallelPoints.transformedPointPoints()[i];
174 if (pPoints.size()+transPPoints.size() > 0)
176 master[i] = masterNumbering.toGlobal(nMaster);
179 master[pPoints[j]] = master[i];
183 master[transPPoints[j]] = master[i];
201 parallelPoints.map().reverseDistribute
203 parallelPoints.map().constructSize(),
210 forAll(parallelPoints.pointPoints(), i)
218 sharedPointLabelsPtr_.reset(
new labelList(nMaster));
219 labelList& sharedPointLabels = sharedPointLabelsPtr_();
220 sharedPointAddrPtr_.reset(
new labelList(nMaster));
221 labelList& sharedPointAddr = sharedPointAddrPtr_();
224 forAll(parallelPoints.pointPoints(), i)
229 sharedPointLabels[nMaster] = i;
230 sharedPointAddr[nMaster] = master[i];
237 Pout<<
"globalMeshData : nGlobalPoints_:" << nGlobalPoints_ <<
nl 238 <<
"globalMeshData : sharedPointLabels_:" 239 << sharedPointLabelsPtr_().size() <<
nl 240 <<
"globalMeshData : sharedPointAddr_:" 241 << sharedPointAddrPtr_().size() <<
endl;
246 void Foam::globalMeshData::countSharedEdges
248 const EdgeMap<labelList>& procSharedEdges,
249 EdgeMap<label>& globalShared,
256 const edge&
e = iter.key();
258 auto globalFnd = globalShared.find(
e);
260 if (globalFnd.found())
262 if (globalFnd() == -1)
266 globalFnd() = sharedEdgeI++;
272 if (iter().size() == 1)
275 globalShared.insert(
e, -1);
281 globalShared.insert(
e, sharedEdgeI++);
288 void Foam::globalMeshData::calcSharedEdges()
const 298 || sharedEdgeLabelsPtr_
299 || sharedEdgeAddrPtr_
307 const labelList& sharedPtAddr = sharedPointAddr();
308 const labelList& sharedPtLabels = sharedPointLabels();
312 Map<label> meshToShared(2*sharedPtLabels.size());
315 meshToShared.insert(sharedPtLabels[i], i);
321 EdgeMap<labelList> localShared(2*sharedPtAddr.size());
323 const edgeList& edges = mesh_.edges();
327 const edge&
e = edges[edgeI];
329 const auto e0Fnd = meshToShared.cfind(
e[0]);
333 const auto e1Fnd = meshToShared.cfind(
e[1]);
343 sharedPtAddr[e0Fnd()],
344 sharedPtAddr[e1Fnd()]
347 auto iter = localShared.find(sharedEdge);
352 localShared.insert(sharedEdge,
labelList(1, edgeI));
359 const label sz = edgeLabels.size();
360 edgeLabels.setSize(sz+1);
361 edgeLabels[sz] = edgeI;
377 EdgeMap<label> globalShared(nGlobalPoints());
381 label sharedEdgeI = 0;
386 Pout<<
"globalMeshData::calcSharedEdges : Merging in from proc0 : " 387 << localShared.size() <<
endl;
389 countSharedEdges(localShared, globalShared, sharedEdgeI);
398 EdgeMap<labelList> procSharedEdges(fromProc);
402 Pout<<
"globalMeshData::calcSharedEdges : " 403 <<
"Merging in from proc" 404 << proci <<
" : " << procSharedEdges.size()
407 countSharedEdges(procSharedEdges, globalShared, sharedEdgeI);
415 EdgeMap<label> oldSharedEdges(globalShared);
417 globalShared.clear();
423 globalShared.insert(iter.key(), iter());
428 Pout<<
"globalMeshData::calcSharedEdges : Filtered " 429 << oldSharedEdges.size()
430 <<
" down to " << globalShared.size() <<
endl;
444 toMaster << localShared;
455 nGlobalEdges_ = globalShared.size();
457 DynamicList<label> dynSharedEdgeLabels(globalShared.size());
458 DynamicList<label> dynSharedEdgeAddr(globalShared.size());
462 const edge&
e = iter.key();
464 const auto edgeFnd = globalShared.cfind(
e);
472 for (
const label edgei : edgeLabels)
475 dynSharedEdgeLabels.append(edgei);
478 dynSharedEdgeAddr.append(edgeFnd());
484 sharedEdgeLabelsPtr_.reset(
new labelList());
485 labelList& sharedEdgeLabels = sharedEdgeLabelsPtr_();
486 sharedEdgeLabels.transfer(dynSharedEdgeLabels);
488 sharedEdgeAddrPtr_.reset(
new labelList());
489 labelList& sharedEdgeAddr = sharedEdgeAddrPtr_();
490 sharedEdgeAddr.transfer(dynSharedEdgeAddr);
494 Pout<<
"globalMeshData : nGlobalEdges_:" << nGlobalEdges_ <<
nl 495 <<
"globalMeshData : sharedEdgeLabels:" << sharedEdgeLabels.size()
497 <<
"globalMeshData : sharedEdgeAddr:" << sharedEdgeAddr.size()
503 void Foam::globalMeshData::calcGlobalPointSlaves()
const 507 Pout<<
"globalMeshData::calcGlobalPointSlaves() :" 508 <<
" calculating coupled master to slave point addressing." 513 globalPoints globalData(mesh_, coupledPatch(),
true,
true);
515 globalPointSlavesPtr_.reset
519 std::move(globalData.pointPoints())
522 globalPointTransformedSlavesPtr_.reset
526 std::move(globalData.transformedPointPoints())
530 globalPointSlavesMapPtr_.reset
534 std::move(globalData.map())
540 void Foam::globalMeshData::calcPointConnectivity
542 List<labelPairList>& allPointConnectivity
545 const globalIndexAndTransform& transforms = globalTransforms();
547 const labelListList& transformedSlaves = globalPointTransformedSlaves();
551 labelPairList myData(globalPointSlavesMap().constructSize());
554 myData[pointi] = transforms.encode
558 transforms.nullTransformIndex()
562 globalPointSlavesMap().distribute(myData);
566 allPointConnectivity.setSize(globalPointSlavesMap().constructSize());
574 const labelList& pSlaves = slaves[pointi];
575 const labelList& pTransformSlaves = transformedSlaves[pointi];
577 if (pSlaves.size()+pTransformSlaves.size())
581 pConnectivity.setSize(1+pSlaves.size()+pTransformSlaves.size());
585 pConnectivity[connI++] = myData[pointi];
589 pConnectivity[connI++] = myData[pSlaves[i]];
592 forAll(pTransformSlaves, i)
595 label transformI = globalPointSlavesMap().whichTransform
600 const labelPair&
n = myData[pTransformSlaves[i]];
601 label proci = transforms.processor(
n);
602 label index = transforms.index(
n);
603 pConnectivity[connI++] = transforms.encode
614 allPointConnectivity[pSlaves[i]] = pConnectivity;
616 forAll(pTransformSlaves, i)
618 allPointConnectivity[pTransformSlaves[i]] = pConnectivity;
629 if (pConnectivity.size() == 0)
631 pConnectivity.setSize(1, myData[pointi]);
636 globalPointSlavesMap().reverseDistribute
644 void Foam::globalMeshData::calcGlobalPointEdges
647 List<labelPairList>& globalPointPoints
650 const edgeList& edges = coupledPatch().edges();
651 const labelListList& pointEdges = coupledPatch().pointEdges();
652 const globalIndex& globalEdgeNumbers = globalEdgeNumbering();
654 const labelListList& transformedSlaves = globalPointTransformedSlaves();
655 const globalIndexAndTransform& transforms = globalTransforms();
659 globalPointEdges.setSize(globalPointSlavesMap().constructSize());
660 globalPointPoints.setSize(globalPointSlavesMap().constructSize());
661 forAll(pointEdges, pointi)
663 const labelList& pEdges = pointEdges[pointi];
664 globalPointEdges[pointi] = globalEdgeNumbers.toGlobal(pEdges);
667 globalPPoints.setSize(pEdges.size());
670 label otherPointi = edges[pEdges[i]].otherVertex(pointi);
671 globalPPoints[i] = transforms.encode
675 transforms.nullTransformIndex()
681 globalPointSlavesMap().distribute(globalPointEdges);
682 globalPointSlavesMap().distribute(globalPointPoints);
686 const labelList& pSlaves = slaves[pointi];
687 const labelList& pTransformSlaves = transformedSlaves[pointi];
692 n += globalPointEdges[pSlaves[i]].size();
694 forAll(pTransformSlaves, i)
696 n += globalPointEdges[pTransformSlaves[i]].size();
701 labelList& globalPEdges = globalPointEdges[pointi];
702 label sz = globalPEdges.
size();
703 globalPEdges.setSize(sz+
n);
706 const labelList& otherData = globalPointEdges[pSlaves[i]];
709 globalPEdges[sz++] = otherData[j];
712 forAll(pTransformSlaves, i)
715 globalPointEdges[pTransformSlaves[i]];
718 globalPEdges[sz++] = otherData[j];
725 globalPointEdges[pSlaves[i]] = globalPEdges;
727 forAll(pTransformSlaves, i)
729 globalPointEdges[pTransformSlaves[i]] = globalPEdges;
737 label sz = globalPPoints.size();
738 globalPPoints.setSize(sz +
n);
743 const labelPairList& otherData = globalPointPoints[pSlaves[i]];
746 globalPPoints[sz++] = otherData[j];
750 forAll(pTransformSlaves, i)
753 label transformI = globalPointSlavesMap().whichTransform
759 globalPointPoints[pTransformSlaves[i]];
764 label proci = transforms.processor(
n);
765 label index = transforms.index(
n);
766 globalPPoints[sz++] = transforms.encode
778 globalPointPoints[pSlaves[i]] = globalPPoints;
780 forAll(pTransformSlaves, i)
782 globalPointPoints[pTransformSlaves[i]] = globalPPoints;
787 globalPointSlavesMap().reverseDistribute
793 globalPointSlavesMap().reverseDistribute
801 Foam::label Foam::globalMeshData::findTransform
805 const label localPoint
808 const globalIndexAndTransform& transforms = globalTransforms();
810 const label remoteProci = transforms.processor(remotePoint);
811 const label remoteIndex = transforms.index(remotePoint);
813 label remoteTransformI = -1;
814 label localTransformI = -1;
817 label proci = transforms.processor(info[i]);
818 label pointi = transforms.index(info[i]);
819 label transformI = transforms.transformIndex(info[i]);
823 localTransformI = transformI;
828 if (proci == remoteProci && pointi == remoteIndex)
830 remoteTransformI = transformI;
838 if (remoteTransformI == -1 || localTransformI == -1)
841 <<
"Problem. Cannot find " << remotePoint
842 <<
" or " << localPoint <<
" " 843 << coupledPatch().localPoints()[localPoint]
846 <<
"remoteTransformI:" << remoteTransformI <<
endl 847 <<
"localTransformI:" << localTransformI
851 return transforms.subtractTransformIndex
859 void Foam::globalMeshData::calcGlobalEdgeSlaves()
const 863 Pout<<
"globalMeshData::calcGlobalEdgeSlaves() :" 864 <<
" calculating coupled master to slave edge addressing." <<
endl;
867 const edgeList& edges = coupledPatch().edges();
868 const globalIndex& globalEdgeNumbers = globalEdgeNumbering();
869 const globalIndexAndTransform& transforms = globalTransforms();
882 List<labelPairList> allPointConnectivity;
883 calcPointConnectivity(allPointConnectivity);
889 List<labelPairList> globalPointPoints;
890 calcGlobalPointEdges(globalPointEdges, globalPointPoints);
903 List<labelPairList> allEdgeConnectivity(edges.size());
907 const edge&
e = edges[edgeI];
908 const labelList& pEdges0 = globalPointEdges[
e[0]];
910 const labelList& pEdges1 = globalPointEdges[
e[1]];
914 DynamicList<labelPair> eEdges(2);
922 transforms.nullTransformIndex()
932 pEdges0[i] == pEdges1[j]
933 && pEdges0[i] != globalEdgeNumbers.toGlobal(edgeI)
945 label transform0 = findTransform
947 allPointConnectivity[
e[0]],
951 label transform1 = findTransform
953 allPointConnectivity[
e[1]],
958 if (transform0 == transform1)
960 label proci = globalEdgeNumbers.whichProcID(pEdges0[i]);
966 globalEdgeNumbers.toLocal(proci, pEdges0[i]),
975 allEdgeConnectivity[edgeI].transfer(eEdges);
978 allEdgeConnectivity[edgeI],
989 List<labelPairList> transformedEdges(edges.size());
990 forAll(allEdgeConnectivity, edgeI)
993 if (edgeInfo.size() >= 2)
995 const labelPair& masterInfo = edgeInfo[0];
1001 transforms.processor(masterInfo)
1004 && (transforms.index(masterInfo) == edgeI)
1008 labelList& eEdges = globalEdgeSlaves[edgeI];
1009 eEdges.
setSize(edgeInfo.size()-1);
1012 trafoEEdges.setSize(edgeInfo.size()-1);
1014 label nonTransformI = 0;
1015 label transformI = 0;
1017 for (label i = 1; i < edgeInfo.size(); i++)
1020 label proci = transforms.processor(info);
1021 label index = transforms.index(info);
1022 label
transform = transforms.transformIndex
1027 if (
transform == transforms.nullTransformIndex())
1029 eEdges[nonTransformI++] = globalEdgeNumbers.toGlobal
1037 trafoEEdges[transformI++] = info;
1041 eEdges.setSize(nonTransformI);
1042 trafoEEdges.setSize(transformI);
1052 globalEdgeSlavesMapPtr_.reset
1061 globalEdgeTransformedSlavesPtr_(),
1070 Pout<<
"globalMeshData::calcGlobalEdgeSlaves() :" 1071 <<
" coupled edges:" << edges.size()
1072 <<
" additional coupled edges:" 1073 << globalEdgeSlavesMapPtr_().constructSize() - edges.size()
1079 void Foam::globalMeshData::calcGlobalEdgeOrientation()
const 1083 Pout<<
"globalMeshData::calcGlobalEdgeOrientation() :" 1084 <<
" calculating edge orientation w.r.t. master edge." <<
endl;
1087 const globalIndex& globalPoints = globalPointNumbering();
1092 const mapDistribute& map = globalPointSlavesMap();
1094 masterPoint.setSize(map.constructSize());
1097 for (label pointi = 0; pointi < coupledPatch().nPoints(); pointi++)
1099 masterPoint[pointi] = globalPoints.toGlobal(pointi);
1104 globalPointSlaves(),
1105 globalPointTransformedSlaves(),
1116 const mapDistribute& map = globalEdgeSlavesMap();
1118 const labelListList& transformedSlaves = globalEdgeTransformedSlaves();
1124 for (label edgeI = 0; edgeI < coupledPatch().nEdges(); edgeI++)
1129 slaves[edgeI].size()
1130 + transformedSlaves[edgeI].size()
1137 const edge&
e = coupledPatch().edges()[edgeI];
1151 minEqOp<labelPair>()
1155 globalEdgeOrientationPtr_.reset
1157 new bitSet(coupledPatch().nEdges())
1159 bitSet& globalEdgeOrientation = globalEdgeOrientationPtr_();
1161 forAll(coupledPatch().edges(), edgeI)
1166 const edge&
e = coupledPatch().edges()[edgeI];
1176 masterEdgeVerts[edgeI]
1181 <<
"problem : my edge:" <<
e 1182 <<
" in master points:" << masterE
1183 <<
" v.s. masterEdgeVerts:" << masterEdgeVerts[edgeI]
1188 globalEdgeOrientation.set(edgeI, (stat == 1));
1193 globalEdgeOrientation.set(edgeI,
true);
1200 Pout<<
"globalMeshData::calcGlobalEdgeOrientation() :" 1201 <<
" finished calculating edge orientation." 1207 void Foam::globalMeshData::calcPointBoundaryFaces
1212 const polyBoundaryMesh&
bMesh = mesh_.boundaryMesh();
1213 const Map<label>& meshPointMap = coupledPatch().meshPointMap();
1219 for (
const polyPatch& pp :
bMesh)
1223 for (
const face&
f : pp)
1227 const auto iter = meshPointMap.cfind(
f[fp]);
1230 nPointFaces[iter.val()]++;
1240 pointBoundaryFaces.setSize(coupledPatch().
nPoints());
1241 forAll(nPointFaces, pointi)
1243 pointBoundaryFaces[pointi].setSize(nPointFaces[pointi]);
1252 const polyPatch& pp =
bMesh[patchi];
1258 const face&
f = pp[i];
1261 const auto iter = meshPointMap.cfind(
f[fp]);
1266 pp.start() + i - mesh_.nInternalFaces();
1267 pointBoundaryFaces[iter()][nPointFaces[iter()]++] =
1277 void Foam::globalMeshData::calcGlobalPointBoundaryFaces()
const 1281 Pout<<
"globalMeshData::calcGlobalPointBoundaryFaces() :" 1282 <<
" calculating coupled point to boundary face addressing." 1288 calcPointBoundaryFaces(pointBoundaryFaces);
1292 globalBoundaryFaceNumberingPtr_.reset
1294 new globalIndex(mesh_.nBoundaryFaces())
1296 globalIndex& globalIndices = globalBoundaryFaceNumberingPtr_();
1300 globalPointBoundaryFacesPtr_.reset
1304 labelListList& globalPointBoundaryFaces = globalPointBoundaryFacesPtr_();
1306 forAll(pointBoundaryFaces, pointi)
1308 const labelList& bFaces = pointBoundaryFaces[pointi];
1309 labelList& globalFaces = globalPointBoundaryFaces[pointi];
1310 globalFaces.
setSize(bFaces.size());
1313 globalFaces[i] = globalIndices.toGlobal(bFaces[i]);
1319 globalPointSlavesMap().distribute
1321 globalPointBoundaryFaces,
1330 globalPointTransformedSlaves();
1331 const globalIndexAndTransform& transforms = globalTransforms();
1335 List<labelPairList> transformedFaces(pointSlaves.size());
1338 forAll(pointSlaves, pointi)
1340 const labelList& slaves = pointSlaves[pointi];
1341 const labelList& transformedSlaves = pointTransformSlaves[pointi];
1343 if (slaves.size() > 0)
1345 labelList& myBFaces = globalPointBoundaryFaces[pointi];
1346 label sz = myBFaces.
size();
1352 n += globalPointBoundaryFaces[slaves[i]].size();
1355 myBFaces.setSize(sz+
n);
1360 globalPointBoundaryFaces[slaves[i]];
1365 for (
const label slave : slaveBFaces)
1367 if (!SubList<label>(myBFaces, sz).
found(slave))
1369 myBFaces[
n++] = slave;
1377 if (transformedSlaves.size() > 0)
1379 const labelList& untrafoFaces = globalPointBoundaryFaces[pointi];
1382 label sz = myBFaces.size();
1386 forAll(transformedSlaves, i)
1388 n += globalPointBoundaryFaces[transformedSlaves[i]].size();
1391 myBFaces.setSize(sz+
n);
1393 forAll(transformedSlaves, i)
1395 label transformI = globalPointSlavesMap().whichTransform
1397 transformedSlaves[i]
1401 globalPointBoundaryFaces[transformedSlaves[i]];
1403 for (
const label slave : slaveBFaces)
1406 if (!untrafoFaces.found(slave))
1408 label proci = globalIndices.whichProcID(slave);
1409 label facei = globalIndices.toLocal(proci, slave);
1411 myBFaces[
n++] = transforms.encode
1424 if (slaves.size() + transformedSlaves.size() == 0)
1426 globalPointBoundaryFaces[pointi].clear();
1433 globalPointTransformedBoundaryFacesPtr_.reset
1438 globalPointBoundaryFacesMapPtr_.reset
1443 globalPointBoundaryFaces,
1447 globalPointTransformedBoundaryFacesPtr_(),
1452 globalPointBoundaryFaces.setSize(coupledPatch().
nPoints());
1453 globalPointTransformedBoundaryFacesPtr_().setSize(coupledPatch().
nPoints());
1457 Pout<<
"globalMeshData::calcGlobalPointBoundaryFaces() :" 1458 <<
" coupled points:" << coupledPatch().nPoints()
1459 <<
" local boundary faces:" << globalIndices.localSize()
1460 <<
" additional coupled faces:" 1461 << globalPointBoundaryFacesMapPtr_().constructSize()
1462 - globalIndices.localSize()
1468 void Foam::globalMeshData::calcGlobalPointBoundaryCells()
const 1472 Pout<<
"globalMeshData::calcGlobalPointBoundaryCells() :" 1473 <<
" calculating coupled point to boundary cell addressing." 1481 Map<label> meshCellMap(4*coupledPatch().
nPoints());
1482 DynamicList<label> cellMap(meshCellMap.size());
1487 forAll(coupledPatch().meshPoints(), pointi)
1489 label meshPointi = coupledPatch().meshPoints()[pointi];
1490 const labelList& pCells = mesh_.pointCells(meshPointi);
1492 labelList& bCells = pointBoundaryCells[pointi];
1493 bCells.
setSize(pCells.size());
1497 const label celli = pCells[i];
1498 const auto fnd = meshCellMap.cfind(celli);
1506 meshCellMap.insert(celli, bCelli);
1507 cellMap.append(celli);
1515 boundaryCellsPtr_.reset(
new labelList(std::move(cellMap)));
1516 labelList& boundaryCells = boundaryCellsPtr_();
1522 globalBoundaryCellNumberingPtr_.reset
1524 new globalIndex(boundaryCells.size())
1526 globalIndex& globalIndices = globalBoundaryCellNumberingPtr_();
1529 globalPointBoundaryCellsPtr_.reset
1533 labelListList& globalPointBoundaryCells = globalPointBoundaryCellsPtr_();
1535 forAll(pointBoundaryCells, pointi)
1537 const labelList& pCells = pointBoundaryCells[pointi];
1538 labelList& globalCells = globalPointBoundaryCells[pointi];
1539 globalCells.
setSize(pCells.size());
1542 globalCells[i] = globalIndices.toGlobal(pCells[i]);
1548 globalPointSlavesMap().distribute
1550 globalPointBoundaryCells,
1558 globalPointTransformedSlaves();
1559 const globalIndexAndTransform& transforms = globalTransforms();
1561 List<labelPairList> transformedCells(pointSlaves.size());
1564 forAll(pointSlaves, pointi)
1566 const labelList& slaves = pointSlaves[pointi];
1567 const labelList& transformedSlaves = pointTransformSlaves[pointi];
1569 if (slaves.size() > 0)
1571 labelList& myBCells = globalPointBoundaryCells[pointi];
1572 label sz = myBCells.
size();
1578 n += globalPointBoundaryCells[slaves[i]].size();
1581 myBCells.setSize(sz+
n);
1586 globalPointBoundaryCells[slaves[i]];
1591 for (
const label slave : slaveBCells)
1593 if (!SubList<label>(myBCells, sz).
found(slave))
1595 myBCells[
n++] = slave;
1603 if (transformedSlaves.size() > 0)
1605 const labelList& untrafoCells = globalPointBoundaryCells[pointi];
1608 label sz = myBCells.size();
1612 forAll(transformedSlaves, i)
1614 n += globalPointBoundaryCells[transformedSlaves[i]].size();
1617 myBCells.setSize(sz+
n);
1619 forAll(transformedSlaves, i)
1621 label transformI = globalPointSlavesMap().whichTransform
1623 transformedSlaves[i]
1627 globalPointBoundaryCells[transformedSlaves[i]];
1629 for (
const label slave : slaveBCells)
1632 if (!untrafoCells.found(slave))
1634 label proci = globalIndices.whichProcID(slave);
1635 label celli = globalIndices.toLocal(proci, slave);
1636 myBCells[
n++] = transforms.encode
1648 if (slaves.size() + transformedSlaves.size() == 0)
1650 globalPointBoundaryCells[pointi].clear();
1657 globalPointTransformedBoundaryCellsPtr_.reset
1662 globalPointBoundaryCellsMapPtr_.reset
1667 globalPointBoundaryCells,
1671 globalPointTransformedBoundaryCellsPtr_(),
1676 globalPointBoundaryCells.setSize(coupledPatch().
nPoints());
1677 globalPointTransformedBoundaryCellsPtr_().setSize(coupledPatch().
nPoints());
1681 Pout<<
"globalMeshData::calcGlobalPointBoundaryCells() :" 1682 <<
" coupled points:" << coupledPatch().nPoints()
1683 <<
" local boundary cells:" << globalIndices.localSize()
1684 <<
" additional coupled cells:" 1685 << globalPointBoundaryCellsMapPtr_().constructSize()
1686 - globalIndices.localSize()
1692 void Foam::globalMeshData::calcGlobalCoPointSlaves()
const 1696 Pout<<
"globalMeshData::calcGlobalCoPointSlaves() :" 1697 <<
" calculating coupled master to collocated" 1698 <<
" slave point addressing." <<
endl;
1702 globalPoints globalData(mesh_, coupledPatch(),
true,
false);
1704 globalCoPointSlavesPtr_.reset
1708 std::move(globalData.pointPoints())
1711 globalCoPointSlavesMapPtr_.reset
1715 std::move(globalData.map())
1721 Pout<<
"globalMeshData::calcGlobalCoPointSlaves() :" 1722 <<
" finished calculating coupled master to collocated" 1723 <<
" slave point addressing." <<
endl;
1730 Foam::globalMeshData::globalMeshData(
const polyMesh&
mesh)
1738 processorTopology::
New<processorPolyPatch>
1740 mesh.boundaryMesh(),
1744 processorPatches_(),
1745 processorPatchIndices_(),
1746 processorPatchNeighbours_(),
1748 sharedPointLabelsPtr_(nullptr),
1749 sharedPointAddrPtr_(nullptr),
1750 sharedPointGlobalLabelsPtr_(nullptr),
1752 sharedEdgeLabelsPtr_(nullptr),
1753 sharedEdgeAddrPtr_(nullptr)
1769 nGlobalPoints_ = -1;
1770 sharedPointLabelsPtr_.clear();
1771 sharedPointAddrPtr_.clear();
1772 sharedPointGlobalLabelsPtr_.clear();
1776 sharedEdgeLabelsPtr_.clear();
1777 sharedEdgeAddrPtr_.clear();
1780 coupledPatchPtr_.clear();
1781 coupledPatchMeshEdgesPtr_.clear();
1782 coupledPatchMeshEdgeMapPtr_.clear();
1783 globalTransformsPtr_.clear();
1786 globalPointNumberingPtr_.clear();
1787 globalPointSlavesPtr_.clear();
1788 globalPointTransformedSlavesPtr_.clear();
1789 globalPointSlavesMapPtr_.clear();
1792 globalEdgeNumberingPtr_.clear();
1793 globalEdgeSlavesPtr_.clear();
1794 globalEdgeTransformedSlavesPtr_.clear();
1795 globalEdgeOrientationPtr_.clear();
1796 globalEdgeSlavesMapPtr_.clear();
1799 globalBoundaryFaceNumberingPtr_.clear();
1800 globalPointBoundaryFacesPtr_.clear();
1801 globalPointTransformedBoundaryFacesPtr_.clear();
1802 globalPointBoundaryFacesMapPtr_.clear();
1805 boundaryCellsPtr_.clear();
1806 globalBoundaryCellNumberingPtr_.clear();
1807 globalPointBoundaryCellsPtr_.clear();
1808 globalPointTransformedBoundaryCellsPtr_.clear();
1809 globalPointBoundaryCellsMapPtr_.clear();
1812 globalCoPointSlavesPtr_.clear();
1813 globalCoPointSlavesMapPtr_.clear();
1821 if (!sharedPointGlobalLabelsPtr_)
1823 sharedPointGlobalLabelsPtr_.reset
1825 new labelList(sharedPointLabels().size())
1827 labelList& sharedPointGlobalLabels = sharedPointGlobalLabelsPtr_();
1831 "pointProcAddressing",
1832 mesh_.facesInstance()/mesh_.meshSubDir,
1841 Pout<<
"globalMeshData::sharedPointGlobalLabels : " 1842 <<
"Reading pointProcAddressing" <<
endl;
1854 sharedPointGlobalLabels[i] = pointProcAddressing[pointi];
1859 Pout<<
"globalMeshData::sharedPointGlobalLabels :" 1860 <<
" Setting pointProcAddressing to -1" <<
endl;
1862 sharedPointGlobalLabels = -1;
1866 return *sharedPointGlobalLabelsPtr_;
1876 const labelList& pointAddr = sharedPointAddr();
1885 label sharedPointi = pointAddr[i];
1887 sharedPoints[sharedPointi] = mesh_.points()[
pointLabels[i]];
1897 fromProc >> nbrSharedPointAddr >> nbrSharedPoints;
1899 forAll(nbrSharedPointAddr, i)
1901 label sharedPointi = nbrSharedPointAddr[i];
1903 sharedPoints[sharedPointi] = nbrSharedPoints[i];
1927 return sharedPoints;
1934 pointField sharedPoints(mesh_.points(), sharedPointLabels());
1940 scalar tolDim = matchTol_ * mesh_.bounds().mag();
1951 return sharedPoints;
1957 if (nGlobalPoints_ == -1)
1961 return nGlobalPoints_;
1967 if (!sharedPointLabelsPtr_)
1971 return *sharedPointLabelsPtr_;
1977 if (!sharedPointAddrPtr_)
1981 return *sharedPointAddrPtr_;
1987 if (nGlobalEdges_ == -1)
1991 return nGlobalEdges_;
1997 if (!sharedEdgeLabelsPtr_)
2001 return *sharedEdgeLabelsPtr_;
2007 if (!sharedEdgeAddrPtr_)
2011 return *sharedEdgeAddrPtr_;
2017 if (!coupledPatchPtr_)
2019 const polyBoundaryMesh&
bMesh = mesh_.boundaryMesh();
2025 const polyPatch& pp =
bMesh[patchi];
2029 nCoupled += pp.size();
2037 const polyPatch& pp =
bMesh[patchi];
2041 label facei = pp.start();
2045 coupledFaces[nCoupled++] = facei++;
2050 coupledPatchPtr_.reset
2065 Pout<<
"globalMeshData::coupledPatch() :" 2066 <<
" constructed coupled faces patch:" 2067 <<
" faces:" << coupledPatchPtr_().size()
2068 <<
" points:" << coupledPatchPtr_().nPoints()
2072 return *coupledPatchPtr_;
2078 if (!coupledPatchMeshEdgesPtr_)
2080 coupledPatchMeshEdgesPtr_.reset
2084 coupledPatch().meshEdges
2092 return *coupledPatchMeshEdgesPtr_;
2099 if (!coupledPatchMeshEdgeMapPtr_)
2103 coupledPatchMeshEdgeMapPtr_.reset(
new Map<label>(2*
me.size()));
2104 Map<label>& em = coupledPatchMeshEdgeMapPtr_();
2111 return *coupledPatchMeshEdgeMapPtr_;
2117 if (!globalPointNumberingPtr_)
2119 globalPointNumberingPtr_.
reset 2121 new globalIndex(coupledPatch().
nPoints())
2124 return *globalPointNumberingPtr_;
2131 if (!globalTransformsPtr_)
2135 return *globalTransformsPtr_;
2141 if (!globalPointSlavesPtr_)
2143 calcGlobalPointSlaves();
2145 return *globalPointSlavesPtr_;
2152 if (!globalPointTransformedSlavesPtr_)
2154 calcGlobalPointSlaves();
2156 return *globalPointTransformedSlavesPtr_;
2162 if (!globalPointSlavesMapPtr_)
2164 calcGlobalPointSlaves();
2166 return *globalPointSlavesMapPtr_;
2172 if (!globalEdgeNumberingPtr_)
2174 globalEdgeNumberingPtr_.
reset 2179 return *globalEdgeNumberingPtr_;
2185 if (!globalEdgeSlavesPtr_)
2187 calcGlobalEdgeSlaves();
2189 return *globalEdgeSlavesPtr_;
2196 if (!globalEdgeTransformedSlavesPtr_)
2198 calcGlobalEdgeSlaves();
2200 return *globalEdgeTransformedSlavesPtr_;
2206 if (!globalEdgeOrientationPtr_)
2208 calcGlobalEdgeOrientation();
2210 return *globalEdgeOrientationPtr_;
2216 if (!globalEdgeSlavesMapPtr_)
2218 calcGlobalEdgeSlaves();
2220 return *globalEdgeSlavesMapPtr_;
2227 if (!globalBoundaryFaceNumberingPtr_)
2229 calcGlobalPointBoundaryFaces();
2231 return *globalBoundaryFaceNumberingPtr_;
2238 if (!globalPointBoundaryFacesPtr_)
2240 calcGlobalPointBoundaryFaces();
2242 return *globalPointBoundaryFacesPtr_;
2249 if (!globalPointTransformedBoundaryFacesPtr_)
2251 calcGlobalPointBoundaryFaces();
2253 return *globalPointTransformedBoundaryFacesPtr_;
2260 if (!globalPointBoundaryFacesMapPtr_)
2262 calcGlobalPointBoundaryFaces();
2264 return *globalPointBoundaryFacesMapPtr_;
2270 if (!boundaryCellsPtr_)
2272 calcGlobalPointBoundaryCells();
2274 return *boundaryCellsPtr_;
2281 if (!globalBoundaryCellNumberingPtr_)
2283 calcGlobalPointBoundaryCells();
2285 return *globalBoundaryCellNumberingPtr_;
2292 if (!globalPointBoundaryCellsPtr_)
2294 calcGlobalPointBoundaryCells();
2296 return *globalPointBoundaryCellsPtr_;
2303 if (!globalPointTransformedBoundaryCellsPtr_)
2305 calcGlobalPointBoundaryCells();
2307 return *globalPointTransformedBoundaryCellsPtr_;
2314 if (!globalPointBoundaryCellsMapPtr_)
2316 calcGlobalPointBoundaryCells();
2318 return *globalPointBoundaryCellsMapPtr_;
2324 if (!globalCoPointSlavesPtr_)
2326 calcGlobalCoPointSlaves();
2328 return *globalCoPointSlavesPtr_;
2334 if (!globalCoPointSlavesMapPtr_)
2336 calcGlobalCoPointSlaves();
2338 return *globalCoPointSlavesMapPtr_;
2349 const globalIndex& globalCoupledPoints = globalPointNumbering();
2352 const mapDistribute& pointSlavesMap = globalCoPointSlavesMap();
2360 labelList masterGlobalPoint(cpp.nPoints(), -1);
2361 forAll(masterGlobalPoint, pointi)
2363 const labelList& slavePoints = pointSlaves[pointi];
2364 if (slavePoints.size() > 0)
2366 masterGlobalPoint[pointi] = globalCoupledPoints.toGlobal(pointi);
2383 bitSet isMaster(mesh_.nPoints(),
true);
2384 forAll(pointSlaves, pointi)
2386 if (masterGlobalPoint[pointi] == -1)
2393 masterGlobalPoint[pointi]
2394 == globalCoupledPoints.toGlobal(pointi)
2403 isMaster.unset(cpp.meshPoints()[pointi]);
2407 label myUniquePoints = mesh_.nPoints() - cpp.nPoints() + nMaster;
2417 autoPtr<globalIndex> globalPointsPtr(
new globalIndex(myUniquePoints));
2421 pointToGlobal.setSize(mesh_.nPoints());
2423 uniquePoints.setSize(myUniquePoints);
2426 forAll(isMaster, meshPointi)
2428 if (isMaster[meshPointi])
2430 pointToGlobal[meshPointi] = globalPointsPtr().toGlobal(nMaster);
2431 uniquePoints[nMaster] = meshPointi;
2439 labelList masterToGlobal(pointSlavesMap.constructSize(), -1);
2441 forAll(pointSlaves, pointi)
2443 const labelList& slaves = pointSlaves[pointi];
2445 if (slaves.size() > 0)
2448 label meshPointi = cpp.meshPoints()[pointi];
2449 masterToGlobal[pointi] = pointToGlobal[meshPointi];
2452 masterToGlobal[slaves[i]] = masterToGlobal[pointi];
2458 pointSlavesMap.reverseDistribute(cpp.nPoints(), masterToGlobal);
2461 forAll(pointSlaves, pointi)
2463 label meshPointi = cpp.meshPoints()[pointi];
2465 if (!isMaster[meshPointi])
2467 pointToGlobal[meshPointi] = masterToGlobal[pointi];
2472 return globalPointsPtr;
2486 const mapDistribute& pointSlavesMap = globalCoPointSlavesMap();
2504 const globalIndex globalPPoints(meshPoints.size());
2506 labelList patchToCoupled(meshPoints.size(), -1);
2508 labelList coupledToGlobalPatch(pointSlavesMap.constructSize(), -1);
2511 forAll(meshPoints, patchPointi)
2513 label meshPointi = meshPoints[patchPointi];
2515 const auto iter = cpp.meshPointMap().cfind(meshPointi);
2519 patchToCoupled[patchPointi] = iter();
2520 coupledToGlobalPatch[iter()] = globalPPoints.toGlobal(patchPointi);
2538 pointSlavesMap.distribute(coupledToGlobalPatch);
2539 forAll(pointSlaves, coupledPointi)
2541 const labelList& slaves = pointSlaves[coupledPointi];
2543 if (slaves.size() > 0)
2547 if (coupledToGlobalPatch[coupledPointi] != -1)
2550 masterI = coupledToGlobalPatch[coupledPointi];
2557 label slavePp = coupledToGlobalPatch[slaves[i]];
2558 if (slavePp != -1 && slavePp < masterI)
2568 coupledToGlobalPatch[coupledPointi] = masterI;
2571 coupledToGlobalPatch[slaves[i]] = masterI;
2576 pointSlavesMap.reverseDistribute(cpp.nPoints(), coupledToGlobalPatch);
2586 forAll(meshPoints, patchPointi)
2588 if (patchToCoupled[patchPointi] == -1)
2594 label coupledPointi = patchToCoupled[patchPointi];
2597 globalPPoints.toGlobal(patchPointi)
2598 == coupledToGlobalPatch[coupledPointi]
2607 autoPtr<globalIndex> globalPointsPtr(
new globalIndex(nMasters));
2619 pointToGlobal.setSize(meshPoints.size());
2621 uniqueMeshPoints.setSize(nMasters);
2625 labelList globalMaster(cpp.nPoints(), -1);
2628 forAll(meshPoints, patchPointi)
2630 if (patchToCoupled[patchPointi] == -1)
2632 uniqueMeshPoints[nMasters++] = meshPoints[patchPointi];
2636 label coupledPointi = patchToCoupled[patchPointi];
2639 globalPPoints.toGlobal(patchPointi)
2640 == coupledToGlobalPatch[coupledPointi]
2643 globalMaster[coupledPointi] =
2644 globalPointsPtr().toGlobal(nMasters);
2645 uniqueMeshPoints[nMasters++] = meshPoints[patchPointi];
2665 forAll(meshPoints, patchPointi)
2667 if (patchToCoupled[patchPointi] == -1)
2669 pointToGlobal[patchPointi] = globalPointsPtr().toGlobal(nMasters++);
2673 label coupledPointi = patchToCoupled[patchPointi];
2674 pointToGlobal[patchPointi] = globalMaster[coupledPointi];
2678 globalPPoints.toGlobal(patchPointi)
2679 == coupledToGlobalPatch[coupledPointi]
2687 return globalPointsPtr;
2708 scalar tolDim = matchTol_ * mesh_.bounds().mag();
2712 Pout<<
"globalMeshData : merge dist:" << tolDim <<
endl;
2739 Pout<<
"globalMeshData : nTotalFaces:" << nTotalFaces_ <<
endl;
2752 Pout<<
"globalMeshData : nTotalCells:" << nTotalCells_ <<
endl;
2768 Pout<<
"globalMeshData : nTotalPoints:" << nTotalPoints_ <<
endl;
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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.
List< labelList > labelListList
A List of labelList.
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...
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.
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
const mapDistribute & globalPointSlavesMap() const
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.
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)
Number of this process (starting from masterNo() = 0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
static label worldComm
Default world communicator (all processors). May differ from globalComm 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...
static label allocateCommunicator(const label parent, const labelUList &subRanks, const bool doPstream=true)
Allocate a new communicator with subRanks of parent communicator.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
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 processes in communicator.
#define forAll(list, i)
Loop across all elements in list.
const labelList & boundaryCells() const
From boundary cell to mesh cell.
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) 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.
List< edge > edgeList
A List of edges.
static int compare(const Pair< label > &a, const Pair< label > &b)
Compare Pairs.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
void sort(UList< T > &list)
Sort the list.
static constexpr int masterNo() noexcept
Process index of the master (always 0)
label size() const noexcept
The number of elements 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...
List< labelPair > labelPairList
List of labelPairs.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
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)
Am I the master rank.
void updateMesh()
Change global mesh data given a topological change. Does a.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
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.
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
const labelList & sharedEdgeLabels() const
Return indices of local edges that are globally shared.
forAllConstIters(mixture.phases(), phase)
const labelListList & globalCoPointSlaves() const
A HashTable to objects of type <T> with a label key.
const labelListList & globalEdgeTransformedSlaves() const
static constexpr const zero Zero
Global zero (0)
const globalIndex & globalBoundaryFaceNumbering() const
Numbering of boundary faces is face-mesh.nInternalFaces()