56 namespace decompositionMethods
72 void Foam::decompositionMethods::ptscotch::check
81 <<
"Call to scotch routine " << str <<
" failed."
103 (adjncy.size() ? adjncy.begin() : dummyAdjncy.begin()),
105 (xadj.size() ? xadj.begin() : dummyXadj.begin()),
115 const label adjncySize,
116 const label adjncy[],
117 const label xadjSize,
125 Pout<<
"ptscotch : entering with xadj:" << xadjSize <<
endl;
129 if (!methodDict_.empty())
131 if (methodDict_.lookupOrDefault(
"writeGraph",
false))
138 Pout<<
"Dumping Scotch graph file to " << str.
name() <<
endl
139 <<
"Use this in combination with dgpart." <<
endl;
141 globalIndex globalCells(xadjSize-1);
145 str << version <<
nl;
152 str << globalCells.size();
154 str <<
' ' <<
returnReduce(xadj[xadjSize-1], sumOp<label>())
159 str <<
' ' << xadj[xadjSize-1] <<
nl;
163 str << baseval <<
' ' <<
"000" <<
nl;
164 for (
label celli = 0; celli < xadjSize-1; celli++)
166 label start = xadj[celli];
167 label end = xadj[celli+1];
170 for (
label i = start; i < end; i++)
172 str <<
' ' << adjncy[i];
183 SCOTCH_Strat stradat;
184 check(SCOTCH_stratInit(&stradat),
"SCOTCH_stratInit");
186 if (!methodDict_.empty())
189 if (methodDict_.readIfPresent(
"strategy", strategy))
193 Info<<
"ptscotch : Using strategy " << strategy <<
endl;
195 SCOTCH_stratDgraphMap(&stradat, strategy.c_str());
208 if (cellWeights.size() != xadjSize-1)
211 <<
"Number of cell weights " << cellWeights.size()
212 <<
" does not equal number of cells " << xadjSize-1
217 velotab = scaleWeights(cellWeights, nWeights);
219 if (nWeights == 1 && !cellWeights.size())
224 velotab.setSize(1, 1);
234 SCOTCH_Dgraph grafdat;
244 Pout<<
"SCOTCH_dgraphBuild with:" <<
nl
245 <<
"xadjSize-1 : " << xadjSize-1 <<
nl
246 <<
"xadj : " << uintptr_t(xadj) <<
nl
247 <<
"velotab : " << uintptr_t(velotab.begin()) <<
nl
248 <<
"adjncySize : " << adjncySize <<
nl
249 <<
"adjncy : " << uintptr_t(adjncy) <<
nl
261 const_cast<SCOTCH_Num*
>(xadj),
264 const_cast<SCOTCH_Num*
>(xadj+1),
266 const_cast<SCOTCH_Num*
>(velotab.begin()),
271 const_cast<SCOTCH_Num*
>(adjncy),
281 Pout<<
"SCOTCH_dgraphCheck" <<
endl;
283 check(SCOTCH_dgraphCheck(&grafdat),
"SCOTCH_dgraphCheck");
296 check(SCOTCH_archInit(&archdat),
"SCOTCH_archInit");
299 if (!methodDict_.empty())
301 methodDict_.readIfPresent(
"processorWeights", processorWeights);
303 if (processorWeights.size())
307 Info<<
"ptscotch : Using processor weights "
313 SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
325 SCOTCH_archCmplt(&archdat, nProcessors_),
333 int oldExcepts = fedisableexcept
343 decomp.setSize(
max(1, xadjSize-1));
363 feenableexcept(oldExcepts);
372 SCOTCH_dgraphExit(&grafdat);
375 SCOTCH_stratExit(&stradat);
378 SCOTCH_archExit(&archdat);
388 const dictionary& decompositionDict,
389 const dictionary& methodDict
392 decompositionMethod(decompositionDict),
393 methodDict_(methodDict)
401 const polyMesh&
mesh,
409 <<
"Can use this decomposition method only for the whole mesh"
411 <<
"and supply one coordinate (cellCentre) for every cell." <<
endl
412 <<
"The number of coordinates " <<
points.size() <<
endl
413 <<
"The number of cells in the mesh " <<
mesh.
nCells()
422 CompactListList<label> cellCells;
449 const polyMesh&
mesh,
458 <<
"Size of cell-to-coarse map " << agglom.size()
459 <<
" differs from number of cells in mesh " <<
mesh.
nCells()
463 checkWeights(agglomPoints, pointWeights);
468 CompactListList<label> cellCells;
490 labelList fineDistribution(agglom.size());
492 forAll(fineDistribution, i)
494 fineDistribution[i] = decomp[agglom[i]];
497 return fineDistribution;
508 if (cellCentres.size() != globalCellCells.size())
511 <<
"Inconsistent number of cells (" << globalCellCells.size()
512 <<
") and number of cell centres (" << cellCentres.size()
516 checkWeights(cellCentres, cellWeights);
521 CompactListList<label> cellCells(globalCellCells);
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
label size() const
Return number of elements in table.
virtual const fileName & name() const
Return the name of the stream.
fileName path() const
Explicitly inherit path from TimePaths to disambiguate from.
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, const dictionary &methodDict)
Construct given the decomposition dictionary.
const Time & time() const
Return the top-level database.
const word & name() const
Return reference to name.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#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.
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)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.