SU2
metis.h
Go to the documentation of this file.
1 
10 #ifndef _METIS_H_
11 #define _METIS_H_
12 
13 /****************************************************************************
14 * A set of defines that can be modified by the user
15 *****************************************************************************/
16 
17 /*--------------------------------------------------------------------------
18  Specifies the width of the elementary data type that will hold information
19  about vertices and their adjacency lists.
20 
21  Possible values:
22  32 : Use 32 bit signed integers
23  64 : Use 64 bit signed integers
24 
25  A width of 64 should be specified if the number of vertices or the total
26  number of edges in the graph exceed the limits of a 32 bit signed integer
27  i.e., 2^31-1.
28  Proper use of 64 bit integers requires that the c99 standard datatypes
29  int32_t and int64_t are supported by the compiler.
30  GCC does provides these definitions in stdint.h, but it may require some
31  modifications on other architectures.
32 --------------------------------------------------------------------------*/
33 #define IDXTYPEWIDTH 32
34 
35 
36 /*--------------------------------------------------------------------------
37  Specifies the data type that will hold floating-point style information.
38 
39  Possible values:
40  32 : single precission floating point (float)
41  64 : double precission floating point (double)
42 --------------------------------------------------------------------------*/
43 #define REALTYPEWIDTH 32
44 
45 
46 
47 /****************************************************************************
48 * In principle, nothing needs to be changed beyond this point, unless the
49 * int32_t and int64_t cannot be found in the normal places.
50 *****************************************************************************/
51 
52 /* Uniform definitions for various compilers */
53 #if defined(_MSC_VER)
54  #define COMPILER_MSC
55 #endif
56 #if defined(__ICC)
57  #define COMPILER_ICC
58 #endif
59 #if defined(__GNUC__)
60  #define COMPILER_GCC
61 #endif
62 
63 /* Include c99 int definitions and need constants. When building the library,
64  * these are already defined by GKlib; hence the test for _GKLIB_H_ */
65 #ifndef _GKLIB_H_
66 #ifdef COMPILER_MSC
67 #include <limits.h>
68 
69 typedef __int32 int32_t;
70 typedef __int64 int64_t;
71 #define PRId32 "I32d"
72 #define PRId64 "I64d"
73 #define SCNd32 "ld"
74 #define SCNd64 "I64d"
75 #define INT32_MIN ((int32_t)_I32_MIN)
76 #define INT32_MAX _I32_MAX
77 #define INT64_MIN ((int64_t)_I64_MIN)
78 #define INT64_MAX _I64_MAX
79 #else
80 #include <inttypes.h>
81 #endif
82 #endif
83 
84 
85 /*------------------------------------------------------------------------
86 * Setup the basic datatypes
87 *-------------------------------------------------------------------------*/
88 #if IDXTYPEWIDTH == 32
89  typedef int32_t idx_t;
90 
91  #define IDX_MAX INT32_MAX
92  #define IDX_MIN INT32_MIN
93 
94  #define SCIDX SCNd32
95  #define PRIDX PRId32
96 
97  #define strtoidx strtol
98  #define iabs abs
99 #elif IDXTYPEWIDTH == 64
100  typedef int64_t idx_t;
101 
102  #define IDX_MAX INT64_MAX
103  #define IDX_MIN INT64_MIN
104 
105  #define SCIDX SCNd64
106  #define PRIDX PRId64
107 
108 #ifdef COMPILER_MSC
109  #define strtoidx _strtoi64
110 #else
111  #define strtoidx strtoll
112 #endif
113  #define iabs labs
114 #else
115  #error "Incorrect user-supplied value fo IDXTYPEWIDTH"
116 #endif
117 
118 
119 #if REALTYPEWIDTH == 32
120  typedef float real_t;
121 
122  #define SCREAL "f"
123  #define PRREAL "f"
124  #define REAL_MAX FLT_MAX
125  #define REAL_MIN FLT_MIN
126  #define REAL_EPSILON FLT_EPSILON
127 
128  #define rabs fabsf
129  #define REALEQ(x,y) ((rabs((x)-(y)) <= FLT_EPSILON))
130 
131 #ifdef COMPILER_MSC
132  #define strtoreal (float)strtod
133 #else
134  #define strtoreal strtof
135 #endif
136 #elif REALTYPEWIDTH == 64
137  typedef double real_t;
138 
139  #define SCREAL "lf"
140  #define PRREAL "lf"
141  #define REAL_MAX DBL_MAX
142  #define REAL_MIN DBL_MIN
143  #define REAL_EPSILON DBL_EPSILON
144 
145  #define rabs fabs
146  #define REALEQ(x,y) ((rabs((x)-(y)) <= DBL_EPSILON))
147 
148  #define strtoreal strtod
149 #else
150  #error "Incorrect user-supplied value for REALTYPEWIDTH"
151 #endif
152 
153 
154 /*------------------------------------------------------------------------
155 * Constant definitions
156 *-------------------------------------------------------------------------*/
157 /* Metis's version number */
158 #define METIS_VER_MAJOR 5
159 #define METIS_VER_MINOR 1
160 #define METIS_VER_SUBMINOR 0
161 
162 /* The maximum length of the options[] array */
163 #define METIS_NOPTIONS 40
164 
165 
166 
167 /*------------------------------------------------------------------------
168 * Function prototypes
169 *-------------------------------------------------------------------------*/
170 
171 #ifdef _WINDLL
172 #define METIS_API(type) __declspec(dllexport) type __cdecl
173 #elif defined(__cdecl)
174 #define METIS_API(type) type __cdecl
175 #else
176 #define METIS_API(type) type
177 #endif
178 
179 
180 
181 #ifdef __cplusplus
182 extern "C" {
183 #endif
184 
185 METIS_API(int) METIS_PartGraphRecursive(idx_t *nvtxs, idx_t *ncon, idx_t *xadj,
186  idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt,
187  idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options,
188  idx_t *edgecut, idx_t *part);
189 
190 METIS_API(int) METIS_PartGraphKway(idx_t *nvtxs, idx_t *ncon, idx_t *xadj,
191  idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt,
192  idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options,
193  idx_t *edgecut, idx_t *part);
194 
195 METIS_API(int) METIS_MeshToDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind,
196  idx_t *ncommon, idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy);
197 
198 METIS_API(int) METIS_MeshToNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind,
199  idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy);
200 
201 METIS_API(int) METIS_PartMeshNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind,
202  idx_t *vwgt, idx_t *vsize, idx_t *nparts, real_t *tpwgts,
203  idx_t *options, idx_t *objval, idx_t *epart, idx_t *npart);
204 
205 METIS_API(int) METIS_PartMeshDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind,
206  idx_t *vwgt, idx_t *vsize, idx_t *ncommon, idx_t *nparts,
207  real_t *tpwgts, idx_t *options, idx_t *objval, idx_t *epart,
208  idx_t *npart);
209 
210 METIS_API(int) METIS_NodeND(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt,
211  idx_t *options, idx_t *perm, idx_t *iperm);
212 
213 METIS_API(int) METIS_Free(void *ptr);
214 
215 METIS_API(int) METIS_SetDefaultOptions(idx_t *options);
216 
217 
218 /* These functions are used by ParMETIS */
219 
220 METIS_API(int) METIS_NodeNDP(idx_t nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt,
221  idx_t npes, idx_t *options, idx_t *perm, idx_t *iperm,
222  idx_t *sizes);
223 
224 METIS_API(int) METIS_ComputeVertexSeparator(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy,
225  idx_t *vwgt, idx_t *options, idx_t *sepsize, idx_t *part);
226 
227 METIS_API(int) METIS_NodeRefine(idx_t nvtxs, idx_t *xadj, idx_t *vwgt, idx_t *adjncy,
228  idx_t *where, idx_t *hmarker, real_t ubfactor);
229 
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 
235 
236 
237 /*------------------------------------------------------------------------
238 * Enum type definitions
239 *-------------------------------------------------------------------------*/
241 typedef enum {
242  METIS_OK = 1,
246 } rstatus_et;
247 
248 
250 typedef enum {
251  METIS_OP_PMETIS,
252  METIS_OP_KMETIS,
253  METIS_OP_OMETIS
254 } moptype_et;
255 
256 
258 typedef enum {
259  METIS_OPTION_PTYPE,
260  METIS_OPTION_OBJTYPE,
261  METIS_OPTION_CTYPE,
262  METIS_OPTION_IPTYPE,
263  METIS_OPTION_RTYPE,
264  METIS_OPTION_DBGLVL,
265  METIS_OPTION_NITER,
266  METIS_OPTION_NCUTS,
267  METIS_OPTION_SEED,
268  METIS_OPTION_NO2HOP,
269  METIS_OPTION_MINCONN,
270  METIS_OPTION_CONTIG,
271  METIS_OPTION_COMPRESS,
272  METIS_OPTION_CCORDER,
273  METIS_OPTION_PFACTOR,
274  METIS_OPTION_NSEPS,
275  METIS_OPTION_UFACTOR,
276  METIS_OPTION_NUMBERING,
277 
278  /* Used for command-line parameter purposes */
279  METIS_OPTION_HELP,
280  METIS_OPTION_TPWGTS,
281  METIS_OPTION_NCOMMON,
282  METIS_OPTION_NOOUTPUT,
283  METIS_OPTION_BALANCE,
284  METIS_OPTION_GTYPE,
285  METIS_OPTION_UBVEC
286 } moptions_et;
287 
288 
290 typedef enum {
291  METIS_PTYPE_RB,
292  METIS_PTYPE_KWAY
293 } mptype_et;
294 
296 typedef enum {
297  METIS_GTYPE_DUAL,
298  METIS_GTYPE_NODAL
299 } mgtype_et;
300 
302 typedef enum {
303  METIS_CTYPE_RM,
304  METIS_CTYPE_SHEM
305 } mctype_et;
306 
308 typedef enum {
309  METIS_IPTYPE_GROW,
310  METIS_IPTYPE_RANDOM,
311  METIS_IPTYPE_EDGE,
312  METIS_IPTYPE_NODE,
313  METIS_IPTYPE_METISRB
314 } miptype_et;
315 
316 
318 typedef enum {
319  METIS_RTYPE_FM,
320  METIS_RTYPE_GREEDY,
321  METIS_RTYPE_SEP2SIDED,
322  METIS_RTYPE_SEP1SIDED
323 } mrtype_et;
324 
325 
327 typedef enum {
338 } mdbglvl_et;
339 
340 
341 /* Types of objectives */
342 typedef enum {
343  METIS_OBJTYPE_CUT,
344  METIS_OBJTYPE_VOL,
345  METIS_OBJTYPE_NODE
346 } mobjtype_et;
347 
348 
349 
350 #endif /* _METIS_H_ */
moptions_et
Definition: metis.h:258
mdbglvl_et
Definition: metis.h:327
Definition: metis.h:242
Definition: metis.h:243
Definition: metis.h:245
int METIS_Free(void *ptr)
Definition: auxapi.c:23
Definition: metis.h:244
Definition: metis.h:337
Definition: metis.h:328
int METIS_SetDefaultOptions(idx_t *options)
Definition: auxapi.c:36
mrtype_et
Definition: metis.h:318
mctype_et
Definition: metis.h:302
Definition: metis.h:329
mgtype_et
Definition: metis.h:296
Definition: metis.h:334
miptype_et
Definition: metis.h:308
Definition: metis.h:330
Definition: metis.h:332
rstatus_et
Definition: metis.h:241
Definition: metis.h:335
Definition: metis.h:331
Definition: metis.h:336
int METIS_PartGraphRecursive(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, idx_t *objval, idx_t *part)
Recursive partitioning routine.
Definition: pmetis.c:91
int METIS_PartGraphKway(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, idx_t *objval, idx_t *part)
Definition: kmetis.c:18
moptype_et
Definition: metis.h:250
mptype_et
Definition: metis.h:290
Definition: metis.h:333