63 void Foam::ptscotchDecomp::check(
const int retVal,
const char* str)
68 <<
"Call to scotch routine " << str <<
" failed." 269 const fileName& meshPath,
270 const List<label>& adjncy,
271 const List<label>& xadj,
273 List<label>& finalDecomp
276 List<label> dummyAdjncy(1);
277 List<label> dummyXadj(1);
284 (adjncy.size() ? adjncy.begin() : dummyAdjncy.begin()),
286 (xadj.size() ? xadj.begin() : dummyXadj.begin()),
296 const fileName& meshPath,
297 const label adjncySize,
298 const label adjncy[],
299 const label xadjSize,
303 List<label>& finalDecomp
308 Pout<<
"ptscotchDecomp : entering with xadj:" << xadjSize <<
endl;
312 if (decompositionDict_.found(
"scotchCoeffs"))
314 const dictionary& scotchCoeffs =
315 decompositionDict_.subDict(
"scotchCoeffs");
317 if (scotchCoeffs.lookupOrDefault(
"writeGraph",
false))
324 Pout<<
"Dumping Scotch graph file to " << str.
name() << endl
325 <<
"Use this in combination with dgpart." <<
endl;
327 globalIndex globalCells(xadjSize-1);
331 str << version <<
nl;
338 str << globalCells.size();
340 str <<
' ' <<
returnReduce(xadj[xadjSize-1], sumOp<label>())
345 str <<
' ' << xadj[xadjSize-1] <<
nl;
349 str << baseval <<
' ' <<
"000" <<
nl;
350 for (
label celli = 0; celli < xadjSize-1; celli++)
352 label start = xadj[celli];
353 label end = xadj[celli+1];
356 for (
label i = start; i < end; i++)
358 str <<
' ' << adjncy[i];
369 SCOTCH_Strat stradat;
370 check(SCOTCH_stratInit(&stradat),
"SCOTCH_stratInit");
372 if (decompositionDict_.found(
"scotchCoeffs"))
374 const dictionary& scotchCoeffs =
375 decompositionDict_.subDict(
"scotchCoeffs");
379 if (scotchCoeffs.readIfPresent(
"strategy", strategy))
383 Info<<
"ptscotchDecomp : Using strategy " << strategy <<
endl;
385 SCOTCH_stratDgraphMap(&stradat, strategy.c_str());
401 scalar minWeights =
gMin(cWeights);
402 scalar maxWeights =
gMax(cWeights);
404 if (maxWeights > minWeights)
409 <<
"Illegal minimum weight " << minWeights
413 if (cWeights.size() != xadjSize-1)
416 <<
"Number of cell weights " << cWeights.size()
417 <<
" does not equal number of cells " << xadjSize-1
422 scalar velotabSum =
gSum(cWeights)/minWeights;
424 scalar rangeScale(1.0);
428 if (velotabSum > scalar(
labelMax - 1))
432 rangeScale = 0.9*scalar(
labelMax - 1)/velotabSum;
435 <<
"Sum of weights has overflowed integer: " << velotabSum
436 <<
", compressing weight scale by a factor of " << rangeScale
443 if (maxWeights > minWeights)
448 velotab.setSize(cWeights.size());
452 velotab[i] = int((cWeights[i]/minWeights - 1)*rangeScale) + 1;
471 SCOTCH_Dgraph grafdat;
481 Pout<<
"SCOTCH_dgraphBuild with:" << nl
482 <<
"xadjSize-1 : " << xadjSize-1 << nl
483 <<
"xadj : " << uintptr_t(xadj) << nl
484 <<
"velotab : " << uintptr_t(velotab.begin()) << nl
485 <<
"adjncySize : " << adjncySize << nl
486 <<
"adjncy : " << uintptr_t(adjncy) << nl
498 const_cast<SCOTCH_Num*>(xadj),
501 const_cast<SCOTCH_Num*>(xadj+1),
503 const_cast<SCOTCH_Num*>(velotab.begin()),
508 const_cast<SCOTCH_Num*>(adjncy),
518 Pout<<
"SCOTCH_dgraphCheck" <<
endl;
520 check(SCOTCH_dgraphCheck(&grafdat),
"SCOTCH_dgraphCheck");
532 check(SCOTCH_archInit(&archdat),
"SCOTCH_archInit");
534 List<label> processorWeights;
535 if (decompositionDict_.found(
"scotchCoeffs"))
537 const dictionary& scotchCoeffs =
538 decompositionDict_.subDict(
"scotchCoeffs");
540 scotchCoeffs.readIfPresent(
"processorWeights", processorWeights);
542 if (processorWeights.size())
546 Info<<
"ptscotchDecomp : Using processor weights " 552 SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
564 SCOTCH_archCmplt(&archdat, nProcessors_),
572 int oldExcepts = fedisableexcept
582 finalDecomp.setSize(
max(1, xadjSize-1));
602 feenableexcept(oldExcepts);
625 SCOTCH_dgraphExit(&grafdat);
627 SCOTCH_stratExit(&stradat);
629 SCOTCH_archExit(&archdat);
639 decompositionMethod(decompositionDict)
647 const polyMesh& mesh,
652 if (points.size() != mesh.nCells())
655 <<
"Can use this decomposition method only for the whole mesh" 657 <<
"and supply one coordinate (cellCentre) for every cell." << endl
658 <<
"The number of coordinates " << points.size() << endl
659 <<
"The number of cells in the mesh " << mesh.nCells()
669 CompactListList<label> cellCells;
680 List<label> finalDecomp;
683 mesh.time().path()/mesh.name(),
694 decomp[i] = finalDecomp[i];
702 const polyMesh& mesh,
708 if (agglom.size() != mesh.nCells())
711 <<
"Size of cell-to-coarse map " << agglom.size()
712 <<
" differs from number of cells in mesh " << mesh.nCells()
720 CompactListList<label> cellCells;
731 List<label> finalDecomp;
734 mesh.time().path()/mesh.name(),
742 labelList fineDistribution(agglom.size());
744 forAll(fineDistribution, i)
746 fineDistribution[i] = finalDecomp[agglom[i]];
749 return fineDistribution;
760 if (cellCentres.size() != globalCellCells.size())
763 <<
"Inconsistent number of cells (" << globalCellCells.size()
764 <<
") and number of cell centres (" << cellCentres.size()
773 CompactListList<label> cellCells(globalCellCells);
776 List<label> finalDecomp;
790 decomp[i] = finalDecomp[i];
virtual const fileName & name() const
Return the name of the stream.
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
ptscotchDecomp(const dictionary &decompositionDict)
Construct given the decomposition dictionary and mesh.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gMin(const FieldField< Field, Type > &f)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Macros for easy insertion into run-time selection tables.
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.
vectorField pointField
pointField is a vectorField.
Type gSum(const FieldField< Field, Type > &f)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static const label labelMax
List< label > labelList
A List of labels.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Type gMax(const FieldField< Field, Type > &f)
defineTypeNameAndDebug(combustionModel, 0)
word name(const complex &)
Return a string representation of a complex.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
#define WarningInFunction
Report a warning using Foam::Warning.
prefixOSstream Pout(cout, "Pout")
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)