ENH: sum reduction of nPoints/nFaces/nCells in a single call (globalMeshData)

STYLE: use labelRange instead of identity(...) for communicator
This commit is contained in:
Mark Olesen
2023-06-12 15:21:20 +02:00
parent f096c34a80
commit e92975075a
3 changed files with 21 additions and 46 deletions

View File

@ -152,7 +152,7 @@ Foam::procFacesGAMGProcAgglomeration::processorAgglomeration
UPstream::communicator singleCellMeshComm
(
mesh.comm(),
labelList(Foam::one{}, 0) // only processor 0
labelRange(1) // Processor 0 only
);
scalarField faceWeights;
@ -197,7 +197,6 @@ Foam::procFacesGAMGProcAgglomeration::processorAgglomeration
}
Pstream::broadcast(fineToCoarse, mesh.comm());
singleCellMeshComm.reset();
return tfineToCoarse;
}

View File

@ -2504,8 +2504,8 @@ Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints
const globalIndex globalPPoints(meshPoints.size());
labelList patchToCoupled(meshPoints.size(), -1);
label nCoupled = 0;
labelList coupledToGlobalPatch(pointSlavesMap.constructSize(), -1);
//label nCoupled = 0;
// Note: loop over patch since usually smaller
forAll(meshPoints, patchPointi)
@ -2518,7 +2518,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints
{
patchToCoupled[patchPointi] = iter();
coupledToGlobalPatch[iter()] = globalPPoints.toGlobal(patchPointi);
nCoupled++;
//++nCoupled;
}
}
@ -2718,55 +2718,31 @@ void Foam::globalMeshData::updateMesh()
UPstream::communicator dupComm
(
UPstream::worldComm,
identity(UPstream::nProcs(UPstream::worldComm))
labelRange(UPstream::nProcs(UPstream::worldComm))
);
const label comm = dupComm.comm();
const label oldWarnComm = UPstream::commWarn(comm);
FixedList<label, 3> totals;
// Total number of faces.
nTotalFaces_ = returnReduce
(
mesh_.nFaces(),
sumOp<label>(),
UPstream::msgType(),
comm
);
totals[0] = mesh_.nPoints();
totals[1] = mesh_.nFaces();
totals[2] = mesh_.nCells();
if (debug)
{
Pout<< "globalMeshData : nTotalFaces:" << nTotalFaces_ << endl;
}
reduce(totals, sumOp<label>(), UPstream::msgType(), comm);
nTotalCells_ = returnReduce
(
mesh_.nCells(),
sumOp<label>(),
UPstream::msgType(),
comm
);
if (debug)
{
Pout<< "globalMeshData : nTotalCells:" << nTotalCells_ << endl;
}
nTotalPoints_ = returnReduce
(
mesh_.nPoints(),
sumOp<label>(),
UPstream::msgType(),
comm
);
nTotalPoints_ = totals[0];
nTotalFaces_ = totals[1];
nTotalCells_ = totals[2];
// Restore communicator settings
UPstream::commWarn(oldWarnComm);
dupComm.reset();
if (debug)
{
Pout<< "globalMeshData : nTotalPoints:" << nTotalPoints_ << endl;
Info<< "globalMeshData : Total points/faces/cells : "
<< totals << endl;
}
}

View File

@ -348,22 +348,22 @@ public:
return mesh_;
}
//- Does the mesh contain processor patches? (also valid when
// not running parallel)
bool parallel() const
//- Does the mesh contain processor patches?
//- (also valid when not running parallel)
bool parallel() const noexcept
{
return !processorPatches_.empty();
}
//- Return total number of points in decomposed mesh. Not
// compensated for duplicate points!
//- Return total number of points in decomposed mesh.
//- Not compensated for duplicate points!
label nTotalPoints() const noexcept
{
return nTotalPoints_;
}
//- Return total number of faces in decomposed mesh. Not
// compensated for duplicate faces!
//- Return total number of faces in decomposed mesh.
//- Not compensated for duplicate faces!
label nTotalFaces() const noexcept
{
return nTotalFaces_;