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 allAcceptors(0.02*mesh.nCells());
labelHashSet allFringeHoles(0.02*mesh.nCells()); labelHashSet allFringeHoles(0.02*mesh.nCells());
// Communicate state across processors
reduce(allFringesReady, andOp<bool>());
if (allFringesReady) if (allFringesReady)
{ {
Info<< "All dependent fringes are ready. Starting donor based layered" if (debug)
<< " overlap assembly..." << endl; {
Info<< "All dependent fringes are ready."
<< " Starting donor based layered overlap assembly..." << endl;
}
// Loop through connected regions // Loop through connected regions
forAll (connectedRegionIDs_, crI) forAll (connectedRegionIDs_, crI)
@ -223,18 +229,45 @@ void Foam::donorBasedLayeredOverlapFringe::calcAddressing() const
const donorAcceptorList& crDonorAcceptorPairs = const donorAcceptorList& crDonorAcceptorPairs =
fringe.finalDonorAcceptors(); 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 // Hash set containing donors
labelHashSet donors(6*crDonorAcceptorPairs.size()); labelHashSet donors(6*nAllAcceptors);
// Initialize centre of the donors of this connected region in order // Initialize centre of the donors of this connected region in order
// to search in a given direction // to search in a given direction
vector centrePoint(vector::zero); 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 // Loop through all donor/acceptors
forAll (crDonorAcceptorPairs, daI) forAll (procDonorAcceptorPairs, daI)
{ {
// Get this donor/acceptor pair // Get this donor/acceptor pair
const donorAcceptor& daPair = crDonorAcceptorPairs[daI]; const donorAcceptor& daPair = procDonorAcceptorPairs[daI];
// Check whether all donors have been found // Check whether all donors have been found
if (!daPair.donorFound()) if (!daPair.donorFound())
@ -247,13 +280,15 @@ void Foam::donorBasedLayeredOverlapFringe::calcAddressing() const
<< nl << nl
<< "Donor/acceptor data: " << daPair << "Donor/acceptor data: " << daPair
<< nl << nl
<< "In connected region: " << allRegions[regionID].name() << "In connected region: "
<< allRegions[regionID].name()
<< abort(FatalError); << abort(FatalError);
} }
// Mark donors on my processor from this connected region. Note // Mark donors on my processor from this connected region.
// that the check has been made in constructor to make sure that // Note that the check has been made in constructor to make
// this region is the only donor region for the connected region // sure that this region is the only donor region for the
// connected region
if (daPair.donorProcNo() == Pstream::myProcNo()) if (daPair.donorProcNo() == Pstream::myProcNo())
{ {
// Get donor index // Get donor index
@ -262,9 +297,9 @@ void Foam::donorBasedLayeredOverlapFringe::calcAddressing() const
// Insert donor into the hash set // Insert donor into the hash set
if (donors.insert(dI)) if (donors.insert(dI))
{ {
// Donor has been inserted (not previously found in the // Donor has been inserted (not previously found in
// hash set), add donor point to centre point (the // the hash set), add donor point to centre point
// centre point will be calculated later on as // (the centre point will be calculated later on as
// arithmetic mean) // arithmetic mean)
centrePoint += daPair.donorPoint(); centrePoint += daPair.donorPoint();
} }
@ -283,13 +318,15 @@ void Foam::donorBasedLayeredOverlapFringe::calcAddressing() const
// Inser extended donor into the hash set // Inser extended donor into the hash set
if (donors.insert(edI)) if (donors.insert(edI))
{ {
// Donor has been inserted (not previously found in // Donor has been inserted (not previously found
// the hash set), add extended donor point as well // in the hash set), add extended donor point as
// well
centrePoint += extDonorPoints[i]; centrePoint += extDonorPoints[i];
} }
} // End for all extended donors } // End for all extended donors
} // End if this donor is on my processor } // End if this donor is on my processor
} // End for all (master) donor cells } // End for all (master) donor cells
} // End for all processors
// Use the centre point as specified by the user if it was specified // Use the centre point as specified by the user if it was specified
// (if the regionCentrePoints_ list is not empty). This avoids // (if the regionCentrePoints_ list is not empty). This avoids