54 namespace decompositionMethods
77 void Foam::decompositionMethods::scotch::check
86 <<
"Call to scotch routine " << str <<
" failed."
116 Info<<
"scotch : running in parallel."
117 <<
" Decomposing all of graph on master processor." <<
endl;
119 globalIndex globalCells(xadj.size()-1);
125 Field<label> allAdjncy(nTotalConnections);
126 Field<label> allXadj(globalCells.size()+1);
130 label nTotalCells = 0;
131 forAll(cellWeights, celli)
133 allXadj[nTotalCells] = xadj[celli];
134 allWeights[nTotalCells++] = cellWeights[celli];
136 nTotalConnections = 0;
139 allAdjncy[nTotalConnections++] = adjncy[i];
145 Field<label> nbrAdjncy(fromSlave);
146 Field<label> nbrXadj(fromSlave);
153 allXadj[nTotalCells] = nTotalConnections+nbrXadj[celli];
154 allWeights[nTotalCells++] = nbrWeights[celli];
159 allAdjncy[nTotalConnections++] = nbrAdjncy[i];
162 allXadj[nTotalCells] = nTotalConnections;
165 Field<label> allFinalDecomp;
180 toSlave << SubField<label>
183 globalCells.localSize(slave),
184 globalCells.offset(slave)
188 decomp = SubField<label>
191 globalCells.localSize()
203 toMaster<< adjncy << SubField<label>(xadj, xadj.size()-1)
213 fromMaster >> decomp;
220 Foam::label Foam::decompositionMethods::scotch::decomposeOneProc
231 if (!methodDict_.empty())
233 if (methodDict_.lookupOrDefault(
"writeGraph",
false))
237 Info<<
"Dumping Scotch graph file to " << str.name() <<
endl
238 <<
"Use this in combination with gpart." <<
endl;
241 str << version <<
nl;
243 str << xadj.size()-1 <<
' ' << adjncy.size() <<
nl;
247 label hasEdgeWeights = 0;
248 label hasVertexWeights = 0;
249 label numericflag = 10*hasEdgeWeights+hasVertexWeights;
250 str << baseval <<
' ' << numericflag <<
nl;
251 for (
label celli = 0; celli < xadj.size()-1; celli++)
253 label start = xadj[celli];
254 label end = xadj[celli+1];
257 for (
label i = start; i < end; i++)
259 str <<
' ' << adjncy[i];
271 SCOTCH_randomReset();
277 SCOTCH_Strat stradat;
278 check(SCOTCH_stratInit(&stradat),
"SCOTCH_stratInit");
280 if (!methodDict_.empty())
283 if (methodDict_.readIfPresent(
"strategy", strategy))
287 Info<<
"scotch : Using strategy " << strategy <<
endl;
289 SCOTCH_stratGraphMap(&stradat, strategy.c_str());
300 if (!cellWeights.empty())
302 if (cellWeights.size() != xadj.size()-1)
305 <<
"Number of cell weights " << cellWeights.size()
306 <<
" does not equal number of cells " << xadj.size()-1
311 velotab = scaleWeights(cellWeights, nWeights,
false);
315 SCOTCH_Graph grafdat;
316 check(SCOTCH_graphInit(&grafdat),
"SCOTCH_graphInit");
334 check(SCOTCH_graphCheck(&grafdat),
"SCOTCH_graphCheck");
342 check(SCOTCH_archInit(&archdat),
"SCOTCH_archInit");
345 if (!methodDict_.empty())
347 methodDict_.readIfPresent(
"processorWeights", processorWeights);
349 if (processorWeights.size())
353 Info<<
"scotch : Using processor weights " << processorWeights
358 SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
366 SCOTCH_archCmplt(&archdat, nProcessors_),
373 int oldExcepts = fedisableexcept
381 decomp.setSize(xadj.size()-1);
396 feenableexcept(oldExcepts);
400 SCOTCH_graphExit(&grafdat);
403 SCOTCH_stratExit(&stradat);
406 SCOTCH_archExit(&archdat);
416 const dictionary& decompositionDict,
417 const dictionary& methodDict
420 decompositionMethod(decompositionDict),
421 methodDict_(methodDict)
429 const polyMesh&
mesh,
437 <<
"Can use this decomposition method only for the whole mesh"
439 <<
"and supply one coordinate (cellCentre) for every cell." <<
endl
440 <<
"The number of coordinates " <<
points.size() <<
endl
441 <<
"The number of cells in the mesh " <<
mesh.
nCells()
448 CompactListList<label> cellCells;
475 const polyMesh&
mesh,
484 <<
"Size of cell-to-coarse map " << agglom.size()
485 <<
" differs from number of cells in mesh " <<
mesh.
nCells()
489 checkWeights(agglomPoints, pointWeights);
492 CompactListList<label> cellCells;
514 labelList fineDistribution(agglom.size());
516 forAll(fineDistribution, i)
518 fineDistribution[i] = decomp[agglom[i]];
521 return fineDistribution;
532 if (cellCentres.size() != globalCellCells.size())
535 <<
"Inconsistent number of cells (" << globalCellCells.size()
536 <<
") and number of cell centres (" << cellCentres.size()
540 checkWeights(cellCentres, cellWeights);
546 CompactListList<label> cellCells(globalCellCells);
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
fileName path() const
Explicitly inherit path from TimePaths to disambiguate from.
static int masterNo()
Process index of the master.
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 bool & parRun()
Is this a parallel run?
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.
scotch(const dictionary &decompositionDict, const dictionary &methodDict)
Construct given the decomposition dictionary and mesh.
const Time & time() const
Return the top-level database.
label size() const
Return fvMesh size.
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)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.