ENH: reduce number of warnings emitted by hierarchGeomDecomp
- it is sufficient to provide the total number of times that findBinary() failed instead of flooding the screen with messages Full verbose warnings still emitted when debugging is on.
This commit is contained in:
parent
d64a738d0f
commit
e761570986
@ -28,7 +28,7 @@ License
|
|||||||
#include "PstreamReduceOps.H"
|
#include "PstreamReduceOps.H"
|
||||||
#include "SortableList.H"
|
#include "SortableList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
@ -49,7 +49,8 @@ namespace Foam
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::hierarchGeomDecomp::setDecompOrder()
|
void Foam::hierarchGeomDecomp::setDecompOrder()
|
||||||
{
|
{
|
||||||
@ -167,7 +168,7 @@ void Foam::hierarchGeomDecomp::calculateSortedWeightedSizes
|
|||||||
|
|
||||||
// Find position in values so between minIndex and this position there
|
// Find position in values so between minIndex and this position there
|
||||||
// are wantedSize elements.
|
// are wantedSize elements.
|
||||||
void Foam::hierarchGeomDecomp::findBinary
|
bool Foam::hierarchGeomDecomp::findBinary
|
||||||
(
|
(
|
||||||
const label sizeTol,
|
const label sizeTol,
|
||||||
const List<scalar>& values,
|
const List<scalar>& values,
|
||||||
@ -227,21 +228,27 @@ void Foam::hierarchGeomDecomp::findBinary
|
|||||||
bool hasNotChanged = (mag(midValue-midValuePrev) < SMALL);
|
bool hasNotChanged = (mag(midValue-midValuePrev) < SMALL);
|
||||||
|
|
||||||
if (returnReduce(hasNotChanged, andOp<bool>()))
|
if (returnReduce(hasNotChanged, andOp<bool>()))
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "unable to find desired decomposition split, making do!"
|
<< "unable to find desired decomposition split, making do!"
|
||||||
<< endl;
|
<< endl;
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
midValuePrev = midValue;
|
midValuePrev = midValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Find position in values so between minIndex and this position there
|
// Find position in values so between minIndex and this position there
|
||||||
// are wantedSize elements.
|
// are wantedSize elements.
|
||||||
void Foam::hierarchGeomDecomp::findBinary
|
bool Foam::hierarchGeomDecomp::findBinary
|
||||||
(
|
(
|
||||||
const label sizeTol,
|
const label sizeTol,
|
||||||
const List<scalar>& sortedWeightedSizes,
|
const List<scalar>& sortedWeightedSizes,
|
||||||
@ -307,20 +314,26 @@ void Foam::hierarchGeomDecomp::findBinary
|
|||||||
bool hasNotChanged = (mag(midValue-midValuePrev) < SMALL);
|
bool hasNotChanged = (mag(midValue-midValuePrev) < SMALL);
|
||||||
|
|
||||||
if (returnReduce(hasNotChanged, andOp<bool>()))
|
if (returnReduce(hasNotChanged, andOp<bool>()))
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "unable to find desired deomposition split, making do!"
|
<< "Unable to find desired decomposition split, making do!"
|
||||||
<< endl;
|
<< endl;
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
midValuePrev = midValue;
|
midValuePrev = midValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sort points into bins according to one component. Recurses to next component.
|
// 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 label sizeTol,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
@ -331,7 +344,10 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Current component
|
// 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)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -426,7 +442,7 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
rightCoord = maxCoord;
|
rightCoord = maxCoord;
|
||||||
|
|
||||||
// Calculate rightIndex/rightCoord to have wanted size
|
// Calculate rightIndex/rightCoord to have wanted size
|
||||||
findBinary
|
bool ok = findBinary
|
||||||
(
|
(
|
||||||
sizeTol,
|
sizeTol,
|
||||||
sortedCoord,
|
sortedCoord,
|
||||||
@ -439,6 +455,11 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
rightCoord
|
rightCoord
|
||||||
);
|
);
|
||||||
localSize = rightIndex - leftIndex;
|
localSize = rightIndex - leftIndex;
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
++nWarnings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -477,7 +498,7 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
Pout.prefix() = " " + oldPrefix;
|
Pout.prefix() = " " + oldPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
sortComponent
|
nWarnings += sortComponent
|
||||||
(
|
(
|
||||||
sizeTol,
|
sizeTol,
|
||||||
points,
|
points,
|
||||||
@ -497,11 +518,13 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
leftIndex += localSize;
|
leftIndex += localSize;
|
||||||
leftCoord = rightCoord;
|
leftCoord = rightCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nWarnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sort points into bins according to one component. Recurses to next component.
|
// 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 label sizeTol,
|
||||||
const scalarField& weights,
|
const scalarField& weights,
|
||||||
@ -513,7 +536,10 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Current component
|
// 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)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -608,7 +634,7 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
rightCoord = maxCoord;
|
rightCoord = maxCoord;
|
||||||
|
|
||||||
// Calculate rightIndex/rightCoord to have wanted size
|
// Calculate rightIndex/rightCoord to have wanted size
|
||||||
findBinary
|
bool ok = findBinary
|
||||||
(
|
(
|
||||||
sizeTol,
|
sizeTol,
|
||||||
sortedWeightedSizes,
|
sortedWeightedSizes,
|
||||||
@ -622,6 +648,11 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
rightCoord
|
rightCoord
|
||||||
);
|
);
|
||||||
localSize = rightIndex - leftIndex;
|
localSize = rightIndex - leftIndex;
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
++nWarnings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -660,7 +691,7 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
Pout.prefix() = " " + oldPrefix;
|
Pout.prefix() = " " + oldPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
sortComponent
|
nWarnings += sortComponent
|
||||||
(
|
(
|
||||||
sizeTol,
|
sizeTol,
|
||||||
weights,
|
weights,
|
||||||
@ -681,6 +712,8 @@ void Foam::hierarchGeomDecomp::sortComponent
|
|||||||
leftIndex += localSize;
|
leftIndex += localSize;
|
||||||
leftCoord = rightCoord;
|
leftCoord = rightCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nWarnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -722,24 +755,18 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
|
|||||||
labelList finalDecomp(points.size(), Zero);
|
labelList finalDecomp(points.size(), Zero);
|
||||||
|
|
||||||
// Start off with every point sorted onto itself.
|
// Start off with every point sorted onto itself.
|
||||||
labelList slice(points.size());
|
labelList slice(identity(points.size()));
|
||||||
forAll(slice, i)
|
|
||||||
{
|
|
||||||
slice[i] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
pointField rotatedPoints(rotDelta_ & points);
|
pointField rotatedPoints(rotDelta_ & points);
|
||||||
|
|
||||||
// Calculate tolerance of cell distribution. For large cases finding
|
// Calculate tolerance of cell distribution. For large cases finding
|
||||||
// distribution to the cell exact would cause too many iterations so allow
|
// distribution to the cell exact would cause too many iterations so allow
|
||||||
// some slack.
|
// some slack.
|
||||||
label allSize = points.size();
|
const label allSize = returnReduce(points.size(), sumOp<label>());
|
||||||
reduce(allSize, sumOp<label>());
|
|
||||||
|
|
||||||
const label sizeTol = max(1, label(1e-3*allSize/nDomains_));
|
const label sizeTol = max(1, label(1e-3*allSize/nDomains_));
|
||||||
|
|
||||||
// Sort recursive
|
// Sort recursive
|
||||||
sortComponent
|
const label nWarnings = sortComponent
|
||||||
(
|
(
|
||||||
sizeTol,
|
sizeTol,
|
||||||
rotatedPoints,
|
rotatedPoints,
|
||||||
@ -749,6 +776,13 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
|
|||||||
finalDecomp
|
finalDecomp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (nWarnings)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "\nEncountered " << nWarnings << " occurrences where the desired"
|
||||||
|
" decomposition split could not be properly satisfied" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return finalDecomp;
|
return finalDecomp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,24 +797,18 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
|
|||||||
labelList finalDecomp(points.size(), Zero);
|
labelList finalDecomp(points.size(), Zero);
|
||||||
|
|
||||||
// Start off with every point sorted onto itself.
|
// Start off with every point sorted onto itself.
|
||||||
labelList slice(points.size());
|
labelList slice(identity(points.size()));
|
||||||
forAll(slice, i)
|
|
||||||
{
|
|
||||||
slice[i] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
pointField rotatedPoints(rotDelta_ & points);
|
pointField rotatedPoints(rotDelta_ & points);
|
||||||
|
|
||||||
// Calculate tolerance of cell distribution. For large cases finding
|
// Calculate tolerance of cell distribution. For large cases finding
|
||||||
// distribution to the cell exact would cause too many iterations so allow
|
// distribution to the cell exact would cause too many iterations so allow
|
||||||
// some slack.
|
// some slack.
|
||||||
label allSize = points.size();
|
const label allSize = returnReduce(points.size(), sumOp<label>());
|
||||||
reduce(allSize, sumOp<label>());
|
|
||||||
|
|
||||||
const label sizeTol = max(1, label(1e-3*allSize/nDomains_));
|
const label sizeTol = max(1, label(1e-3*allSize/nDomains_));
|
||||||
|
|
||||||
// Sort recursive
|
// Sort recursive
|
||||||
sortComponent
|
const label nWarnings = sortComponent
|
||||||
(
|
(
|
||||||
sizeTol,
|
sizeTol,
|
||||||
weights,
|
weights,
|
||||||
@ -791,6 +819,13 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
|
|||||||
finalDecomp
|
finalDecomp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (nWarnings)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "\nEncountered " << nWarnings << " occurrences where the desired"
|
||||||
|
" decomposition split could not be properly satisfied" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return finalDecomp;
|
return finalDecomp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,9 @@ class hierarchGeomDecomp
|
|||||||
//- Find midValue (at local index mid) such that the number of
|
//- Find midValue (at local index mid) such that the number of
|
||||||
// elements between mid and leftIndex are (globally summed) the
|
// elements between mid and leftIndex are (globally summed) the
|
||||||
// wantedSize. Binary search.
|
// wantedSize. Binary search.
|
||||||
static void findBinary
|
//
|
||||||
|
// \Return False if the binary search completed
|
||||||
|
static bool findBinary
|
||||||
(
|
(
|
||||||
const label sizeTol, // size difference considered acceptable
|
const label sizeTol, // size difference considered acceptable
|
||||||
const List<scalar>&,
|
const List<scalar>&,
|
||||||
@ -126,7 +128,7 @@ class hierarchGeomDecomp
|
|||||||
//- Find midValue (at local index mid) such that the number of
|
//- Find midValue (at local index mid) such that the number of
|
||||||
// elements between mid and leftIndex are (globally summed) the
|
// elements between mid and leftIndex are (globally summed) the
|
||||||
// wantedSize. Binary search.
|
// wantedSize. Binary search.
|
||||||
static void findBinary
|
static bool findBinary
|
||||||
(
|
(
|
||||||
const label sizeTol, // size difference considered acceptable
|
const label sizeTol, // size difference considered acceptable
|
||||||
const List<scalar>& sortedWeightedSizes,
|
const List<scalar>& sortedWeightedSizes,
|
||||||
@ -140,7 +142,8 @@ class hierarchGeomDecomp
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Recursively sort in x,y,z (or rather acc. to decompOrder_)
|
//- Recursively sort in x,y,z (or rather acc. to decompOrder_)
|
||||||
void sortComponent
|
// \return the number of warnings from findBinary
|
||||||
|
label sortComponent
|
||||||
(
|
(
|
||||||
const label sizeTol,
|
const label sizeTol,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
@ -152,7 +155,8 @@ class hierarchGeomDecomp
|
|||||||
|
|
||||||
//- Recursively sort in x,y,z (or rather acc. to decompOrder_)
|
//- Recursively sort in x,y,z (or rather acc. to decompOrder_)
|
||||||
//- Using weighted points.
|
//- Using weighted points.
|
||||||
void sortComponent
|
// \return the number of warnings from findBinary
|
||||||
|
label sortComponent
|
||||||
(
|
(
|
||||||
const label sizeTol,
|
const label sizeTol,
|
||||||
const scalarField& weights,
|
const scalarField& weights,
|
||||||
|
Loading…
Reference in New Issue
Block a user