Work in progress regarding parallel bugfix in donorBasedLayeredOverlapFringe
This commit is contained in:
parent
6f532eee4f
commit
9a178ce555
1 changed files with 89 additions and 52 deletions
|
@ -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,73 +229,104 @@ 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 donor/acceptors
|
// Loop through all processors
|
||||||
forAll (crDonorAcceptorPairs, daI)
|
forAll (allDonorAcceptorPairs, procI)
|
||||||
{
|
{
|
||||||
// Get this donor/acceptor pair
|
// Get all donor/acceptor pairs found on this processor
|
||||||
const donorAcceptor& daPair = crDonorAcceptorPairs[daI];
|
const donorAcceptorList& procDonorAcceptorPairs =
|
||||||
|
allDonorAcceptorPairs[procI];
|
||||||
|
|
||||||
// Check whether all donors have been found
|
// Loop through all donor/acceptors
|
||||||
if (!daPair.donorFound())
|
forAll (procDonorAcceptorPairs, daI)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
// Get this donor/acceptor pair
|
||||||
(
|
const donorAcceptor& daPair = procDonorAcceptorPairs[daI];
|
||||||
"donorBasedLayeredOverlapFringe::"
|
|
||||||
"updateIteration(donorAcceptorList&) const"
|
|
||||||
) << "Donor not found for donor/acceptor pair " << daI
|
|
||||||
<< nl
|
|
||||||
<< "Donor/acceptor data: " << daPair
|
|
||||||
<< nl
|
|
||||||
<< "In connected region: " << allRegions[regionID].name()
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark donors on my processor from this connected region. Note
|
// Check whether all donors have been found
|
||||||
// that the check has been made in constructor to make sure that
|
if (!daPair.donorFound())
|
||||||
// this region is the only donor region for the connected region
|
|
||||||
if (daPair.donorProcNo() == Pstream::myProcNo())
|
|
||||||
{
|
|
||||||
// Get donor index
|
|
||||||
const label& dI = daPair.donorCell();
|
|
||||||
|
|
||||||
// Insert donor into the hash set
|
|
||||||
if (donors.insert(dI))
|
|
||||||
{
|
{
|
||||||
// Donor has been inserted (not previously found in the
|
FatalErrorIn
|
||||||
// hash set), add donor point to centre point (the
|
(
|
||||||
// centre point will be calculated later on as
|
"donorBasedLayeredOverlapFringe::"
|
||||||
// arithmetic mean)
|
"updateIteration(donorAcceptorList&) const"
|
||||||
centrePoint += daPair.donorPoint();
|
) << "Donor not found for donor/acceptor pair " << daI
|
||||||
|
<< nl
|
||||||
|
<< "Donor/acceptor data: " << daPair
|
||||||
|
<< nl
|
||||||
|
<< "In connected region: "
|
||||||
|
<< allRegions[regionID].name()
|
||||||
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through extended donor cells
|
// Mark donors on my processor from this connected region.
|
||||||
const donorAcceptor::DynamicLabelList& extDonors =
|
// Note that the check has been made in constructor to make
|
||||||
daPair.extendedDonorCells();
|
// sure that this region is the only donor region for the
|
||||||
const donorAcceptor::DynamicPointList& extDonorPoints =
|
// connected region
|
||||||
daPair.extendedDonorPoints();
|
if (daPair.donorProcNo() == Pstream::myProcNo())
|
||||||
|
|
||||||
forAll (extDonors, i)
|
|
||||||
{
|
{
|
||||||
// Get donor index
|
// Get donor index
|
||||||
const label& edI = extDonors[i];
|
const label& dI = daPair.donorCell();
|
||||||
|
|
||||||
// Inser extended donor into the hash set
|
// Insert donor into the hash set
|
||||||
if (donors.insert(edI))
|
if (donors.insert(dI))
|
||||||
{
|
{
|
||||||
// Donor has been inserted (not previously found in
|
// Donor has been inserted (not previously found in
|
||||||
// the hash set), add extended donor point as well
|
// the hash set), add donor point to centre point
|
||||||
centrePoint += extDonorPoints[i];
|
// (the centre point will be calculated later on as
|
||||||
|
// arithmetic mean)
|
||||||
|
centrePoint += daPair.donorPoint();
|
||||||
}
|
}
|
||||||
} // End for all extended donors
|
|
||||||
} // End if this donor is on my processor
|
// Loop through extended donor cells
|
||||||
} // End for all (master) donor cells
|
const donorAcceptor::DynamicLabelList& extDonors =
|
||||||
|
daPair.extendedDonorCells();
|
||||||
|
const donorAcceptor::DynamicPointList& extDonorPoints =
|
||||||
|
daPair.extendedDonorPoints();
|
||||||
|
|
||||||
|
forAll (extDonors, i)
|
||||||
|
{
|
||||||
|
// Get donor index
|
||||||
|
const label& edI = extDonors[i];
|
||||||
|
|
||||||
|
// 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
|
||||||
|
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
|
// 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
|
||||||
|
@ -695,7 +732,7 @@ Foam::donorBasedLayeredOverlapFringe::donorBasedLayeredOverlapFringe
|
||||||
// acceptors on the wrong side and filling in the whole region with holes
|
// acceptors on the wrong side and filling in the whole region with holes
|
||||||
if (nLayers_ == 1)
|
if (nLayers_ == 1)
|
||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"donorBasedLayeredOverlapFringe::"
|
"donorBasedLayeredOverlapFringe::"
|
||||||
"donorBasedLayeredOverlapFringe\n"
|
"donorBasedLayeredOverlapFringe\n"
|
||||||
|
@ -758,7 +795,7 @@ bool Foam::donorBasedLayeredOverlapFringe::updateIteration
|
||||||
donorAcceptorRegionData,
|
donorAcceptorRegionData,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set the flag to true
|
// Set the flag to true
|
||||||
updateSuitableOverlapFlag(true);
|
updateSuitableOverlapFlag(true);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue