Work in progress regarding parallel bugfix in donorBasedLayeredOverlapFringe

This commit is contained in:
Vuko Vukcevic 2019-04-12 08:25:22 +02:00
parent 6f532eee4f
commit 9a178ce555

View file

@ -204,10 +204,16 @@ void Foam::donorBasedLayeredOverlapFringe::calcAddressing() const
labelHashSet allAcceptors(0.02*mesh.nCells());
labelHashSet allFringeHoles(0.02*mesh.nCells());
// Communicate state across processors
reduce(allFringesReady, andOp<bool>());
if (allFringesReady)
{
Info<< "All dependent fringes are ready. Starting donor based layered"
<< " overlap assembly..." << endl;
if (debug)
{
Info<< "All dependent fringes are ready."
<< " Starting donor based layered overlap assembly..." << endl;
}
// Loop through connected regions
forAll (connectedRegionIDs_, crI)
@ -223,18 +229,45 @@ void Foam::donorBasedLayeredOverlapFringe::calcAddressing() const
const donorAcceptorList& crDonorAcceptorPairs =
fringe.finalDonorAcceptors();
// Need to gather/scatter the donor-acceptor pairs across all
// processors because these pairs only represent acceptors found on
// my processor. It would be possible to optimize this a bit using
// the mapDistribute tool, but I don't think it will represent a big
// overhead, especially since it's done once.
List<donorAcceptorList> allDonorAcceptorPairs(Pstream::nProcs());
// Fill in my part and communicate
allDonorAcceptorPairs[Pstream::myProcNo()] = crDonorAcceptorPairs;
Pstream::gatherList(allDonorAcceptorPairs);
Pstream::scatterList(allDonorAcceptorPairs);
// Count approximate number of acceptors to guess the size for the
// hash set containing donors
label nAllAcceptors = 0;
forAll (allDonorAcceptorPairs, procI)
{
nAllAcceptors += allDonorAcceptorPairs[procI].size();
}
// Hash set containing donors
labelHashSet donors(6*crDonorAcceptorPairs.size());
labelHashSet donors(6*nAllAcceptors);
// Initialize centre of the donors of this connected region in order
// to search in a given direction
vector centrePoint(vector::zero);
// Loop through all processors
forAll (allDonorAcceptorPairs, procI)
{
// Get all donor/acceptor pairs found on this processor
const donorAcceptorList& procDonorAcceptorPairs =
allDonorAcceptorPairs[procI];
// Loop through all donor/acceptors
forAll (crDonorAcceptorPairs, daI)
forAll (procDonorAcceptorPairs, daI)
{
// Get this donor/acceptor pair
const donorAcceptor& daPair = crDonorAcceptorPairs[daI];
const donorAcceptor& daPair = procDonorAcceptorPairs[daI];
// Check whether all donors have been found
if (!daPair.donorFound())
@ -247,13 +280,15 @@ void Foam::donorBasedLayeredOverlapFringe::calcAddressing() const
<< nl
<< "Donor/acceptor data: " << daPair
<< nl
<< "In connected region: " << allRegions[regionID].name()
<< "In connected region: "
<< allRegions[regionID].name()
<< abort(FatalError);
}
// Mark donors on my processor from this connected region. Note
// that the check has been made in constructor to make sure that
// this region is the only donor region for the connected region
// Mark donors on my processor from this connected region.
// Note that the check has been made in constructor to make
// sure that this region is the only donor region for the
// connected region
if (daPair.donorProcNo() == Pstream::myProcNo())
{
// Get donor index
@ -262,9 +297,9 @@ void Foam::donorBasedLayeredOverlapFringe::calcAddressing() const
// Insert donor into the hash set
if (donors.insert(dI))
{
// Donor has been inserted (not previously found in the
// hash set), add donor point to centre point (the
// centre point will be calculated later on as
// Donor has been inserted (not previously found in
// the hash set), add donor point to centre point
// (the centre point will be calculated later on as
// arithmetic mean)
centrePoint += daPair.donorPoint();
}
@ -283,13 +318,15 @@ void Foam::donorBasedLayeredOverlapFringe::calcAddressing() const
// Inser extended donor into the hash set
if (donors.insert(edI))
{
// Donor has been inserted (not previously found in
// the hash set), add extended donor point as well
// Donor has been inserted (not previously found
// in the hash set), add extended donor point as
// well
centrePoint += extDonorPoints[i];
}
} // End for all extended donors
} // End if this donor is on my processor
} // End for all (master) donor cells
} // End for all processors
// Use the centre point as specified by the user if it was specified
// (if the regionCentrePoints_ list is not empty). This avoids