69 void Foam::ptscotchDecomp::check(
const int retVal,
const char* str)
74 <<
"Call to scotch routine " << str <<
" failed."
274 const fileName& meshPath,
275 const List<label>& adjncy,
276 const List<label>& xadj,
278 List<label>& finalDecomp
281 List<label> dummyAdjncy(1);
282 List<label> dummyXadj(1);
289 (adjncy.size() ? adjncy.begin() : dummyAdjncy.begin()),
291 (xadj.size() ? xadj.begin() : dummyXadj.begin()),
300 const fileName& meshPath,
301 const label adjncySize,
302 const label adjncy[],
303 const label xadjSize,
307 List<label>& finalDecomp
312 Pout<<
"ptscotchDecomp : entering with xadj:" << xadjSize <<
endl;
316 if (decompositionDict_.found(
"scotchCoeffs"))
318 const dictionary& scotchCoeffs =
319 decompositionDict_.subDict(
"scotchCoeffs");
321 if (scotchCoeffs.lookupOrDefault(
"writeGraph",
false))
328 Pout<<
"Dumping Scotch graph file to " << str.
name() <<
endl
329 <<
"Use this in combination with dgpart." <<
endl;
331 globalIndex globalCells(xadjSize-1);
335 str << version <<
nl;
342 str << globalCells.size();
344 str <<
' ' <<
returnReduce(xadj[xadjSize-1], sumOp<label>())
349 str <<
' ' << xadj[xadjSize-1] <<
nl;
353 str << baseval <<
' ' <<
"000" <<
nl;
354 for (
label celli = 0; celli < xadjSize-1; celli++)
356 label start = xadj[celli];
357 label end = xadj[celli+1];
360 for (
label i = start; i < end; i++)
362 str <<
' ' << adjncy[i];
373 SCOTCH_Strat stradat;
374 check(SCOTCH_stratInit(&stradat),
"SCOTCH_stratInit");
376 if (decompositionDict_.found(
"scotchCoeffs"))
378 const dictionary& scotchCoeffs =
379 decompositionDict_.subDict(
"scotchCoeffs");
383 if (scotchCoeffs.readIfPresent(
"strategy", strategy))
387 Info<<
"ptscotchDecomp : Using strategy " << strategy <<
endl;
389 SCOTCH_stratDgraphMap(&stradat, strategy.c_str());
405 scalar minWeights =
gMin(cWeights);
406 scalar maxWeights =
gMax(cWeights);
408 if (maxWeights > minWeights)
413 <<
"Illegal minimum weight " << minWeights
417 if (cWeights.size() != xadjSize-1)
420 <<
"Number of cell weights " << cWeights.size()
421 <<
" does not equal number of cells " << xadjSize-1
426 scalar velotabSum =
gSum(cWeights)/minWeights;
428 scalar rangeScale(1.0);
432 if (velotabSum > scalar(
labelMax - 1))
436 rangeScale = 0.9*scalar(
labelMax - 1)/velotabSum;
439 <<
"Sum of weights has overflowed integer: " << velotabSum
440 <<
", compressing weight scale by a factor of " << rangeScale
447 if (maxWeights > minWeights)
452 velotab.setSize(cWeights.size());
456 velotab[i] = int((cWeights[i]/minWeights - 1)*rangeScale) + 1;
475 SCOTCH_Dgraph grafdat;
485 Pout<<
"SCOTCH_dgraphBuild with:" <<
nl
486 <<
"xadjSize-1 : " << xadjSize-1 <<
nl
487 <<
"xadj : " << uintptr_t(xadj) <<
nl
488 <<
"velotab : " << uintptr_t(velotab.begin()) <<
nl
489 <<
"adjncySize : " << adjncySize <<
nl
490 <<
"adjncy : " << uintptr_t(adjncy) <<
nl
502 const_cast<SCOTCH_Num*
>(xadj),
505 const_cast<SCOTCH_Num*
>(xadj+1),
507 const_cast<SCOTCH_Num*
>(velotab.begin()),
512 const_cast<SCOTCH_Num*
>(adjncy),
522 Pout<<
"SCOTCH_dgraphCheck" <<
endl;
524 check(SCOTCH_dgraphCheck(&grafdat),
"SCOTCH_dgraphCheck");
536 check(SCOTCH_archInit(&archdat),
"SCOTCH_archInit");
538 List<label> processorWeights;
539 if (decompositionDict_.found(
"scotchCoeffs"))
541 const dictionary& scotchCoeffs =
542 decompositionDict_.subDict(
"scotchCoeffs");
544 scotchCoeffs.readIfPresent(
"processorWeights", processorWeights);
546 if (processorWeights.size())
550 Info<<
"ptscotchDecomp : Using processor weights "
556 SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
568 SCOTCH_archCmplt(&archdat, nProcessors_),
576 int oldExcepts = fedisableexcept
586 finalDecomp.setSize(
max(1, xadjSize-1));
606 feenableexcept(oldExcepts);
630 SCOTCH_dgraphExit(&grafdat);
633 SCOTCH_stratExit(&stradat);
636 SCOTCH_archExit(&archdat);
646 decompositionMethod(decompositionDict)
654 const polyMesh& mesh,
659 if (
points.size() != mesh.nCells())
662 <<
"Can use this decomposition method only for the whole mesh"
664 <<
"and supply one coordinate (cellCentre) for every cell." <<
endl
665 <<
"The number of coordinates " <<
points.size() <<
endl
666 <<
"The number of cells in the mesh " << mesh.nCells()
676 CompactListList<label> cellCells;
687 List<label> finalDecomp;
690 mesh.time().path()/mesh.name(),
701 decomp[i] = finalDecomp[i];
709 const polyMesh& mesh,
715 if (agglom.size() != mesh.nCells())
718 <<
"Size of cell-to-coarse map " << agglom.size()
719 <<
" differs from number of cells in mesh " << mesh.nCells()
727 CompactListList<label> cellCells;
738 List<label> finalDecomp;
741 mesh.time().path()/mesh.name(),
749 labelList fineDistribution(agglom.size());
751 forAll(fineDistribution, i)
753 fineDistribution[i] = finalDecomp[agglom[i]];
756 return fineDistribution;
767 if (cellCentres.size() != globalCellCells.size())
770 <<
"Inconsistent number of cells (" << globalCellCells.size()
771 <<
") and number of cell centres (" << cellCentres.size()
780 CompactListList<label> cellCells(globalCellCells);
783 List<label> finalDecomp;
797 decomp[i] = finalDecomp[i];
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
virtual const fileName & name() const
Return the name of the stream.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
static bool master(const label communicator=0)
Am I the master process.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static void calcCellCells(const polyMesh &mesh, const labelList &agglom, const label nLocalCoarse, const bool global, CompactListList< label > &cellCells)
Helper: determine (local or global) cellCells from mesh.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Inherit decompose from decompositionMethod.
ptscotchDecomp(const dictionary &decompositionDict)
Construct given the decomposition dictionary and mesh.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
volScalarField scalarField(fieldObject, mesh)
#define WarningInFunction
Report a warning using Foam::Warning.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gSum(const FieldField< Field, Type > &f)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< labelList > labelListList
A List of labelList.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
prefixOSstream Pout(cout, "Pout")
Type gMin(const FieldField< Field, Type > &f)
static const label labelMax
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
word name(const complex &)
Return a string representation of a complex.
Type gMax(const FieldField< Field, Type > &f)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)