56 namespace decompositionMethods
72 void Foam::decompositionMethods::ptscotch::check
81 <<
"Call to scotch routine " << str <<
" failed."
89 const fileName& meshPath,
103 (adjncy.size() ? adjncy.begin() : dummyAdjncy.begin()),
105 (xadj.size() ? xadj.begin() : dummyXadj.begin()),
114 const fileName& meshPath,
115 const label adjncySize,
116 const label adjncy[],
117 const label xadjSize,
125 Pout<<
"ptscotch : entering with xadj:" << xadjSize <<
endl;
129 if (decompositionDict_.found(
"scotchCoeffs"))
131 const dictionary& scotchCoeffs =
132 decompositionDict_.subDict(
"scotchCoeffs");
134 if (scotchCoeffs.lookupOrDefault(
"writeGraph",
false))
141 Pout<<
"Dumping Scotch graph file to " << str.
name() <<
endl
142 <<
"Use this in combination with dgpart." <<
endl;
144 globalIndex globalCells(xadjSize-1);
148 str << version <<
nl;
155 str << globalCells.size();
157 str <<
' ' <<
returnReduce(xadj[xadjSize-1], sumOp<label>())
162 str <<
' ' << xadj[xadjSize-1] <<
nl;
166 str << baseval <<
' ' <<
"000" <<
nl;
167 for (
label celli = 0; celli < xadjSize-1; celli++)
169 label start = xadj[celli];
170 label end = xadj[celli+1];
173 for (
label i = start; i < end; i++)
175 str <<
' ' << adjncy[i];
186 SCOTCH_Strat stradat;
187 check(SCOTCH_stratInit(&stradat),
"SCOTCH_stratInit");
189 if (decompositionDict_.found(
"scotchCoeffs"))
191 const dictionary& scotchCoeffs =
192 decompositionDict_.subDict(
"scotchCoeffs");
195 if (scotchCoeffs.readIfPresent(
"strategy", strategy))
199 Info<<
"ptscotch : Using strategy " << strategy <<
endl;
201 SCOTCH_stratDgraphMap(&stradat, strategy.c_str());
214 if (cellWeights.size() != xadjSize-1)
217 <<
"Number of cell weights " << cellWeights.size()
218 <<
" does not equal number of cells " << xadjSize-1
223 velotab = scaleWeights(cellWeights, nWeights);
225 if (nWeights == 1 && !cellWeights.size())
230 velotab.setSize(1, 1);
240 SCOTCH_Dgraph grafdat;
250 Pout<<
"SCOTCH_dgraphBuild with:" <<
nl
251 <<
"xadjSize-1 : " << xadjSize-1 <<
nl
252 <<
"xadj : " << uintptr_t(xadj) <<
nl
253 <<
"velotab : " << uintptr_t(velotab.begin()) <<
nl
254 <<
"adjncySize : " << adjncySize <<
nl
255 <<
"adjncy : " << uintptr_t(adjncy) <<
nl
267 const_cast<SCOTCH_Num*
>(xadj),
270 const_cast<SCOTCH_Num*
>(xadj+1),
272 const_cast<SCOTCH_Num*
>(velotab.begin()),
277 const_cast<SCOTCH_Num*
>(adjncy),
287 Pout<<
"SCOTCH_dgraphCheck" <<
endl;
289 check(SCOTCH_dgraphCheck(&grafdat),
"SCOTCH_dgraphCheck");
302 check(SCOTCH_archInit(&archdat),
"SCOTCH_archInit");
305 if (decompositionDict_.found(
"scotchCoeffs"))
307 const dictionary& scotchCoeffs =
308 decompositionDict_.subDict(
"scotchCoeffs");
310 scotchCoeffs.readIfPresent(
"processorWeights", processorWeights);
312 if (processorWeights.size())
316 Info<<
"ptscotch : Using processor weights "
322 SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
334 SCOTCH_archCmplt(&archdat, nProcessors_),
342 int oldExcepts = fedisableexcept
352 decomp.setSize(
max(1, xadjSize-1));
372 feenableexcept(oldExcepts);
381 SCOTCH_dgraphExit(&grafdat);
384 SCOTCH_stratExit(&stradat);
387 SCOTCH_archExit(&archdat);
397 const dictionary& decompositionDict
400 decompositionMethod(decompositionDict)
408 const polyMesh& mesh,
413 if (
points.size() != mesh.nCells())
416 <<
"Can use this decomposition method only for the whole mesh"
418 <<
"and supply one coordinate (cellCentre) for every cell." <<
endl
419 <<
"The number of coordinates " <<
points.size() <<
endl
420 <<
"The number of cells in the mesh " << mesh.nCells()
429 CompactListList<label> cellCells;
443 mesh.time().path()/mesh.name(),
456 const polyMesh& mesh,
462 if (agglom.size() != mesh.nCells())
465 <<
"Size of cell-to-coarse map " << agglom.size()
466 <<
" differs from number of cells in mesh " << mesh.nCells()
470 checkWeights(agglomPoints, pointWeights);
475 CompactListList<label> cellCells;
489 mesh.time().path()/mesh.name(),
497 labelList fineDistribution(agglom.size());
499 forAll(fineDistribution, i)
501 fineDistribution[i] = decomp[agglom[i]];
504 return fineDistribution;
515 if (cellCentres.size() != globalCellCells.size())
518 <<
"Inconsistent number of cells (" << globalCellCells.size()
519 <<
") and number of cell centres (" << cellCentres.size()
523 checkWeights(cellCentres, cellWeights);
528 CompactListList<label> cellCells(globalCellCells);
#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 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)
label checkWeights(const pointField &points, const scalarField &pointWeights) const
Check the weights against the points.
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.
ptscotch(const dictionary &decompositionDict)
Construct given the decomposition dictionary.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
volScalarField scalarField(fieldObject, mesh)
defineTypeNameAndDebug(metis, 0)
addToRunTimeSelectionTable(decompositionMethod, metis, decomposer)
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
word name(const bool)
Return a word representation of a bool.
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)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
prefixOSstream Pout(cout, "Pout")
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.