43 namespace LibUtilities
50 "Partitioning using the Scotch library.");
80 if (vertWgt.num_elements() > 0)
85 if (vertSize.num_elements() > 0)
96 &wgtflag, &numflag, &nparts, options, &volume,
102 const SCOTCH_Num *
const n,
103 const SCOTCH_Num *
const xadj,
104 const SCOTCH_Num *
const adjncy,
105 const SCOTCH_Num *
const vwgt,
106 const SCOTCH_Num *
const vsize,
107 const SCOTCH_Num *
const wgtflag,
108 const SCOTCH_Num *
const numflag,
109 const SCOTCH_Num *
const nparts,
110 const SCOTCH_Num *
const options,
111 SCOTCH_Num *
const volume,
112 SCOTCH_Num *
const part)
115 const SCOTCH_Num * vwgt2;
116 const SCOTCH_Num * vsize2;
121 const SCOTCH_Num * edgetax;
122 const SCOTCH_Num * parttax;
123 SCOTCH_Num * nghbtab;
126 vsize2 = ((*wgtflag & 1) != 0) ? vsize : NULL;
127 vwgt2 = ((*wgtflag & 2) != 0) ? vwgt : NULL;
130 edgetax = adjncy - baseval;
133 if (vsize2 == NULL) {
134 if (
PartGraph2 (n, xadj, adjncy, vwgt2, NULL, numflag, nparts,
135 part, SCOTCH_STRATDEFAULT, 0.01) != 0)
141 const SCOTCH_Num * vsiztax;
143 SCOTCH_Num * edlotax;
146 edgenbr = xadj[vertnbr] - baseval;
148 (SCOTCH_Num*) malloc (edgenbr *
sizeof (SCOTCH_Num))) == NULL)
154 vsiztax = vsize2 - baseval;
157 for (vertnum = 0, edgenum = baseval;
158 vertnum < vertnbr; vertnum ++) {
162 vsizval = vsize2[vertnum];
164 for (edgennd = xadj[vertnum + 1];
170 vertend = edgetax[edgenum];
171 edlotax[edgenum] = vsizval + vsiztax[vertend];
175 o =
PartGraph2 (n, xadj, adjncy, vwgt2, edlotax + baseval, numflag,
176 nparts, part, SCOTCH_STRATDEFAULT, 0.01);
178 free (edlotax + baseval);
185 (SCOTCH_Num*) malloc (*nparts *
sizeof (SCOTCH_Num))) == NULL)
190 memset (nghbtab, ~0, *nparts *
sizeof (SCOTCH_Num));
192 parttax = part - baseval;
196 for (vertnum = 0, edgenum = baseval, commvol = 0;
197 vertnum < vertnbr; vertnum ++) {
201 partval = part[vertnum];
202 nghbtab[partval] = vertnum;
205 vsizval = vsize2[vertnum];
208 for (edgennd = xadj[vertnum + 1]; edgenum < edgennd; edgenum ++) {
212 vertend = edgetax[edgenum];
213 partend = parttax[vertend];
216 if (nghbtab[partend] != vertnum) {
217 nghbtab[partend] = vertnum;
228 const SCOTCH_Num *
const n,
229 const SCOTCH_Num *
const xadj,
230 const SCOTCH_Num *
const adjncy,
231 const SCOTCH_Num *
const vwgt,
232 const SCOTCH_Num *
const adjwgt,
233 const SCOTCH_Num *
const numflag,
234 const SCOTCH_Num *
const nparts,
235 SCOTCH_Num *
const part,
240 SCOTCH_Graph grafdat;
241 SCOTCH_Strat stradat;
246 SCOTCH_graphInit (&grafdat);
252 if (SCOTCH_graphBuild (&grafdat, baseval, vertnbr, xadj, xadj + 1,
253 vwgt, NULL, xadj[vertnbr] - baseval, adjncy,
255 SCOTCH_stratInit (&stradat);
256 SCOTCH_stratGraphMapBuild (&stradat, flagval, *nparts, kbalval);
257 #ifdef SCOTCH_DEBUG_ALL
259 if (SCOTCH_graphCheck (&grafdat) == 0)
261 o = SCOTCH_graphPart (&grafdat, *nparts, &stradat, part);
262 SCOTCH_stratExit (&stradat);
264 SCOTCH_graphExit (&grafdat);
272 for (vertnum = 0; vertnum < vertnbr; vertnum ++)
273 part[vertnum] += baseval;
static std::string RegisterCmdLineFlag(const std::string &pName, const std::string &pShortName, const std::string &pDescription)
Registers a command-line flag with the session reader.
static std::string cmdSwitch
static MeshPartitionSharedPtr create(const SessionReaderSharedPtr &pSession)
Creates an instance of this class.
virtual ~MeshPartitionScotch()
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
MeshPartitionScotch(const SessionReaderSharedPtr &pSession)
int PartGraph2(const SCOTCH_Num *const n, const SCOTCH_Num *const xadj, const SCOTCH_Num *const adjncy, const SCOTCH_Num *const vwgt, const SCOTCH_Num *const adjwgt, const SCOTCH_Num *const numflag, const SCOTCH_Num *const nparts, SCOTCH_Num *const part, SCOTCH_Num flagval, double kbalval)
virtual void PartitionGraphImpl(int &nVerts, int &nVertConds, Nektar::Array< Nektar::OneD, int > &xadj, Nektar::Array< Nektar::OneD, int > &adjcy, Nektar::Array< Nektar::OneD, int > &vertWgt, Nektar::Array< Nektar::OneD, int > &vertSize, int &nparts, int &volume, Nektar::Array< Nektar::OneD, int > &part)
static std::string className
Name of class.
void PartGraphVKway(const SCOTCH_Num *const n, const SCOTCH_Num *const xadj, const SCOTCH_Num *const adjncy, const SCOTCH_Num *const vwgt, const SCOTCH_Num *const vsize, const SCOTCH_Num *const wgtflag, const SCOTCH_Num *const numflag, const SCOTCH_Num *const nparts, const SCOTCH_Num *const options, SCOTCH_Num *const volume, SCOTCH_Num *const part)
MeshPartitionFactory & GetMeshPartitionFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.