35#define MPICH_SKIP_MPICXX
36#define OMPI_SKIP_MPICXX
71 const labelList& adjncy,
72 const labelList& xadj,
73 const List<scalar>& cWeights,
80 word method(
"recursive");
84 idx_t numCells =
max(0, (xadj.size()-1));
87 List<idx_t> options(METIS_NOPTIONS);
88 METIS_SetDefaultOptions(options.data());
92 Field<real_t> procWeights;
95 List<idx_t> cellWeights;
98 List<idx_t> faceWeights;
102 const scalar minWeights =
min(cWeights);
104 if (!cWeights.empty())
109 <<
"Illegal minimum weight " << minWeights
113 if (cWeights.size() != numCells)
116 <<
"Number of cell weights " << cWeights.size()
117 <<
" does not equal number of cells " << numCells
122 cellWeights.setSize(cWeights.size());
125 cellWeights[i] = idx_t(cWeights[i]/minWeights);
133 const dictionary& coeffDict = *coeffsDictPtr;
137 if (coeffDict.readIfPresent(
"method", method))
139 if (method !=
"recursive" && method !=
"k-way")
142 <<
"Method " << method <<
" in metisCoeffs in dictionary : "
144 <<
" should be 'recursive' or 'k-way'"
148 Info<<
"metisDecomp : Using Metis method " << method
152 if (coeffDict.readIfPresent(
"options", options))
154 if (options.size() != METIS_NOPTIONS)
157 <<
"Number of options in metisCoeffs in dictionary : "
159 <<
" should be " << METIS_NOPTIONS
163 Info<<
"metisDecomp : Using Metis options " << options
167 if (coeffDict.readIfPresent(
"processorWeights", procWeights))
172 <<
"processorWeights (" << procWeights.size()
173 <<
") != number of domains (" <<
nDomains_ <<
")" <<
nl
177 procWeights /=
sum(procWeights);
185 ConstPrecisionAdaptor<idx_t, label, List> xadj_param(xadj);
186 ConstPrecisionAdaptor<idx_t, label, List> adjncy_param(adjncy);
189 decomp.resize(numCells);
190 PrecisionAdaptor<idx_t, label, List> decomp_param(decomp,
false);
193 labelList adjncy_dummy, xadj_dummy, decomp_dummy;
196 adjncy_dummy.
resize(1, 0);
197 adjncy_param.set(adjncy_dummy);
199 xadj_dummy.resize(2, 0);
200 xadj_param.set(xadj_dummy);
202 decomp_dummy.resize(1, 0);
203 decomp_param.clear();
204 decomp_param.set(decomp_dummy);
215 if (method ==
"recursive")
217 METIS_PartGraphRecursive
221 xadj_param.constCast().data(),
222 adjncy_param.constCast().data(),
231 decomp_param.ref().data()
240 xadj_param.constCast().data(),
241 adjncy_param.constCast().data(),
250 decomp_param.ref().data()
262 const dictionary& decompDict,
266 metisLikeDecomp(typeName, decompDict,
regionName, selectionType::NULL_DICT)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void resize(const label len)
Adjust allocated size of list.
label nDomains_
Number of domains for the decomposition.
const dictionary & decompDict_
Top-level decomposition dictionary (eg, decomposeParDict)
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
const fileName & name() const noexcept
The dictionary name.
Metis domain decomposition.
virtual label decomposeSerial(const labelList &adjncy, const labelList &xadj, const List< scalar > &cellWeights, labelList &decomp) const
Decompose non-parallel.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::word regionName(Foam::polyMesh::defaultRegion)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.