33#include "kaHIP_interface.h"
62 { kahipDecomp::configs::FAST,
"fast" },
63 { kahipDecomp::configs::ECO,
"eco" },
64 { kahipDecomp::configs::STRONG,
"strong" },
65 { kahipDecomp::configs::FASTSOCIAL,
"fast-social" },
66 { kahipDecomp::configs::ECOSOCIAL,
"eco-social" },
67 { kahipDecomp::configs::STRONGSOCIAL,
"strong-social" },
75 const labelList& adjncy,
76 const labelList& xadj,
77 const List<scalar>& cWeights,
83 double imbalance = 0.01;
87 #if WM_LABEL_SIZE == 64
88 if (xadj.size()-1 > INT_MAX)
91 <<
"Cannot decompose " << (xadj.size()-1) <<
" cells," <<
nl
92 <<
"Exceeded integer limit of " << INT_MAX <<
nl
97 int numCells =
max(0, (xadj.size()-1));
100 ConstPrecisionAdaptor<int, label, List> adjncy_param(adjncy);
101 ConstPrecisionAdaptor<int, label, List> xadj_param(xadj);
104 decomp.resize(numCells);
106 PrecisionAdaptor<int, label, List> decomp_param(decomp,
false);
109 labelList adjncy_dummy, xadj_dummy, decomp_dummy;
112 adjncy_dummy.
resize(1, 0);
113 adjncy_param.set(adjncy_dummy);
115 xadj_dummy.resize(2, 0);
116 xadj_param.set(xadj_dummy);
118 decomp_dummy.resize(1, 0);
119 decomp_param.clear();
120 decomp_param.set(decomp_dummy);
129 bool hasWeights = !cWeights.empty();
132 const scalar minWeights = hasWeights ?
min(cWeights) : scalar(1);
138 <<
"Illegal minimum weight " << minWeights
142 else if (hasWeights && (cWeights.size() != numCells))
145 <<
"Number of cell weights " << cWeights.size()
146 <<
" does not equal number of cells " << numCells
151 List<int> cellWeights;
156 cellWeights.resize(cWeights.size());
159 cellWeights[i] =
static_cast<int>
161 cWeights[i]/minWeights
170 Info<<
"kahipDecomp :"
172 <<
" imbalance=" << imbalance;
176 Info<<
" seed=" << seed;
180 std::map<std::string, std::vector<int>> sizingParams;
189 std::vector<int> vec;
190 vec.reserve(labels.size()+1);
195 for (
const auto val : labels)
208 <<
"Mismatch in number of processors and "
222 sizingParams[
"hierarchy"] = std::move(vec);
233 std::vector<int> vec(labels.size());
240 sizingParams[
"distance"] = std::move(vec);
258 (cellWeights.empty() ?
nullptr : cellWeights.data()),
259 xadj_param.constCast().data(),
261 adjncy_param.constCast().data(),
268 decomp_param.ref().data(),
275 (cellWeights.empty() ?
nullptr : cellWeights.data()),
276 xadj_param.constCast().data(),
278 adjncy_param.constCast().data(),
285 decomp_param.ref().data()
297 const dictionary& decompDict,
301 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.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
bool readIfPresent(const word &key, const dictionary &dict, EnumType &val) const
Find an entry if present, and assign to T val.
void resize(const label len)
Adjust allocated size of list.
label nDomains_
Number of domains for the decomposition.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Domain decomposition using KaHIP http://algo2.iti.kit.edu/documents/kahip/.
virtual label decomposeSerial(const labelList &adjncy, const labelList &xadj, const List< scalar > &cellWeights, labelList &decomp) const
Call kahip with options from dictionary.
configs
The predefined KaHIP configuration types.
static const Enum< configs > configNames
The selection names for predefined KaHIP configurations.
const dictionary & coeffsDict_
Coefficients for all derived methods.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::word regionName(Foam::polyMesh::defaultRegion)
#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.
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.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
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.