Go to the documentation of this file.
175 <<
"Call to scotch routine " << str <<
" failed."
183 const fileName& meshPath,
206 Info<<
"scotchDecomp : running in parallel."
207 <<
" Decomposing all of graph on master processor." <<
endl;
209 globalIndex globalCells(xadj.
size()-1);
215 Field<label> allAdjncy(nTotalConnections);
216 Field<label> allXadj(globalCells.size()+1);
220 label nTotalCells = 0;
223 allXadj[nTotalCells] = xadj[cellI];
224 allWeights[nTotalCells++] = cWeights[cellI];
226 nTotalConnections = 0;
229 allAdjncy[nTotalConnections++] = adjncy[i];
235 Field<label> nbrAdjncy(fromSlave);
236 Field<label> nbrXadj(fromSlave);
243 allXadj[nTotalCells] = nTotalConnections+nbrXadj[cellI];
244 allWeights[nTotalCells++] = nbrWeights[cellI];
249 allAdjncy[nTotalConnections++] = nbrAdjncy[i];
252 allXadj[nTotalCells] = nTotalConnections;
255 Field<label> allFinalDecomp;
270 toSlave << SubField<label>
273 globalCells.localSize(slave),
274 globalCells.offset(slave)
278 finalDecomp = SubField<label>
281 globalCells.localSize()
289 toMaster<< adjncy << SubField<label>(xadj, xadj.
size()-1)
295 fromMaster >> finalDecomp;
314 if (decompositionDict_.found(
"scotchCoeffs"))
317 decompositionDict_.
subDict(
"scotchCoeffs");
323 Info<<
"Dumping Scotch graph file to " << str.
name() <<
endl
324 <<
"Use this in combination with gpart." <<
endl;
327 str << version <<
nl;
329 str << xadj.
size()-1 <<
' ' << adjncy.
size() <<
nl;
333 label hasEdgeWeights = 0;
334 label hasVertexWeights = 0;
335 label numericflag = 10*hasEdgeWeights+hasVertexWeights;
336 str << baseval <<
' ' << numericflag <<
nl;
337 for (
label cellI = 0; cellI < xadj.
size()-1; cellI++)
339 label start = xadj[cellI];
340 label end = xadj[cellI+1];
343 for (
label i = start; i < end; i++)
345 str <<
' ' << adjncy[i];
357 SCOTCH_Strat stradat;
358 check(SCOTCH_stratInit(&stradat),
"SCOTCH_stratInit");
360 if (decompositionDict_.found(
"scotchCoeffs"))
363 decompositionDict_.
subDict(
"scotchCoeffs");
370 Info<<
"scotchDecomp : Using strategy " << strategy <<
endl;
372 SCOTCH_stratGraphMap(&stradat, strategy.c_str());
388 scalar minWeights =
min(cWeights);
389 if (!cWeights.empty())
394 <<
"Illegal minimum weight " << minWeights
398 if (cWeights.size() != xadj.
size()-1)
401 <<
"Number of cell weights " << cWeights.size()
402 <<
" does not equal number of cells " << xadj.
size()-1
406 scalar velotabSum =
sum(cWeights)/minWeights;
408 scalar rangeScale(1.0);
410 if (velotabSum > scalar(
labelMax - 1))
414 rangeScale = 0.9*scalar(
labelMax - 1)/velotabSum;
417 <<
"Sum of weights has overflowed integer: " << velotabSum
418 <<
", compressing weight scale by a factor of " << rangeScale
423 velotab.
setSize(cWeights.size());
427 velotab[i] = int((cWeights[i]/minWeights - 1)*rangeScale) + 1;
433 SCOTCH_Graph grafdat;
434 check(SCOTCH_graphInit(&grafdat),
"SCOTCH_graphInit");
452 check(SCOTCH_graphCheck(&grafdat),
"SCOTCH_graphCheck");
460 check(SCOTCH_archInit(&archdat),
"SCOTCH_archInit");
463 if (decompositionDict_.found(
"scotchCoeffs"))
466 decompositionDict_.
subDict(
"scotchCoeffs");
468 scotchCoeffs.
readIfPresent(
"processorWeights", processorWeights);
470 if (processorWeights.
size())
474 Info<<
"scotchDecomp : Using procesor weights " << processorWeights
479 SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
487 SCOTCH_archCmplt(&archdat, nProcessors_),
534 # ifdef FE_NOMASK_ENV
535 int oldExcepts = fedisableexcept
557 # ifdef FE_NOMASK_ENV
558 feenableexcept(oldExcepts);
577 SCOTCH_graphExit(&grafdat);
579 SCOTCH_stratExit(&stradat);
581 SCOTCH_archExit(&archdat);
599 const polyMesh&
mesh,
607 <<
"Can use this decomposition method only for the whole mesh"
609 <<
"and supply one coordinate (cellCentre) for every cell." <<
endl
610 <<
"The number of coordinates " <<
points.size() <<
endl
611 <<
"The number of cells in the mesh " <<
mesh.
nCells()
616 CompactListList<label> cellCells;
641 decomp[i] = finalDecomp[i];
649 const polyMesh&
mesh,
658 <<
"Size of cell-to-coarse map " << agglom.size()
659 <<
" differs from number of cells in mesh " <<
mesh.
nCells()
664 CompactListList<label> cellCells;
686 labelList fineDistribution(agglom.size());
688 forAll(fineDistribution, i)
690 fineDistribution[i] = finalDecomp[agglom[i]];
693 return fineDistribution;
704 if (cellCentres.size() != globalCellCells.size())
707 <<
"Inconsistent number of cells (" << globalCellCells.size()
708 <<
") and number of cell centres (" << cellCentres.size()
717 CompactListList<label> cellCells(globalCellCells);
734 decomp[i] = finalDecomp[i];
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A class for handling file names.
List< label > labelList
A List of labels.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
#define forAll(list, i)
Loop across all elements in list.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const label labelMax
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool & parRun()
Is this a parallel run?
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label decompose(const fileName &meshPath, const List< label > &adjncy, const List< label > &xadj, const scalarField &cWeights, List< label > &finalDecomp)
static void check(const int, const char *)
Check and print error message.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
static int masterNo()
Process index of the master.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
A list of keyword definitions, which are a keyword followed by any number of values (e....
label size() const
Return number of elements in table.
Macros for easy insertion into run-time selection tables.
Abstract base class for decomposition.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static bool master(const label communicator=0)
Am I the master process.
void setSize(const label)
Reset size of List.
List< labelList > labelListList
A List of labelList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label decomposeOneProc(const fileName &meshPath, const List< label > &adjncy, const List< label > &xadj, const scalarField &cWeights, List< label > &finalDecomp)
Decompose non-parallel.
fileName path() const
Return path.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const Time & time() const
Return the top-level database.
const fileName & name() const
Return the name of the stream.
void size(const label)
Override size to be inconsistent with allocated storage.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
#define WarningInFunction
Report a warning using Foam::Warning.
scotchDecomp(const scotchDecomp &)
const word & name() const
Return reference to name.