ENH: use mpi gather for list values in a few places

- avoid gatherList/scatterList when value are only need on master
This commit is contained in:
Mark Olesen
2022-02-25 17:42:57 +01:00
committed by Andrew Heather
parent c086f22298
commit af8161925b
9 changed files with 180 additions and 199 deletions

View File

@ -261,15 +261,17 @@ boolList haveFacesFile(const fileName& meshPath)
{
const fileName facesPath(meshPath/"faces");
Info<< "Checking for mesh in " << facesPath << nl << endl;
boolList haveMesh(Pstream::nProcs(), false);
haveMesh[Pstream::myProcNo()] = fileHandler().isFile
boolList haveMesh
(
fileHandler().filePath(facesPath)
UPstream::listGatherValues<bool>
(
fileHandler().isFile(fileHandler().filePath(facesPath))
)
);
Pstream::gatherList(haveMesh);
Pstream::scatterList(haveMesh);
Info<< "Per processor mesh availability:" << nl
<< " " << flatOutput(haveMesh) << nl << endl;
Pstream::broadcast(haveMesh);
return haveMesh;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -63,41 +63,38 @@ void writeProcStats
{
// Determine surface bounding boxes, faces, points
List<treeBoundBox> surfBb(Pstream::nProcs());
surfBb[Pstream::myProcNo()] = treeBoundBox(s.points());
Pstream::gatherList(surfBb);
labelList nPoints(UPstream::listGatherValues<label>(s.points().size()));
labelList nFaces(UPstream::listGatherValues<label>(s.size()));
if (Pstream::master())
{
surfBb[Pstream::myProcNo()] = treeBoundBox(s.points());
Pstream::gatherList(surfBb);
Pstream::scatterList(surfBb);
}
labelList nPoints(Pstream::nProcs());
nPoints[Pstream::myProcNo()] = s.points().size();
Pstream::gatherList(nPoints);
Pstream::scatterList(nPoints);
labelList nFaces(Pstream::nProcs());
nFaces[Pstream::myProcNo()] = s.size();
Pstream::gatherList(nFaces);
Pstream::scatterList(nFaces);
forAll(surfBb, proci)
{
Info<< "processor" << proci << nl;
const List<treeBoundBox>& bbs = meshBb[proci];
if (bbs.size())
forAll(surfBb, proci)
{
Info<< "\tMesh bounds : " << bbs[0] << nl;
for (label i = 1; i < bbs.size(); i++)
Info<< "processor" << proci << nl;
const List<treeBoundBox>& bbs = meshBb[proci];
forAll(bbs, i)
{
Info<< "\t " << bbs[i]<< nl;
if (!i)
{
Info<< "\tMesh bounds : ";
}
else
{
Info<< "\t ";
}
Info<< bbs[i] << nl;
}
Info<< "\tSurface bounding box : " << surfBb[proci] << nl
<< "\tTriangles : " << nFaces[proci] << nl
<< "\tVertices : " << nPoints[proci]
<< endl;
}
Info<< "\tSurface bounding box : " << surfBb[proci] << nl
<< "\tTriangles : " << nFaces[proci] << nl
<< "\tVertices : " << nPoints[proci]
<< endl;
Info<< endl;
}
Info<< endl;
}