mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: distributedTriSurfaceMesh: non-parallel running clip against local proc
This commit is contained in:
@ -365,9 +365,6 @@ void Foam::distributedTriSurfaceMesh::findLine
|
|||||||
{
|
{
|
||||||
const indexedOctree<treeDataTriSurface>& octree = tree();
|
const indexedOctree<treeDataTriSurface>& octree = tree();
|
||||||
|
|
||||||
// Important:force synchronised construction of indexing
|
|
||||||
const globalIndex& triIndexer = globalTris();
|
|
||||||
|
|
||||||
// Initialise
|
// Initialise
|
||||||
info.setSize(start.size());
|
info.setSize(start.size());
|
||||||
forAll(info, i)
|
forAll(info, i)
|
||||||
@ -375,15 +372,9 @@ void Foam::distributedTriSurfaceMesh::findLine
|
|||||||
info[i].setMiss();
|
info[i].setMiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Pstream::parRun())
|
||||||
// Do any local queries
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
label nLocal = 0;
|
|
||||||
|
|
||||||
forAll(start, i)
|
|
||||||
{
|
{
|
||||||
if (isLocal(procBb_[Pstream::myProcNo()], start[i], end[i]))
|
forAll(start, i)
|
||||||
{
|
{
|
||||||
if (nearestIntersection)
|
if (nearestIntersection)
|
||||||
{
|
{
|
||||||
@ -393,127 +384,150 @@ void Foam::distributedTriSurfaceMesh::findLine
|
|||||||
{
|
{
|
||||||
info[i] = octree.findLineAny(start[i], end[i]);
|
info[i] = octree.findLineAny(start[i], end[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info[i].hit())
|
|
||||||
{
|
|
||||||
info[i].setIndex(triIndexer.toGlobal(info[i].index()));
|
|
||||||
}
|
|
||||||
nLocal++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Important:force synchronised construction of indexing
|
||||||
|
const globalIndex& triIndexer = globalTris();
|
||||||
|
|
||||||
|
|
||||||
if
|
// Do any local queries
|
||||||
(
|
// ~~~~~~~~~~~~~~~~~~~~
|
||||||
Pstream::parRun()
|
|
||||||
&& (
|
label nLocal = 0;
|
||||||
|
|
||||||
|
forAll(start, i)
|
||||||
|
{
|
||||||
|
if (isLocal(procBb_[Pstream::myProcNo()], start[i], end[i]))
|
||||||
|
{
|
||||||
|
if (nearestIntersection)
|
||||||
|
{
|
||||||
|
info[i] = octree.findLine(start[i], end[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info[i] = octree.findLineAny(start[i], end[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info[i].hit())
|
||||||
|
{
|
||||||
|
info[i].setIndex(triIndexer.toGlobal(info[i].index()));
|
||||||
|
}
|
||||||
|
nLocal++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
returnReduce(nLocal, sumOp<label>())
|
returnReduce(nLocal, sumOp<label>())
|
||||||
< returnReduce(start.size(), sumOp<label>())
|
< returnReduce(start.size(), sumOp<label>())
|
||||||
)
|
)
|
||||||
)
|
{
|
||||||
{
|
// Not all can be resolved locally. Build segments and map,
|
||||||
// Not all can be resolved locally. Build segments and map, send over
|
// send over segments, do intersections, send back and merge.
|
||||||
// segments, do intersections, send back and merge.
|
|
||||||
|
|
||||||
|
|
||||||
// Construct queries (segments)
|
// Construct queries (segments)
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
// Segments to test
|
// Segments to test
|
||||||
List<segment> allSegments(start.size());
|
List<segment> allSegments(start.size());
|
||||||
// Original index of segment
|
// Original index of segment
|
||||||
labelList allSegmentMap(start.size());
|
labelList allSegmentMap(start.size());
|
||||||
|
|
||||||
const autoPtr<mapDistribute> mapPtr
|
const autoPtr<mapDistribute> mapPtr
|
||||||
(
|
|
||||||
distributeSegments
|
|
||||||
(
|
(
|
||||||
start,
|
distributeSegments
|
||||||
end,
|
|
||||||
allSegments,
|
|
||||||
allSegmentMap
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const mapDistribute& map = mapPtr();
|
|
||||||
|
|
||||||
label nOldAllSegments = allSegments.size();
|
|
||||||
|
|
||||||
|
|
||||||
// Exchange the segments
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
map.distribute(allSegments);
|
|
||||||
|
|
||||||
|
|
||||||
// Do tests I need to do
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
// Intersections
|
|
||||||
List<pointIndexHit> intersections(allSegments.size());
|
|
||||||
|
|
||||||
forAll(allSegments, i)
|
|
||||||
{
|
|
||||||
if (nearestIntersection)
|
|
||||||
{
|
|
||||||
intersections[i] = octree.findLine
|
|
||||||
(
|
(
|
||||||
allSegments[i].first(),
|
start,
|
||||||
allSegments[i].second()
|
end,
|
||||||
);
|
allSegments,
|
||||||
}
|
allSegmentMap
|
||||||
else
|
)
|
||||||
|
);
|
||||||
|
const mapDistribute& map = mapPtr();
|
||||||
|
|
||||||
|
label nOldAllSegments = allSegments.size();
|
||||||
|
|
||||||
|
|
||||||
|
// Exchange the segments
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
map.distribute(allSegments);
|
||||||
|
|
||||||
|
|
||||||
|
// Do tests I need to do
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
// Intersections
|
||||||
|
List<pointIndexHit> intersections(allSegments.size());
|
||||||
|
|
||||||
|
forAll(allSegments, i)
|
||||||
{
|
{
|
||||||
intersections[i] = octree.findLineAny
|
if (nearestIntersection)
|
||||||
(
|
|
||||||
allSegments[i].first(),
|
|
||||||
allSegments[i].second()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert triangle index to global numbering
|
|
||||||
if (intersections[i].hit())
|
|
||||||
{
|
|
||||||
intersections[i].setIndex
|
|
||||||
(
|
|
||||||
triIndexer.toGlobal(intersections[i].index())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Exchange the intersections (opposite to segments)
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
map.reverseDistribute(nOldAllSegments, intersections);
|
|
||||||
|
|
||||||
|
|
||||||
// Extract the hits
|
|
||||||
// ~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
forAll(intersections, i)
|
|
||||||
{
|
|
||||||
const pointIndexHit& allInfo = intersections[i];
|
|
||||||
label segmentI = allSegmentMap[i];
|
|
||||||
pointIndexHit& hitInfo = info[segmentI];
|
|
||||||
|
|
||||||
if (allInfo.hit())
|
|
||||||
{
|
|
||||||
if (!hitInfo.hit())
|
|
||||||
{
|
{
|
||||||
// No intersection yet so take this one
|
intersections[i] = octree.findLine
|
||||||
hitInfo = allInfo;
|
|
||||||
}
|
|
||||||
else if (nearestIntersection)
|
|
||||||
{
|
|
||||||
// Nearest intersection
|
|
||||||
if
|
|
||||||
(
|
(
|
||||||
magSqr(allInfo.hitPoint()-start[segmentI])
|
allSegments[i].first(),
|
||||||
< magSqr(hitInfo.hitPoint()-start[segmentI])
|
allSegments[i].second()
|
||||||
)
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
intersections[i] = octree.findLineAny
|
||||||
|
(
|
||||||
|
allSegments[i].first(),
|
||||||
|
allSegments[i].second()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert triangle index to global numbering
|
||||||
|
if (intersections[i].hit())
|
||||||
|
{
|
||||||
|
intersections[i].setIndex
|
||||||
|
(
|
||||||
|
triIndexer.toGlobal(intersections[i].index())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Exchange the intersections (opposite to segments)
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
map.reverseDistribute(nOldAllSegments, intersections);
|
||||||
|
|
||||||
|
|
||||||
|
// Extract the hits
|
||||||
|
// ~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
forAll(intersections, i)
|
||||||
|
{
|
||||||
|
const pointIndexHit& allInfo = intersections[i];
|
||||||
|
label segmentI = allSegmentMap[i];
|
||||||
|
pointIndexHit& hitInfo = info[segmentI];
|
||||||
|
|
||||||
|
if (allInfo.hit())
|
||||||
|
{
|
||||||
|
if (!hitInfo.hit())
|
||||||
{
|
{
|
||||||
|
// No intersection yet so take this one
|
||||||
hitInfo = allInfo;
|
hitInfo = allInfo;
|
||||||
}
|
}
|
||||||
|
else if (nearestIntersection)
|
||||||
|
{
|
||||||
|
// Nearest intersection
|
||||||
|
if
|
||||||
|
(
|
||||||
|
magSqr(allInfo.hitPoint()-start[segmentI])
|
||||||
|
< magSqr(hitInfo.hitPoint()-start[segmentI])
|
||||||
|
)
|
||||||
|
{
|
||||||
|
hitInfo = allInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user