32 #define OMPI_SKIP_MPICXX
41 namespace decompositionMethods
62 word method(
"recursive");
64 label numCells = xadj.size()-1;
68 METIS_SetDefaultOptions(options.begin());
72 Field<real_t> processorWeights;
74 if (cellWeights.size() > 0 && cellWeights.size() != numCells)
77 <<
"Number of cell weights " << cellWeights.size()
78 <<
" does not equal number of cells " << numCells
92 if (!methodDict_.empty())
96 if (method !=
"recursive" && method !=
"kWay")
99 <<
"Method " << method
100 <<
" should be 'recursive' or 'kWay'"
104 Info<<
"metis : Using Metis method " << method
110 if (options.size() != METIS_NOPTIONS)
113 <<
"Number of options should be " << METIS_NOPTIONS
114 <<
" found " << options
118 Info<<
"Using Metis options " << options <<
nl <<
endl;
121 if (methodDict_.
readIfPresent(
"processorWeights", processorWeights))
123 processorWeights /=
sum(processorWeights);
128 <<
"Number of processor weights "
129 << processorWeights.size()
140 decomp.setSize(numCells);
145 if (method ==
"recursive")
147 METIS_PartGraphRecursive
157 processorWeights.begin(),
176 processorWeights.begin(),
192 const dictionary& decompositionDict,
193 const dictionary& methodDict
196 decompositionMethod(decompositionDict),
197 methodDict_(methodDict)
205 const polyMesh&
mesh,
213 <<
"Can use this decomposition method only for the whole mesh"
215 <<
"and supply one coordinate (cellCentre) for every cell." <<
endl
216 <<
"The number of coordinates " <<
points.size() <<
endl
217 <<
"The number of cells in the mesh " <<
mesh.
nCells()
226 CompactListList<label> cellCells;
252 const polyMesh&
mesh,
261 <<
"Size of cell-to-coarse map " << cellToRegion.size()
262 <<
" differs from number of cells in mesh " <<
mesh.
nCells()
266 checkWeights(regionPoints, regionWeights);
272 CompactListList<label> cellCells;
273 calcCellCells(
mesh, cellToRegion, regionPoints.
size(),
false, cellCells);
277 decompose(cellCells.m(), cellCells.offsets(), regionWeights, decomp);
281 labelList fineDistribution(cellToRegion.size());
283 forAll(fineDistribution, i)
285 fineDistribution[i] = decomp[cellToRegion[i]];
288 return fineDistribution;
299 if (cellCentres.size() != globalCellCells.size())
302 <<
"Inconsistent number of cells (" << globalCellCells.size()
303 <<
") and number of cell centres (" << cellCentres.size()
307 checkWeights(cellCentres, cellWeights);
312 CompactListList<label> cellCells(globalCellCells);
316 decompose(cellCells.m(), cellCells.offsets(), cellWeights, decomp);
#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.
iterator begin()
Return an iterator to begin traversing the UList.
label nWeights(const pointField &points, const scalarField &pointWeights) const
Return the number of weights per point.
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.
static labelList scaleWeights(const scalarField &weights, label &nWeights, const bool distributed=true)
Convert the given scalar weights to labels.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Inherit decompose from decompositionMethod.
metis(const dictionary &decompositionDict, const dictionary &methodDict)
Construct given the decomposition dictionary.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
volScalarField scalarField(fieldObject, mesh)
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.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< labelList > labelListList
A List of labelList.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.