ENH: extend globalIndex toGlobal methods

- now applicable to labelLists.

Note:
  in some situations it will be more efficient to use
  Foam::identity() directly. Eg,

     globalIndex globalCells(mesh.nCells());
     ...
     labelList cellIds
     (
         identity(globalCells.localSize(), globalCells.localStart())
     );
This commit is contained in:
Mark Olesen
2018-11-05 16:23:33 +01:00
parent dfb652bcac
commit f5baa9a583
16 changed files with 127 additions and 136 deletions

View File

@ -524,24 +524,19 @@ void Foam::meshToMesh::calculate(const word& methodName, const bool normalise)
calcAddressing(methodName, srcRegion_, newTgt);
// per source cell the target cell address in newTgt mesh
forAll(srcToTgtCellAddr_, i)
// Per source cell the target cell address in newTgt mesh
for (labelList& addressing : srcToTgtCellAddr_)
{
labelList& addressing = srcToTgtCellAddr_[i];
forAll(addressing, addrI)
for (label& addr : addressing)
{
addressing[addrI] = newTgtCellIDs[addressing[addrI]];
addr = newTgtCellIDs[addr];
}
}
// convert target addresses in newTgtMesh into global cell numbering
forAll(tgtToSrcCellAddr_, i)
// Convert target addresses in newTgtMesh into global cell numbering
for (labelList& addressing : tgtToSrcCellAddr_)
{
labelList& addressing = tgtToSrcCellAddr_[i];
forAll(addressing, addrI)
{
addressing[addrI] = globalSrcCells.toGlobal(addressing[addrI]);
}
globalSrcCells.inplaceToGlobal(addressing);
}
// set up as a reverse distribute

View File

@ -455,18 +455,17 @@ void Foam::meshToMesh::distributeCells
}
// tgt cells into global numbering
labelList globalElems(sendElems.size());
forAll(sendElems, i)
labelList globalElems(globalI.toGlobal(sendElems));
if (debug > 1)
{
if (debug > 1)
forAll(sendElems, i)
{
Pout<< "tgtProc:" << Pstream::myProcNo()
<< " sending tgt cell " << sendElems[i]
<< "[" << globalI.toGlobal(sendElems[i]) << "]"
<< "[" << globalElems[i] << "]"
<< " to srcProc " << domain << endl;
}
globalElems[i] = globalI.toGlobal(sendElems[i]);
}
// pass data