38 namespace decompositionMethods
68 List<real_t> processorWeights;
70 if (processorWeights_.
size())
75 <<
"Number of processor weights specified in parMetisCoeffs "
76 << processorWeights_.
size()
77 <<
" does not equal number of constraints * number of domains "
82 processorWeights = processorWeights_;
99 globalIndex globalMap(cellCentres.size());
102 labelList cellOffsets(globalMap.offsets());
106 const label* vwgtPtr =
nullptr;
107 const label* adjwgtPtr =
nullptr;
110 if (cellWeights.size())
112 vwgtPtr = cellWeights.begin();
127 label nValidProcs = 0;
131 if (cellOffsets[proci + 1] - cellOffsets[proci] > 0)
133 validProcs[nValidProcs] = proci;
134 validCellOffsets[nValidProcs] = validCellOffsets[proci];
138 validProcs.setSize(nValidProcs);
155 decomp.setSize(cellCentres.size());
161 if (cellCentres.size())
163 if (method_ ==
"kWay")
167 validCellOffsets.begin(),
168 const_cast<label*
>(xadj.begin()),
169 const_cast<label*
>(adjncy.begin()),
170 const_cast<label*
>(vwgtPtr),
171 const_cast<label*
>(adjwgtPtr),
176 processorWeights.begin(),
184 else if (method_ ==
"geomKway")
190 List<real_t> xyz(nDims*cellCentres.size());
192 forAll(cellCentres, celli)
194 const point& cc = cellCentres[celli];
200 ParMETIS_V3_PartGeomKway
202 validCellOffsets.begin(),
203 const_cast<label*
>(xadj.begin()),
204 const_cast<label*
>(adjncy.begin()),
205 const_cast<label*
>(vwgtPtr),
206 const_cast<label*
>(adjwgtPtr),
213 processorWeights.begin(),
221 else if (method_ ==
"adaptiveRepart")
226 ParMETIS_V3_AdaptiveRepart
228 validCellOffsets.begin(),
229 const_cast<label*
>(xadj.begin()),
230 const_cast<label*
>(adjncy.begin()),
231 const_cast<label*
>(vwgtPtr),
232 const_cast<label*
>(vsize.begin()),
233 const_cast<label*
>(adjwgtPtr),
238 processorWeights.begin(),
260 nProcCells[decomp[i]]++;
263 reduce(nProcCells, ListOp<sumOp<label>>());
269 Pout<<
" No cells allocated to this processor"
270 ", keeping first cell"
288 options_(4,
label(0)),
292 if (decompositionDict.
found(
"parMetisCoeffs"))
295 decompositionDict.
subDict(
"parMetisCoeffs");
304 && method_ !=
"geomKWay"
305 && method_ !=
"adaptiveRepart"
309 <<
"Method " << method_
310 <<
" in parMetisCoeffs in dictionary : "
311 << decompositionDict.
name()
312 <<
" should be kWay, geomKWay or adaptiveRepart"
316 Info<<
" method: " << method_ <<
endl;
321 method_ ==
"adaptiveRepart"
330 if (options_.
size() != 4)
333 <<
"Number of options in parMetisCoeffs dictionary : "
334 << decompositionDict.
name()
335 <<
" should be 4, found " << options_
339 Info<<
" options: " << options_ <<
endl;
342 parMetisCoeffs.
readIfPresent(
"processorWeights_", processorWeights_);
361 <<
"Can use this decomposition method only for the whole mesh"
363 <<
"and supply one coordinate (cellCentre) for every cell." <<
endl
364 <<
"The number of coordinates " <<
points.size() <<
endl
365 <<
"The number of cells in the mesh " << mesh.
nCells()
382 label nWeights = this->nWeights(
points, pointWeights);
384 const labelList intWeights(scaleWeights(pointWeights, nWeights));
413 <<
"Size of cell-to-coarse map " << cellToRegion.
size()
414 <<
" differs from number of cells in mesh " << mesh.
nCells()
431 label nWeights = this->nWeights(regionPoints, pointWeights);
432 const labelList intWeights(scaleWeights(pointWeights, nWeights));
450 forAll(fineDistribution, i)
452 fineDistribution[i] = decomp[cellToRegion[i]];
455 return fineDistribution;
466 if (cellCentres.
size() != globalCellCells.
size())
469 <<
"Inconsistent number of cells (" << globalCellCells.
size()
470 <<
") and number of cell centres (" << cellCentres.
size()
479 label nWeights = this->nWeights(cellCentres, cellWeights);
480 const labelList intWeights(scaleWeights(cellWeights, nWeights));
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
const UList< label > & offsets() const
Return the offset table (= size()+1)
const UList< T > & m() const
Return the packed matrix of data.
iterator begin()
Return an iterator to begin traversing the UList.
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
static label worldComm
Default communicator (all processors)
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Abstract base class for decomposition.
label nWeights(const pointField &points, const scalarField &pointWeights) const
Return the number of weights per point.
ParMetis redistribution in parallel.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Inherit decompose from decompositionMethod.
parMetis(const dictionary &decompositionDict)
Construct given the decomposition dictionary.
const fileName & name() const
Return the dictionary name.
A list of keyword definitions, which are a keyword followed by any number of values (e....
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Mesh consisting of general polyhedral cells.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
DynamicList< MPI_Comm > MPICommunicators_
defineTypeNameAndDebug(metis, 0)
addToRunTimeSelectionTable(decompositionMethod, metis, decomposer)
tmp< scalarField > faceWeights(const polyMesh &mesh, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs)
Generate interpolation factors field.
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.
vector point
Point is a vector.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
prefixOSstream Pout(cout, "Pout")
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.