diff --git a/src/parallel/decompose/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C b/src/parallel/decompose/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C index cc87a33f2d..2eee63f9c4 100644 --- a/src/parallel/decompose/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C +++ b/src/parallel/decompose/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C @@ -28,7 +28,7 @@ License #include "PstreamReduceOps.H" #include "SortableList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { @@ -49,7 +49,8 @@ namespace Foam ); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::hierarchGeomDecomp::setDecompOrder() { @@ -167,7 +168,7 @@ void Foam::hierarchGeomDecomp::calculateSortedWeightedSizes // Find position in values so between minIndex and this position there // are wantedSize elements. -void Foam::hierarchGeomDecomp::findBinary +bool Foam::hierarchGeomDecomp::findBinary ( const label sizeTol, const List& values, @@ -228,20 +229,26 @@ void Foam::hierarchGeomDecomp::findBinary if (returnReduce(hasNotChanged, andOp())) { - WarningInFunction - << "unable to find desired decomposition split, making do!" - << endl; - break; + if (debug) + { + WarningInFunction + << "unable to find desired decomposition split, making do!" + << endl; + } + + return false; } midValuePrev = midValue; } + + return true; } // Find position in values so between minIndex and this position there // are wantedSize elements. -void Foam::hierarchGeomDecomp::findBinary +bool Foam::hierarchGeomDecomp::findBinary ( const label sizeTol, const List& sortedWeightedSizes, @@ -308,19 +315,25 @@ void Foam::hierarchGeomDecomp::findBinary if (returnReduce(hasNotChanged, andOp())) { - WarningInFunction - << "unable to find desired deomposition split, making do!" - << endl; - break; + if (debug) + { + WarningInFunction + << "Unable to find desired decomposition split, making do!" + << endl; + } + + return false; } midValuePrev = midValue; } + + return true; } // Sort points into bins according to one component. Recurses to next component. -void Foam::hierarchGeomDecomp::sortComponent +Foam::label Foam::hierarchGeomDecomp::sortComponent ( const label sizeTol, const pointField& points, @@ -331,7 +344,10 @@ void Foam::hierarchGeomDecomp::sortComponent ) const { // Current component - label compI = decompOrder_[componentIndex]; + const label compI = decompOrder_[componentIndex]; + + // Track the number of times that findBinary() did not converge + label nWarnings = 0; if (debug) { @@ -426,7 +442,7 @@ void Foam::hierarchGeomDecomp::sortComponent rightCoord = maxCoord; // Calculate rightIndex/rightCoord to have wanted size - findBinary + bool ok = findBinary ( sizeTol, sortedCoord, @@ -439,6 +455,11 @@ void Foam::hierarchGeomDecomp::sortComponent rightCoord ); localSize = rightIndex - leftIndex; + + if (!ok) + { + ++nWarnings; + } } if (debug) @@ -477,7 +498,7 @@ void Foam::hierarchGeomDecomp::sortComponent Pout.prefix() = " " + oldPrefix; } - sortComponent + nWarnings += sortComponent ( sizeTol, points, @@ -497,11 +518,13 @@ void Foam::hierarchGeomDecomp::sortComponent leftIndex += localSize; leftCoord = rightCoord; } + + return nWarnings; } // Sort points into bins according to one component. Recurses to next component. -void Foam::hierarchGeomDecomp::sortComponent +Foam::label Foam::hierarchGeomDecomp::sortComponent ( const label sizeTol, const scalarField& weights, @@ -513,7 +536,10 @@ void Foam::hierarchGeomDecomp::sortComponent ) const { // Current component - label compI = decompOrder_[componentIndex]; + const label compI = decompOrder_[componentIndex]; + + // Track the number of times that findBinary() did not converge + label nWarnings = 0; if (debug) { @@ -608,7 +634,7 @@ void Foam::hierarchGeomDecomp::sortComponent rightCoord = maxCoord; // Calculate rightIndex/rightCoord to have wanted size - findBinary + bool ok = findBinary ( sizeTol, sortedWeightedSizes, @@ -622,6 +648,11 @@ void Foam::hierarchGeomDecomp::sortComponent rightCoord ); localSize = rightIndex - leftIndex; + + if (!ok) + { + ++nWarnings; + } } if (debug) @@ -660,7 +691,7 @@ void Foam::hierarchGeomDecomp::sortComponent Pout.prefix() = " " + oldPrefix; } - sortComponent + nWarnings += sortComponent ( sizeTol, weights, @@ -681,6 +712,8 @@ void Foam::hierarchGeomDecomp::sortComponent leftIndex += localSize; leftCoord = rightCoord; } + + return nWarnings; } @@ -722,24 +755,18 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose labelList finalDecomp(points.size(), Zero); // Start off with every point sorted onto itself. - labelList slice(points.size()); - forAll(slice, i) - { - slice[i] = i; - } + labelList slice(identity(points.size())); pointField rotatedPoints(rotDelta_ & points); // Calculate tolerance of cell distribution. For large cases finding // distribution to the cell exact would cause too many iterations so allow // some slack. - label allSize = points.size(); - reduce(allSize, sumOp