43 namespace LibUtilities
50 "Partitioning using the Scotch library.");
81 if (vertWgt.num_elements() > 0)
86 if (vertSize.num_elements() > 0)
97 &wgtflag, &numflag, &nparts, options, &volume,
103 const SCOTCH_Num *
const n,
104 const SCOTCH_Num *
const xadj,
105 const SCOTCH_Num *
const adjncy,
106 const SCOTCH_Num *
const vwgt,
107 const SCOTCH_Num *
const vsize,
108 const SCOTCH_Num *
const wgtflag,
109 const SCOTCH_Num *
const numflag,
110 const SCOTCH_Num *
const nparts,
111 const SCOTCH_Num *
const options,
112 SCOTCH_Num *
const volume,
113 SCOTCH_Num *
const part)
116 const SCOTCH_Num * vwgt2;
117 const SCOTCH_Num * vsize2;
122 const SCOTCH_Num * edgetax;
123 const SCOTCH_Num * parttax;
124 SCOTCH_Num * nghbtab;
127 vsize2 = ((*wgtflag & 1) != 0) ? vsize : NULL;
128 vwgt2 = ((*wgtflag & 2) != 0) ? vwgt : NULL;
131 edgetax = adjncy - baseval;
134 if (vsize2 == NULL) {
135 if (
PartGraph2 (n, xadj, adjncy, vwgt2, NULL, numflag, nparts,
136 part, SCOTCH_STRATDEFAULT, 0.01) != 0)
142 const SCOTCH_Num * vsiztax;
144 SCOTCH_Num * edlotax;
147 edgenbr = xadj[vertnbr] - baseval;
149 (SCOTCH_Num*) malloc (edgenbr *
sizeof (SCOTCH_Num))) == NULL)
155 vsiztax = vsize2 - baseval;
158 for (vertnum = 0, edgenum = baseval;
159 vertnum < vertnbr; vertnum ++) {
163 vsizval = vsize2[vertnum];
165 for (edgennd = xadj[vertnum + 1];
171 vertend = edgetax[edgenum];
172 edlotax[edgenum] = vsizval + vsiztax[vertend];
176 o =
PartGraph2 (n, xadj, adjncy, vwgt2, edlotax + baseval, numflag,
177 nparts, part, SCOTCH_STRATDEFAULT, 0.01);
179 free (edlotax + baseval);
186 (SCOTCH_Num*) malloc (*nparts *
sizeof (SCOTCH_Num))) == NULL)
191 memset (nghbtab, ~0, *nparts *
sizeof (SCOTCH_Num));
193 parttax = part - baseval;
197 for (vertnum = 0, edgenum = baseval, commvol = 0;
198 vertnum < vertnbr; vertnum ++) {
202 partval = part[vertnum];
203 nghbtab[partval] = vertnum;
206 vsizval = vsize2[vertnum];
209 for (edgennd = xadj[vertnum + 1]; edgenum < edgennd; edgenum ++) {
213 vertend = edgetax[edgenum];
214 partend = parttax[vertend];
217 if (nghbtab[partend] != vertnum) {
218 nghbtab[partend] = vertnum;
229 const SCOTCH_Num *
const n,
230 const SCOTCH_Num *
const xadj,
231 const SCOTCH_Num *
const adjncy,
232 const SCOTCH_Num *
const vwgt,
233 const SCOTCH_Num *
const adjwgt,
234 const SCOTCH_Num *
const numflag,
235 const SCOTCH_Num *
const nparts,
236 SCOTCH_Num *
const part,
241 SCOTCH_Graph grafdat;
242 SCOTCH_Strat stradat;
247 SCOTCH_graphInit (&grafdat);
253 if (SCOTCH_graphBuild (&grafdat, baseval, vertnbr, xadj, xadj + 1,
254 vwgt, NULL, xadj[vertnbr] - baseval, adjncy,
256 SCOTCH_stratInit (&stradat);
257 SCOTCH_stratGraphMapBuild (&stradat, flagval, *nparts, kbalval);
258 #ifdef SCOTCH_DEBUG_ALL
260 if (SCOTCH_graphCheck (&grafdat) == 0)
262 o = SCOTCH_graphPart (&grafdat, *nparts, &stradat, part);
263 SCOTCH_stratExit (&stradat);
265 SCOTCH_graphExit (&grafdat);
273 for (vertnum = 0; vertnum < vertnbr; vertnum ++)
274 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
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, Nektar::Array< Nektar::OneD, int > &edgeWgt, int &nparts, int &volume, Nektar::Array< Nektar::OneD, int > &part)
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)
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.