38 #define MPICH_SKIP_MPICXX
39 #define OMPI_SKIP_MPICXX
55 sizeof(Foam::label) <=
sizeof(SCOTCH_Num),
56 "SCOTCH_Num is too small for Foam::label, check your scotch headers"
79 static inline void check(
const int retVal,
const char* what)
84 <<
"Call to scotch routine " << what
85 <<
" failed (" << retVal <<
")\n"
107 const List<scalar>& cWeights,
111 const SCOTCH_Num numCells =
max(0, (xadj.size()-1));
114 ConstPrecisionAdaptor<SCOTCH_Num, label, List> adjncy_param(adjncy);
115 ConstPrecisionAdaptor<SCOTCH_Num, label, List> xadj_param(xadj);
118 decomp.resize(numCells);
120 PrecisionAdaptor<SCOTCH_Num, label, List> decomp_param(decomp,
false);
123 labelList adjncy_dummy, xadj_dummy, decomp_dummy;
126 adjncy_dummy.
resize(1, 0);
127 adjncy_param.set(adjncy_dummy);
129 xadj_dummy.resize(2, 0);
130 xadj_param.set(xadj_dummy);
132 decomp_dummy.resize(1, 0);
133 decomp_param.clear();
134 decomp_param.set(decomp_dummy);
141 OFstream str(graphPath_ +
".grf");
143 Info<<
"Dumping Scotch graph file to " << str.name() <<
nl
144 <<
"Use this in combination with gpart." <<
endl;
146 const label numConnect = adjncy.size();
153 str << numCells <<
' ' << numConnect <<
nl;
157 str <<
"0 000" <<
nl;
159 for (label celli = 0; celli < numCells; ++celli)
161 const label beg = xadj[celli];
162 const label
end = xadj[celli+1];
166 for (label i = beg; i <
end; ++i)
168 str <<
' ' << adjncy[i];
176 SCOTCH_randomReset();
182 SCOTCH_Strat stradat;
185 SCOTCH_stratInit(&stradat),
192 DebugInfo <<
"scotchDecomp : Using strategy " << strategy <<
endl;
194 SCOTCH_stratGraphMap(&stradat, strategy.c_str());
206 bool hasWeights = !cWeights.empty();
209 const scalar minWeights = hasWeights ?
min(cWeights) : scalar(1);
215 <<
"Illegal minimum weight " << minWeights
219 else if (hasWeights && (cWeights.size() != numCells))
222 <<
"Number of cell weights " << cWeights.size()
223 <<
" does not equal number of cells " << numCells
228 List<SCOTCH_Num> velotab;
232 scalar rangeScale(1);
234 const scalar velotabSum =
sum(cWeights)/minWeights;
236 const scalar upperRange =
static_cast<scalar
>
241 if (velotabSum > upperRange)
245 rangeScale = 0.9*upperRange/velotabSum;
248 <<
"Sum of weights overflows SCOTCH_Num: " << velotabSum
249 <<
", compressing by factor " << rangeScale <<
endl;
254 velotab.resize(cWeights.size());
258 velotab[i] =
static_cast<SCOTCH_Num
>
260 ((cWeights[i]/minWeights - 1)*rangeScale) + 1
271 SCOTCH_Graph grafdat;
274 SCOTCH_graphInit(&grafdat),
285 xadj_param().cdata(),
292 adjncy_param().cdata(),
299 SCOTCH_graphCheck(&grafdat),
311 SCOTCH_archInit(&archdat),
315 List<SCOTCH_Num> procWeights;
319 && !procWeights.empty()
325 <<
"processorWeights (" << procWeights.size()
326 <<
") != number of domains (" <<
nDomains_ <<
")" <<
nl
331 <<
"scotchDecomp : Using procesor weights "
332 << procWeights <<
endl;
336 SCOTCH_archCmpltw(&archdat,
nDomains_, procWeights.cdata()),
392 int oldExcepts = fedisableexcept
407 decomp_param.ref().data()
413 feenableexcept(oldExcepts);
429 SCOTCH_graphExit(&grafdat);
430 SCOTCH_stratExit(&stradat);
431 SCOTCH_archExit(&archdat);
441 const dictionary& decompDict,
445 metisLikeDecomp(typeName, decompDict,
regionName, selectionType::NULL_DICT)
453 const polyMesh&
mesh,
472 const polyMesh&
mesh,
499 graphPath_ =
"scotch.grf";