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
94 const dictionary& metisCoeffs =
97 if (metisCoeffs.readIfPresent(
"method", method))
99 if (method !=
"recursive" && method !=
"kWay")
102 <<
"Method " << method <<
" in metisCoeffs in dictionary : "
104 <<
" should be 'recursive' or 'kWay'"
108 Info<<
"metis : Using Metis method " << method
112 if (metisCoeffs.readIfPresent(
"options", options))
114 if (options.size() != METIS_NOPTIONS)
117 <<
"Number of options in metisCoeffs dictionary : "
119 <<
" should be " << METIS_NOPTIONS <<
" found " << options
123 Info<<
"Using Metis options " << options <<
nl <<
endl;
126 if (metisCoeffs.readIfPresent(
"processorWeights", processorWeights))
128 processorWeights /=
sum(processorWeights);
133 <<
"Number of processor weights "
134 << processorWeights.size()
145 decomp.setSize(numCells);
150 if (method ==
"recursive")
152 METIS_PartGraphRecursive
162 processorWeights.begin(),
181 processorWeights.begin(),
197 decompositionMethod(decompositionDict)
205 const polyMesh& mesh,
210 if (
points.size() != mesh.nCells())
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,
258 if (cellToRegion.size() != mesh.nCells())
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.
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.
dictionary decompositionDict_
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 &)
Construct given the decomposition dictionary.
const fileName & name() const
Return the dictionary name.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#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.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< labelList > labelListList
A List of labelList.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.