32 #define OMPI_SKIP_MPICXX
50 const List<label>& adjncy,
51 const List<label>& xadj,
54 List<label>& finalDecomp
60 word method(
"recursive");
62 label numCells = xadj.size()-1;
65 List<label> options(METIS_NOPTIONS);
66 METIS_SetDefaultOptions(options.begin());
70 Field<real_t> processorWeights;
73 List<label> cellWeights;
76 List<label> faceWeights;
80 scalar minWeights =
gMin(cWeights);
81 if (cWeights.size() > 0)
86 <<
"Illegal minimum weight " << minWeights
90 if (cWeights.size() != numCells)
93 <<
"Number of cell weights " << cWeights.size()
94 <<
" does not equal number of cells " << numCells
99 cellWeights.setSize(cWeights.size());
102 cellWeights[i] = int(cWeights[i]/minWeights);
110 const dictionary& metisCoeffs =
115 if (metisCoeffs.readIfPresent(
"method", method))
117 if (method !=
"recursive" && method !=
"k-way")
120 <<
"Method " << method <<
" in metisCoeffs in dictionary : "
122 <<
" should be 'recursive' or 'k-way'"
126 Info<<
"metisDecomp : Using Metis method " << method
130 if (metisCoeffs.readIfPresent(
"options", options))
132 if (options.size() != METIS_NOPTIONS)
135 <<
"Number of options in metisCoeffs in dictionary : "
137 <<
" should be " << METIS_NOPTIONS
141 Info<<
"metisDecomp : Using Metis options " << options
145 if (metisCoeffs.readIfPresent(
"processorWeights", processorWeights))
147 processorWeights /=
sum(processorWeights);
152 <<
"Number of processor weights "
153 << processorWeights.size()
164 finalDecomp.setSize(numCells);
169 if (method ==
"recursive")
171 METIS_PartGraphRecursive
175 const_cast<List<label>&
>(xadj).begin(),
176 const_cast<List<label>&
>(adjncy).begin(),
181 processorWeights.begin(),
194 const_cast<List<label>&
>(xadj).begin(),
195 const_cast<List<label>&
>(adjncy).begin(),
200 processorWeights.begin(),
216 decompositionMethod(decompositionDict)
224 const polyMesh& mesh,
229 if (
points.size() != mesh.nCells())
232 <<
"Can use this decomposition method only for the whole mesh"
234 <<
"and supply one coordinate (cellCentre) for every cell." <<
endl
235 <<
"The number of coordinates " <<
points.size() <<
endl
236 <<
"The number of cells in the mesh " << mesh.nCells()
240 CompactListList<label> cellCells;
252 decompose(cellCells.m(), cellCells.offsets(), pointWeights, decomp);
260 const polyMesh& mesh,
266 if (agglom.size() != mesh.nCells())
269 <<
"Size of cell-to-coarse map " << agglom.size()
270 <<
" differs from number of cells in mesh " << mesh.nCells()
278 CompactListList<label> cellCells;
279 calcCellCells(mesh, agglom, agglomPoints.size(),
false, cellCells);
283 decompose(cellCells.m(), cellCells.offsets(), agglomWeights, finalDecomp);
287 labelList fineDistribution(agglom.size());
289 forAll(fineDistribution, i)
291 fineDistribution[i] = finalDecomp[agglom[i]];
294 return fineDistribution;
305 if (cellCentres.size() != globalCellCells.size())
308 <<
"Inconsistent number of cells (" << globalCellCells.size()
309 <<
") and number of cell centres (" << cellCentres.size()
318 CompactListList<label> cellCells(globalCellCells);
322 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.
dictionary decompositionDict_
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.
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.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Inherit decompose from decompositionMethod.
metisDecomp(const dictionary &)
Construct given the decomposition dictionary.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
volScalarField scalarField(fieldObject, mesh)
#define WarningInFunction
Report a warning using Foam::Warning.
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.
defineTypeNameAndDebug(combustionModel, 0)
Type gMin(const FieldField< Field, Type > &f)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)