MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
metiswrap.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mbdyn_METIS_PartGraph (int piTotVertices, int *pXadj, int *pAdjncy, int *pVertexWgts, int *pCommWgts, int *pEdgeWgts, int DataCommSize, int *pParAmgProcs)
 
void METIS_EdgeND (int *, int *, int *, int *, int *, int *, int *)
 
void METIS_NodeND (int *, int *, int *, int *, int *, int *, int *)
 

Function Documentation

int mbdyn_METIS_PartGraph ( int  piTotVertices,
int pXadj,
int pAdjncy,
int pVertexWgts,
int pCommWgts,
int pEdgeWgts,
int  DataCommSize,
int pParAmgProcs 
)

Definition at line 40 of file metiswrap.cc.

References options, SAFEDELETEARR, and SAFENEWARR.

48 {
49  /* required by METIS_PartGraphVKway API, but otherwise ignored */
50  /* 0: C-style numbering [0..n-1]; 1: F77-style numbering (1..n) */
51  int numflag = 0;
52  /* if options[0] == 0, the rest is ignored */
53  int options[5] = { 0 };
54  /* total communication volume */
55  int volume = 0;
56  /* weiht flags */
57  int wgtflag;
58 
59  idxtype *xadj = 0,
60  *adjncy = 0,
61  *vwgt = 0,
62  *adjwgt = 0,
63  *part = 0;
64 
65  if (sizeof(idxtype) == sizeof(int)) {
66  xadj = pXadj;
67  adjncy = pAdjncy;
68  vwgt = pVertexWgts;
69  adjwgt = pCommWgts;
70  part = pParAmgProcs;
71 
72  } else {
73  SAFENEWARR(xadj, idxtype, iTotVertices);
74  SAFENEWARR(adjncy, idxtype, pXadj[iTotVertices]);
75  if (pVertexWgts) {
76  SAFENEWARR(vwgt, idxtype, iTotVertices);
77  }
78  if (pCommWgts) {
79  SAFENEWARR(adjwgt, idxtype, pXadj[iTotVertices]);
80  }
81  SAFENEWARR(part, idxtype, iTotVertices);
82 
83  for (int i = 0; i < iTotVertices; i++) {
84  xadj[i] = pXadj[i];
85  part[i] = pParAmgProcs[i];
86  }
87 
88  if (pVertexWgts) {
89  for (int i = 0; i < iTotVertices; i++) {
90  vwgt[i] = pVertexWgts[i];
91  }
92  }
93 
94  for (int i = 0; i < pXadj[iTotVertices]; i++) {
95  adjncy[i] = pAdjncy[i];
96  }
97 
98  if (pCommWgts) {
99  for (int i = 0; i < pXadj[iTotVertices]; i++) {
100  adjwgt[i] = pCommWgts[i];
101  }
102  }
103  }
104 
105  if (pVertexWgts && pCommWgts) {
106  wgtflag = 3;
107  } else if (pVertexWgts) {
108  wgtflag = 2;
109  } else if (pCommWgts) {
110  wgtflag = 1;
111  } else {
112  wgtflag = 0;
113  }
114 
115  METIS_PartGraphVKway(&iTotVertices,
116  xadj,
117  adjncy,
118  vwgt,
119  adjwgt,
120  &wgtflag,
121  &numflag,
122  &DataCommSize,
123  options,
124  &volume,
125  part);
126 
127 
128  if (sizeof(idxtype) != sizeof(int)) {
129  for (int i = 0; i < iTotVertices; i++) {
130  pParAmgProcs[i] = part[i];
131  }
132 
133  SAFEDELETEARR(xadj);
134  SAFEDELETEARR(adjncy);
135 
136  if (pVertexWgts) {
137  SAFEDELETEARR(vwgt);
138  }
139 
140  if (pCommWgts) {
141  SAFEDELETEARR(adjwgt);
142  }
143 
144  SAFEDELETEARR(part);
145  }
146 
147  /* NOTE: the manual suggests to use
148  * METIS_PartGraphRecursive if DataCommSize < 8 */
149 
150  return 0;
151 }
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
struct option options[]
Definition: ann_in.c:46
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
void METIS_EdgeND ( int ,
int ,
int ,
int ,
int ,
int ,
int  
)
void METIS_NodeND ( int ,
int ,
int ,
int ,
int ,
int ,
int  
)