mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
committed by
Andrew Heather
parent
c086f22298
commit
af8161925b
@ -3,12 +3,14 @@ phaseSystem = $(LIB_SRC)/phaseSystemModels/multiphaseInter
|
||||
EXE_INC = \
|
||||
-I${phaseSystem}/phasesSystem/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfileFormats \
|
||||
-lmeshTools \
|
||||
-llagrangian \
|
||||
-lradiationModels \
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,11 +31,12 @@ License
|
||||
#include "absorptionEmissionModel.H"
|
||||
#include "scatterModel.H"
|
||||
#include "constants.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "unitConversion.H"
|
||||
#include "interpolationCell.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
#include "Random.H"
|
||||
#include "OBJstream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
using namespace Foam::constant;
|
||||
|
||||
@ -679,44 +680,28 @@ void Foam::radiation::laserDTRM::calculate()
|
||||
Info<< "Final number of particles..."
|
||||
<< returnReduce(DTRMCloud_.size(), sumOp<label>()) << endl;
|
||||
|
||||
OFstream osRef(type() + ":particlePath.obj");
|
||||
label vertI = 0;
|
||||
|
||||
List<pointField> positions(Pstream::nProcs());
|
||||
List<pointField> p0(Pstream::nProcs());
|
||||
|
||||
DynamicList<point> positionsMyProc;
|
||||
DynamicList<point> p0MyProc;
|
||||
|
||||
for (const DTRMParticle& p : DTRMCloud_)
|
||||
pointField lines(2*DTRMCloud_.size());
|
||||
{
|
||||
positionsMyProc.append(p.position());
|
||||
p0MyProc.append(p.p0());
|
||||
}
|
||||
|
||||
positions[Pstream::myProcNo()].transfer(positionsMyProc);
|
||||
p0[Pstream::myProcNo()].transfer(p0MyProc);
|
||||
|
||||
Pstream::gatherList(positions);
|
||||
Pstream::scatterList(positions);
|
||||
Pstream::gatherList(p0);
|
||||
Pstream::scatterList(p0);
|
||||
|
||||
for (const int proci : Pstream::allProcs())
|
||||
{
|
||||
const pointField& pos = positions[proci];
|
||||
const pointField& pfinal = p0[proci];
|
||||
forAll(pos, i)
|
||||
label i = 0;
|
||||
for (const DTRMParticle& p : DTRMCloud_)
|
||||
{
|
||||
meshTools::writeOBJ(osRef, pos[i]);
|
||||
vertI++;
|
||||
meshTools::writeOBJ(osRef, pfinal[i]);
|
||||
vertI++;
|
||||
osRef << "l " << vertI-1 << ' ' << vertI << nl;
|
||||
lines[i] = p.position();
|
||||
lines[i+1] = p.p0();
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
osRef.flush();
|
||||
globalIndex::gatherInplaceOp(lines);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
OBJstream os(type() + ":particlePath.obj");
|
||||
|
||||
for (label pointi = 0; pointi < lines.size(); pointi += 2)
|
||||
{
|
||||
os.write(linePointRef(lines[pointi], lines[pointi+1]));
|
||||
}
|
||||
}
|
||||
|
||||
scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V());
|
||||
Info << "Total energy absorbed [W]: " << totalQ << endl;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user