214 #include "ptscotch.h"
244 <<
"Call to scotch routine " << str <<
" failed."
441 const fileName& meshPath,
456 (adjncy.
size() ? adjncy.begin() : dummyAdjncy.begin()),
458 (xadj.
size() ? xadj.begin() : dummyXadj.begin()),
468 const fileName& meshPath,
469 const label adjncySize,
470 const label adjncy[],
471 const label xadjSize,
480 Pout<<
"ptscotchDecomp : entering with xadj:" << xadjSize <<
endl;
484 if (decompositionDict_.found(
"scotchCoeffs"))
486 const dictionary& scotchCoeffs =
487 decompositionDict_.subDict(
"scotchCoeffs");
489 if (scotchCoeffs.lookupOrDefault(
"writeGraph",
false))
496 Pout<<
"Dumping Scotch graph file to " << str.
name() <<
endl
497 <<
"Use this in combination with dgpart." <<
endl;
499 globalIndex globalCells(xadjSize-1);
503 str << version <<
nl;
510 str << globalCells.size();
512 str <<
' ' <<
returnReduce(xadj[xadjSize-1], sumOp<label>())
517 str <<
' ' << xadj[xadjSize-1] <<
nl;
521 str << baseval <<
' ' <<
"000" <<
nl;
522 for (
label cellI = 0; cellI < xadjSize-1; cellI++)
524 label start = xadj[cellI];
525 label end = xadj[cellI+1];
528 for (
label i = start; i < end; i++)
530 str <<
' ' << adjncy[i];
541 SCOTCH_Strat stradat;
542 check(SCOTCH_stratInit(&stradat),
"SCOTCH_stratInit");
544 if (decompositionDict_.found(
"scotchCoeffs"))
546 const dictionary& scotchCoeffs =
547 decompositionDict_.subDict(
"scotchCoeffs");
551 if (scotchCoeffs.readIfPresent(
"strategy", strategy))
555 Info<<
"ptscotchDecomp : Using strategy " << strategy <<
endl;
557 SCOTCH_stratDgraphMap(&stradat, strategy.c_str());
573 scalar minWeights =
gMin(cWeights);
574 scalar maxWeights =
gMax(cWeights);
576 if (maxWeights > minWeights)
581 <<
"Illegal minimum weight " << minWeights
585 if (cWeights.size() != xadjSize-1)
588 <<
"Number of cell weights " << cWeights.size()
589 <<
" does not equal number of cells " << xadjSize-1
594 scalar velotabSum =
gSum(cWeights)/minWeights;
596 scalar rangeScale(1.0);
600 if (velotabSum > scalar(
labelMax - 1))
604 rangeScale = 0.9*scalar(
labelMax - 1)/velotabSum;
607 <<
"Sum of weights has overflowed integer: " << velotabSum
608 <<
", compressing weight scale by a factor of " << rangeScale
615 if (maxWeights > minWeights)
620 velotab.setSize(cWeights.size());
624 velotab[i] = int((cWeights[i]/minWeights - 1)*rangeScale) + 1;
643 SCOTCH_Dgraph grafdat;
644 check(SCOTCH_dgraphInit(&grafdat, MPI_COMM_WORLD),
"SCOTCH_dgraphInit");
649 Pout<<
"SCOTCH_dgraphBuild with:" <<
nl
650 <<
"xadjSize-1 : " << xadjSize-1 <<
nl
651 <<
"xadj : " << uintptr_t(xadj) <<
nl
652 <<
"velotab : " << uintptr_t(velotab.begin()) <<
nl
653 <<
"adjncySize : " << adjncySize <<
nl
654 <<
"adjncy : " << uintptr_t(adjncy) <<
nl
666 const_cast<SCOTCH_Num*
>(xadj),
669 const_cast<SCOTCH_Num*
>(xadj+1),
671 const_cast<SCOTCH_Num*
>(velotab.begin()),
676 const_cast<SCOTCH_Num*
>(adjncy),
686 Pout<<
"SCOTCH_dgraphCheck" <<
endl;
688 check(SCOTCH_dgraphCheck(&grafdat),
"SCOTCH_dgraphCheck");
700 check(SCOTCH_archInit(&archdat),
"SCOTCH_archInit");
703 if (decompositionDict_.found(
"scotchCoeffs"))
705 const dictionary& scotchCoeffs =
706 decompositionDict_.subDict(
"scotchCoeffs");
708 scotchCoeffs.readIfPresent(
"processorWeights", processorWeights);
710 if (processorWeights.
size())
714 Info<<
"ptscotchDecomp : Using procesor weights "
720 SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
732 SCOTCH_archCmplt(&archdat, nProcessors_),
739 # ifdef FE_NOMASK_ENV
740 int oldExcepts = fedisableexcept
750 finalDecomp.setSize(
max(1, xadjSize-1));
769 # ifdef FE_NOMASK_ENV
770 feenableexcept(oldExcepts);
793 SCOTCH_dgraphExit(&grafdat);
795 SCOTCH_stratExit(&stradat);
797 SCOTCH_archExit(&archdat);
807 decompositionMethod(decompositionDict)
815 const polyMesh&
mesh,
823 <<
"Can use this decomposition method only for the whole mesh"
825 <<
"and supply one coordinate (cellCentre) for every cell." <<
endl
826 <<
"The number of coordinates " <<
points.size() <<
endl
827 <<
"The number of cells in the mesh " <<
mesh.
nCells()
837 CompactListList<label> cellCells;
862 decomp[i] = finalDecomp[i];
870 const polyMesh&
mesh,
879 <<
"Size of cell-to-coarse map " << agglom.size()
880 <<
" differs from number of cells in mesh " <<
mesh.
nCells()
888 CompactListList<label> cellCells;
910 labelList fineDistribution(agglom.size());
912 forAll(fineDistribution, i)
914 fineDistribution[i] = finalDecomp[agglom[i]];
917 return fineDistribution;
928 if (cellCentres.size() != globalCellCells.size())
931 <<
"Inconsistent number of cells (" << globalCellCells.size()
932 <<
") and number of cell centres (" << cellCentres.size()
941 CompactListList<label> cellCells(globalCellCells);
958 decomp[i] = finalDecomp[i];