63void 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];
126void 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;
246void 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++);
288void 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()
503void 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())
540void 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
644void 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
801Foam::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
859void 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],
979 globalIndexAndTransform::less(transforms)
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()
1079void 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."
1207void 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()]++] =
1277void 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()
1468void 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()
1692void 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;
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_)
2029 nCoupled += pp.size();
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_)
2101 const labelList& me = coupledPatchMeshEdges();
2103 coupledPatchMeshEdgeMapPtr_.reset(
new Map<label>(2*me.size()));
2104 Map<label>& em = coupledPatchMeshEdgeMapPtr_();
2111 return *coupledPatchMeshEdgeMapPtr_;
2117 if (!globalPointNumberingPtr_)
2119 globalPointNumberingPtr_.
reset
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();
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)
2407 label myUniquePoints = mesh_.nPoints() - cpp.
nPoints() + nMaster;
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;
2441 forAll(pointSlaves, pointi)
2443 const labelList& slaves = pointSlaves[pointi];
2445 if (slaves.
size() > 0)
2449 masterToGlobal[pointi] = pointToGlobal[meshPointi];
2452 masterToGlobal[slaves[i]] = masterToGlobal[pointi];
2461 forAll(pointSlaves, pointi)
2465 if (!isMaster[meshPointi])
2467 pointToGlobal[meshPointi] = masterToGlobal[pointi];
2472 return globalPointsPtr;
2486 const mapDistribute& pointSlavesMap = globalCoPointSlavesMap();
2511 forAll(meshPoints, patchPointi)
2513 label meshPointi = meshPoints[patchPointi];
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;
2586 forAll(meshPoints, patchPointi)
2588 if (patchToCoupled[patchPointi] == -1)
2594 label coupledPointi = patchToCoupled[patchPointi];
2597 globalPPoints.
toGlobal(patchPointi)
2598 == coupledToGlobalPatch[coupledPointi]
2621 uniqueMeshPoints.
setSize(nMasters);
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_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
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 (uses typeFilePath to find file) and check its info.
Input inter-processor communications stream.
A List with indirect addressing.
void setSize(const label n)
Alias for resize()
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void resize(const label len)
Adjust allocated size of list.
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)
Compare Pairs.
A list of faces which address into the list of points.
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.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
UPstream::rangeType subProcs() const noexcept
Range of sub-processes indices associated with PstreamBuffers.
static void combineAllGather(const List< commsStruct > &comms, T &value, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
static void broadcast(Type &value, const label comm=UPstream::worldComm)
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
Inter-processor communications stream.
@ nonBlocking
"nonBlocking"
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
static int & msgType() noexcept
Message tag of standard messages.
static constexpr int masterNo() noexcept
Process index of the master (always 0)
static label worldComm
Default communicator (all processors)
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
static bool & parRun() noexcept
Test if this a parallel run.
label size() const noexcept
The number of elements 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)
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
void reset(const dimensionSet &ds)
Copy assign the exponents from the dimensionSet.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
void reset(const label localSize, const label comm=UPstream::worldComm, const bool parallel=UPstream::parRun())
label toGlobal(const label i) const
From local to global index.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const mapDistribute & globalCoPointSlavesMap() const
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points.
const bitSet & globalEdgeOrientation() const
Is my edge same orientation as master edge.
const labelListList & globalPointTransformedBoundaryCells() const
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.
pointField geometricSharedPoints() const
Like sharedPoints but keeps cyclic points separate.
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()
label nGlobalEdges() const
Return number of globally shared edges. Demand-driven.
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.
const labelListList & globalCoPointSlaves() const
pointField sharedPoints() const
Collect coordinates of shared points on all processors.
const globalIndex & globalBoundaryCellNumbering() const
Numbering of boundary cells is according to boundaryCells()
const labelListList & globalPointSlaves() const
const globalIndex & globalEdgeNumbering() const
const globalIndexAndTransform & globalTransforms() const
Global transforms numbering.
const labelList & sharedEdgeLabels() const
Return indices of local edges that are globally shared.
const labelListList & globalPointTransformedSlaves() const
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
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.
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 data using default commsType.
void operator()(labelPair &x, const labelPair &y) const
void movePoints()
Update for new mesh geometry.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
A patch is a list of labels that address the faces in the global face list.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
label start() const
Return start label of this patch in the polyMesh face list.
int myProcNo() const noexcept
Return processor number.
Neighbour processor patch.
Determines/represents processor-processor connection. After instantiation contains the processor-proc...
splitCell * master() const
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelList nEdges(UPstream::listGatherValues< label >(aMesh.nEdges()))
Geometric merging of points. See below.
Pair< label > labelPair
A pair of labels.
List< labelPair > labelPairList
List of labelPairs.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< labelList > labelListList
A List of labelList.
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)
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points)
static constexpr const zero Zero
Global zero (0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
List< edge > edgeList
A List of edges.
label inplaceMergePoints(PointList &points, const scalar mergeTol, const bool verbose, labelList &pointToUnique)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.