diff --git a/src/parallel/decompositionMethods/scotchDecomp/scotchDecomp.C b/src/parallel/decompositionMethods/scotchDecomp/scotchDecomp.C index 53931689cb..b1b666198c 100644 --- a/src/parallel/decompositionMethods/scotchDecomp/scotchDecomp.C +++ b/src/parallel/decompositionMethods/scotchDecomp/scotchDecomp.C @@ -253,9 +253,19 @@ Foam::label Foam::scotchDecomp::decompose // Check for externally provided cellweights and if so initialise weights - scalar maxWeights = gMax(cWeights); + scalar minWeights = gMin(cWeights); 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) { FatalErrorIn @@ -266,11 +276,12 @@ Foam::label Foam::scotchDecomp::decompose << " does not equal number of cells " << xadj.size()-1 << exit(FatalError); } + // Convert to integers. velotab.setSize(cWeights.size()); forAll(velotab, i) { - velotab[i] = int(1000000*cWeights[i]/maxWeights); + velotab[i] = int(cWeights[i]/minWeights); } } diff --git a/src/parallel/decompositionMethods/scotchDecomp/scotchDecomp.H b/src/parallel/decompositionMethods/scotchDecomp/scotchDecomp.H index 93bcc7b9a4..7429eefacf 100644 --- a/src/parallel/decompositionMethods/scotchDecomp/scotchDecomp.H +++ b/src/parallel/decompositionMethods/scotchDecomp/scotchDecomp.H @@ -104,6 +104,9 @@ public: //- Return for every coordinate the wanted processor number. Use the // 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 ( const pointField& points, @@ -114,6 +117,7 @@ public: // passed agglomeration map (from fine to coarse cells) and coarse cell // location. Can be overridden by decomposers that provide this // functionality natively. + // See note on weights above. virtual labelList decompose ( const labelList& agglom, @@ -128,6 +132,7 @@ public: // from 0 at processor0 and then incrementing all through the // processors) // - the connections are across coupled patches + // See note on weights above. virtual labelList decompose ( const labelListList& globalCellCells, diff --git a/src/parallel/metisDecomp/metisDecomp.C b/src/parallel/metisDecomp/metisDecomp.C index 9066e92248..fb2fddb868 100644 --- a/src/parallel/metisDecomp/metisDecomp.C +++ b/src/parallel/metisDecomp/metisDecomp.C @@ -89,9 +89,19 @@ Foam::label Foam::metisDecomp::decompose // Check for externally provided cellweights and if so initialise weights - scalar maxWeights = gMax(cWeights); + scalar minWeights = gMin(cWeights); if (cWeights.size() > 0) { + if (minWeights <= 0) + { + WarningIn + ( + "metisDecomp::decompose" + "(const pointField&, const scalarField&)" + ) << "Illegal minimum weight " << minWeights + << endl; + } + if (cWeights.size() != numCells) { FatalErrorIn @@ -106,7 +116,7 @@ Foam::label Foam::metisDecomp::decompose cellWeights.setSize(cWeights.size()); forAll(cellWeights, i) { - cellWeights[i] = int(1000000*cWeights[i]/maxWeights); + cellWeights[i] = int(cWeights[i]/minWeights); } } diff --git a/src/parallel/metisDecomp/metisDecomp.H b/src/parallel/metisDecomp/metisDecomp.H index c585686f60..12610f7d82 100644 --- a/src/parallel/metisDecomp/metisDecomp.H +++ b/src/parallel/metisDecomp/metisDecomp.H @@ -101,6 +101,9 @@ public: //- Return for every coordinate the wanted processor number. Use the // 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 ( const pointField& points, @@ -111,6 +114,7 @@ public: // passed agglomeration map (from fine to coarse cells) and coarse cell // location. Can be overridden by decomposers that provide this // functionality natively. + // See note on weights above. virtual labelList decompose ( const labelList& agglom, @@ -125,6 +129,7 @@ public: // from 0 at processor0 and then incrementing all through the // processors) // - the connections are across coupled patches + // See note on weights above. virtual labelList decompose ( const labelListList& globalCellCells, diff --git a/src/parallel/parMetisDecomp/parMetisDecomp.C b/src/parallel/parMetisDecomp/parMetisDecomp.C index cf7434b5c9..f8e590c957 100644 --- a/src/parallel/parMetisDecomp/parMetisDecomp.C +++ b/src/parallel/parMetisDecomp/parMetisDecomp.C @@ -428,9 +428,19 @@ Foam::labelList Foam::parMetisDecomp::decompose // Check for externally provided cellweights and if so initialise weights - scalar maxWeights = gMax(cWeights); + scalar minWeights = gMin(cWeights); if (cWeights.size() > 0) { + if (minWeights <= 0) + { + WarningIn + ( + "metisDecomp::decompose" + "(const pointField&, const scalarField&)" + ) << "Illegal minimum weight " << minWeights + << endl; + } + if (cWeights.size() != mesh_.nCells()) { FatalErrorIn @@ -441,11 +451,12 @@ Foam::labelList Foam::parMetisDecomp::decompose << " does not equal number of cells " << mesh_.nCells() << exit(FatalError); } + // Convert to integers. cellWeights.setSize(cWeights.size()); 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 - scalar maxWeights = gMax(cWeights); + scalar minWeights = gMin(cWeights); 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()) { FatalErrorIn @@ -792,11 +813,12 @@ Foam::labelList Foam::parMetisDecomp::decompose << " does not equal number of cells " << globalCellCells.size() << exit(FatalError); } + // Convert to integers. cellWeights.setSize(cWeights.size()); forAll(cellWeights, i) { - cellWeights[i] = int(1000000*cWeights[i]/maxWeights); + cellWeights[i] = int(cWeights[i]/minWeights); } } diff --git a/src/parallel/parMetisDecomp/parMetisDecomp.H b/src/parallel/parMetisDecomp/parMetisDecomp.H index dda8173557..69c9500a47 100644 --- a/src/parallel/parMetisDecomp/parMetisDecomp.H +++ b/src/parallel/parMetisDecomp/parMetisDecomp.H @@ -112,6 +112,9 @@ public: //- Return for every coordinate the wanted processor number. Use the // 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 ( const pointField& points, @@ -122,6 +125,7 @@ public: // passed agglomeration map (from fine to coarse cells) and coarse cell // location. Can be overridden by decomposers that provide this // functionality natively. + // See note on weights above. virtual labelList decompose ( const labelList& cellToRegion, @@ -136,6 +140,7 @@ public: // from 0 at processor0 and then incrementing all through the // processors) // - the connections are across coupled patches + // See note on weights above. virtual labelList decompose ( const labelListList& globalCellCells,