36 #define MPICH_SKIP_MPICXX
37 #define OMPI_SKIP_MPICXX
53 sizeof(Foam::label) ==
sizeof(SCOTCH_Num),
54 "sizeof(Foam::label) == sizeof(SCOTCH_Num), check your scotch headers"
82 void Foam::scotchDecomp::graphPath(
const polyMesh&
mesh)
const
84 graphPath_ =
mesh.time().path()/
mesh.name() +
".grf";
88 void Foam::scotchDecomp::check(
const int retVal,
const char* str)
93 <<
"Call to scotch routine " << str <<
" failed.\n"
105 const List<scalar>& cWeights,
110 if (coeffsDict_.getOrDefault(
"writeGraph",
false))
112 OFstream str(graphPath_);
114 Info<<
"Dumping Scotch graph file to " << str.name() <<
nl
115 <<
"Use this in combination with gpart." <<
endl;
120 str << xadj.size()-1 <<
' ' << adjncy.size() <<
nl;
123 const label baseval = 0;
126 const label hasEdgeWeights = 0;
127 const label hasVertexWeights = 0;
128 const label numericflag = 10*hasEdgeWeights+hasVertexWeights;
129 str << baseval <<
' ' << numericflag <<
nl;
131 for (label celli = 1; celli < xadj.size(); ++celli)
133 const label start = xadj[celli-1];
134 const label
end = xadj[celli];
138 for (label i = start; i <
end; ++i)
140 str <<
' ' << adjncy[i];
147 SCOTCH_randomReset();
153 SCOTCH_Strat stradat;
154 check(SCOTCH_stratInit(&stradat),
"SCOTCH_stratInit");
157 if (coeffsDict_.readIfPresent(
"strategy", strategy))
161 Info<<
"scotchDecomp : Using strategy " << strategy <<
endl;
163 SCOTCH_stratGraphMap(&stradat, strategy.c_str());
177 const scalar minWeights =
min(cWeights);
178 if (!cWeights.empty())
183 <<
"Illegal minimum weight " << minWeights
187 if (cWeights.size() != xadj.size()-1)
190 <<
"Number of cell weights " << cWeights.size()
191 <<
" does not equal number of cells " << xadj.size()-1
195 scalar velotabSum =
sum(cWeights)/minWeights;
197 scalar rangeScale(1.0);
199 if (velotabSum > scalar(
labelMax - 1))
203 rangeScale = 0.9*scalar(
labelMax - 1)/velotabSum;
206 <<
"Sum of weights has overflowed integer: " << velotabSum
207 <<
", compressing weight scale by a factor of " << rangeScale
212 velotab.setSize(cWeights.size());
216 velotab[i] = int((cWeights[i]/minWeights - 1)*rangeScale) + 1;
221 SCOTCH_Graph grafdat;
222 check(SCOTCH_graphInit(&grafdat),
"SCOTCH_graphInit");
240 check(SCOTCH_graphCheck(&grafdat),
"SCOTCH_graphCheck");
248 check(SCOTCH_archInit(&archdat),
"SCOTCH_archInit");
253 coeffsDict_.readIfPresent(
"processorWeights", processorWeights)
254 && processorWeights.size()
259 Info<<
"scotchDecomp : Using procesor weights " << processorWeights
262 if (processorWeights.size() != nDomains_)
265 <<
"processorWeights not the same size"
266 <<
" as the wanted number of domains " << nDomains_
274 &archdat, nDomains_, processorWeights.begin()
283 SCOTCH_archCmplt(&archdat, nDomains_),
331 int oldExcepts = fedisableexcept
339 decomp.setSize(xadj.size()-1);
354 feenableexcept(oldExcepts);
371 SCOTCH_graphExit(&grafdat);
373 SCOTCH_stratExit(&stradat);
375 SCOTCH_archExit(&archdat);
385 metisLikeDecomp(typeName, decompDict, selectionType::NULL_DICT)
391 const dictionary& decompDict,
395 metisLikeDecomp(typeName, decompDict,
regionName, selectionType::NULL_DICT)
403 const polyMesh&
mesh,
422 const polyMesh&
mesh,
449 graphPath_ =
"scotch.grf";