mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Fix weight calculation.
The global sum of (integer) weights for metis&scotch has to be within the valid range of integers. For now just divided the input (scalar) weights with the minimum before truncating to integer.
This commit is contained in:
@ -253,9 +253,19 @@ Foam::label Foam::scotchDecomp::decompose
|
|||||||
|
|
||||||
|
|
||||||
// Check for externally provided cellweights and if so initialise weights
|
// Check for externally provided cellweights and if so initialise weights
|
||||||
scalar maxWeights = gMax(cWeights);
|
scalar minWeights = gMin(cWeights);
|
||||||
if (cWeights.size() > 0)
|
if (cWeights.size() > 0)
|
||||||
{
|
{
|
||||||
|
if (minWeights <= 0)
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"scotchDecomp::decompose"
|
||||||
|
"(const pointField&, const scalarField&)"
|
||||||
|
) << "Illegal minimum weight " << minWeights
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (cWeights.size() != xadj.size()-1)
|
if (cWeights.size() != xadj.size()-1)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -266,11 +276,12 @@ Foam::label Foam::scotchDecomp::decompose
|
|||||||
<< " does not equal number of cells " << xadj.size()-1
|
<< " does not equal number of cells " << xadj.size()-1
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to integers.
|
// Convert to integers.
|
||||||
velotab.setSize(cWeights.size());
|
velotab.setSize(cWeights.size());
|
||||||
forAll(velotab, i)
|
forAll(velotab, i)
|
||||||
{
|
{
|
||||||
velotab[i] = int(1000000*cWeights[i]/maxWeights);
|
velotab[i] = int(cWeights[i]/minWeights);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -104,6 +104,9 @@ public:
|
|||||||
|
|
||||||
//- Return for every coordinate the wanted processor number. Use the
|
//- Return for every coordinate the wanted processor number. Use the
|
||||||
// mesh connectivity (if needed)
|
// mesh connectivity (if needed)
|
||||||
|
// Weights get truncated to convert into integer
|
||||||
|
// so e.g. 3.5 is seen as 3. The overall sum of weights
|
||||||
|
// might otherwise overflow.
|
||||||
virtual labelList decompose
|
virtual labelList decompose
|
||||||
(
|
(
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
@ -114,6 +117,7 @@ public:
|
|||||||
// passed agglomeration map (from fine to coarse cells) and coarse cell
|
// passed agglomeration map (from fine to coarse cells) and coarse cell
|
||||||
// location. Can be overridden by decomposers that provide this
|
// location. Can be overridden by decomposers that provide this
|
||||||
// functionality natively.
|
// functionality natively.
|
||||||
|
// See note on weights above.
|
||||||
virtual labelList decompose
|
virtual labelList decompose
|
||||||
(
|
(
|
||||||
const labelList& agglom,
|
const labelList& agglom,
|
||||||
@ -128,6 +132,7 @@ public:
|
|||||||
// from 0 at processor0 and then incrementing all through the
|
// from 0 at processor0 and then incrementing all through the
|
||||||
// processors)
|
// processors)
|
||||||
// - the connections are across coupled patches
|
// - the connections are across coupled patches
|
||||||
|
// See note on weights above.
|
||||||
virtual labelList decompose
|
virtual labelList decompose
|
||||||
(
|
(
|
||||||
const labelListList& globalCellCells,
|
const labelListList& globalCellCells,
|
||||||
|
|||||||
@ -89,9 +89,19 @@ Foam::label Foam::metisDecomp::decompose
|
|||||||
|
|
||||||
|
|
||||||
// Check for externally provided cellweights and if so initialise weights
|
// Check for externally provided cellweights and if so initialise weights
|
||||||
scalar maxWeights = gMax(cWeights);
|
scalar minWeights = gMin(cWeights);
|
||||||
if (cWeights.size() > 0)
|
if (cWeights.size() > 0)
|
||||||
{
|
{
|
||||||
|
if (minWeights <= 0)
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"metisDecomp::decompose"
|
||||||
|
"(const pointField&, const scalarField&)"
|
||||||
|
) << "Illegal minimum weight " << minWeights
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (cWeights.size() != numCells)
|
if (cWeights.size() != numCells)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -106,7 +116,7 @@ Foam::label Foam::metisDecomp::decompose
|
|||||||
cellWeights.setSize(cWeights.size());
|
cellWeights.setSize(cWeights.size());
|
||||||
forAll(cellWeights, i)
|
forAll(cellWeights, i)
|
||||||
{
|
{
|
||||||
cellWeights[i] = int(1000000*cWeights[i]/maxWeights);
|
cellWeights[i] = int(cWeights[i]/minWeights);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -101,6 +101,9 @@ public:
|
|||||||
|
|
||||||
//- Return for every coordinate the wanted processor number. Use the
|
//- Return for every coordinate the wanted processor number. Use the
|
||||||
// mesh connectivity (if needed)
|
// mesh connectivity (if needed)
|
||||||
|
// Weights get normalised so the minimum value is 1 before truncation
|
||||||
|
// to an integer so the weights should be multiples of the minimum
|
||||||
|
// value. The overall sum of weights might otherwise overflow.
|
||||||
virtual labelList decompose
|
virtual labelList decompose
|
||||||
(
|
(
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
@ -111,6 +114,7 @@ public:
|
|||||||
// passed agglomeration map (from fine to coarse cells) and coarse cell
|
// passed agglomeration map (from fine to coarse cells) and coarse cell
|
||||||
// location. Can be overridden by decomposers that provide this
|
// location. Can be overridden by decomposers that provide this
|
||||||
// functionality natively.
|
// functionality natively.
|
||||||
|
// See note on weights above.
|
||||||
virtual labelList decompose
|
virtual labelList decompose
|
||||||
(
|
(
|
||||||
const labelList& agglom,
|
const labelList& agglom,
|
||||||
@ -125,6 +129,7 @@ public:
|
|||||||
// from 0 at processor0 and then incrementing all through the
|
// from 0 at processor0 and then incrementing all through the
|
||||||
// processors)
|
// processors)
|
||||||
// - the connections are across coupled patches
|
// - the connections are across coupled patches
|
||||||
|
// See note on weights above.
|
||||||
virtual labelList decompose
|
virtual labelList decompose
|
||||||
(
|
(
|
||||||
const labelListList& globalCellCells,
|
const labelListList& globalCellCells,
|
||||||
|
|||||||
@ -428,9 +428,19 @@ Foam::labelList Foam::parMetisDecomp::decompose
|
|||||||
|
|
||||||
|
|
||||||
// Check for externally provided cellweights and if so initialise weights
|
// Check for externally provided cellweights and if so initialise weights
|
||||||
scalar maxWeights = gMax(cWeights);
|
scalar minWeights = gMin(cWeights);
|
||||||
if (cWeights.size() > 0)
|
if (cWeights.size() > 0)
|
||||||
{
|
{
|
||||||
|
if (minWeights <= 0)
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"metisDecomp::decompose"
|
||||||
|
"(const pointField&, const scalarField&)"
|
||||||
|
) << "Illegal minimum weight " << minWeights
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (cWeights.size() != mesh_.nCells())
|
if (cWeights.size() != mesh_.nCells())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -441,11 +451,12 @@ Foam::labelList Foam::parMetisDecomp::decompose
|
|||||||
<< " does not equal number of cells " << mesh_.nCells()
|
<< " does not equal number of cells " << mesh_.nCells()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to integers.
|
// Convert to integers.
|
||||||
cellWeights.setSize(cWeights.size());
|
cellWeights.setSize(cWeights.size());
|
||||||
forAll(cellWeights, i)
|
forAll(cellWeights, i)
|
||||||
{
|
{
|
||||||
cellWeights[i] = int(1000000*cWeights[i]/maxWeights);
|
cellWeights[i] = int(cWeights[i]/minWeights);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,9 +790,19 @@ Foam::labelList Foam::parMetisDecomp::decompose
|
|||||||
|
|
||||||
|
|
||||||
// Check for externally provided cellweights and if so initialise weights
|
// Check for externally provided cellweights and if so initialise weights
|
||||||
scalar maxWeights = gMax(cWeights);
|
scalar minWeights = gMin(cWeights);
|
||||||
if (cWeights.size() > 0)
|
if (cWeights.size() > 0)
|
||||||
{
|
{
|
||||||
|
if (minWeights <= 0)
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"parMetisDecomp::decompose(const labelListList&"
|
||||||
|
", const pointField&, const scalarField&)"
|
||||||
|
) << "Illegal minimum weight " << minWeights
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (cWeights.size() != globalCellCells.size())
|
if (cWeights.size() != globalCellCells.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -792,11 +813,12 @@ Foam::labelList Foam::parMetisDecomp::decompose
|
|||||||
<< " does not equal number of cells " << globalCellCells.size()
|
<< " does not equal number of cells " << globalCellCells.size()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to integers.
|
// Convert to integers.
|
||||||
cellWeights.setSize(cWeights.size());
|
cellWeights.setSize(cWeights.size());
|
||||||
forAll(cellWeights, i)
|
forAll(cellWeights, i)
|
||||||
{
|
{
|
||||||
cellWeights[i] = int(1000000*cWeights[i]/maxWeights);
|
cellWeights[i] = int(cWeights[i]/minWeights);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -112,6 +112,9 @@ public:
|
|||||||
|
|
||||||
//- Return for every coordinate the wanted processor number. Use the
|
//- Return for every coordinate the wanted processor number. Use the
|
||||||
// mesh connectivity (if needed)
|
// mesh connectivity (if needed)
|
||||||
|
// Weights get normalised so the minimum value is 1 before truncation
|
||||||
|
// to an integer so the weights should be multiples of the minimum
|
||||||
|
// value. The overall sum of weights might otherwise overflow.
|
||||||
virtual labelList decompose
|
virtual labelList decompose
|
||||||
(
|
(
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
@ -122,6 +125,7 @@ public:
|
|||||||
// passed agglomeration map (from fine to coarse cells) and coarse cell
|
// passed agglomeration map (from fine to coarse cells) and coarse cell
|
||||||
// location. Can be overridden by decomposers that provide this
|
// location. Can be overridden by decomposers that provide this
|
||||||
// functionality natively.
|
// functionality natively.
|
||||||
|
// See note on weights above.
|
||||||
virtual labelList decompose
|
virtual labelList decompose
|
||||||
(
|
(
|
||||||
const labelList& cellToRegion,
|
const labelList& cellToRegion,
|
||||||
@ -136,6 +140,7 @@ public:
|
|||||||
// from 0 at processor0 and then incrementing all through the
|
// from 0 at processor0 and then incrementing all through the
|
||||||
// processors)
|
// processors)
|
||||||
// - the connections are across coupled patches
|
// - the connections are across coupled patches
|
||||||
|
// See note on weights above.
|
||||||
virtual labelList decompose
|
virtual labelList decompose
|
||||||
(
|
(
|
||||||
const labelListList& globalCellCells,
|
const labelListList& globalCellCells,
|
||||||
|
|||||||
Reference in New Issue
Block a user