m2gmetis.c
Go to the documentation of this file.
1 /*
2  * Copyright 1994-2011, Regents of the University of Minnesota
3  *
4  * m2gmetis.c
5  *
6  * Drivers for the mesh-to-graph coversion routines
7  *
8  * Started 5/28/11
9  * George
10  *
11  * $Id: m2gmetis.c 10498 2011-07-06 16:41:38Z karypis $
12  *
13  */
14 
15 #include "metisbin.h"
16 
17 
18 
19 /*************************************************************************/
21 /*************************************************************************/
22 int main(int argc, char *argv[])
23 {
24  mesh_t *mesh;
25  graph_t *graph;
27  int status=0;
28 
29  params = parse_cmdline(argc, argv);
30 
31  gk_startcputimer(params->iotimer);
32  mesh = ReadMesh(params);
33 
34  gk_stopcputimer(params->iotimer);
35 
36  if (mesh->ncon > 1) {
37  printf("*** Meshes with more than one balancing constraint are not supported yet.\n");
38  exit(0);
39  }
40 
41  M2GPrintInfo(params, mesh);
42 
43  graph = CreateGraph();
44 
46  gk_startcputimer(params->parttimer);
47 
48  switch (params->gtype) {
49  case METIS_GTYPE_DUAL:
50  status = METIS_MeshToDual(&mesh->ne, &mesh->nn, mesh->eptr, mesh->eind,
51  &params->ncommon, &params->numflag, &graph->xadj, &graph->adjncy);
52 
53  if (status == METIS_OK) {
54  graph->nvtxs = mesh->ne;
55  graph->nedges = graph->xadj[graph->nvtxs];
56  graph->ncon = 1;
57  }
58  break;
59 
60  case METIS_GTYPE_NODAL:
61  status = METIS_MeshToNodal(&mesh->ne, &mesh->nn, mesh->eptr, mesh->eind,
62  &params->numflag, &graph->xadj, &graph->adjncy);
63 
64  if (status == METIS_OK) {
65  graph->nvtxs = mesh->nn;
66  graph->nedges = graph->xadj[graph->nvtxs];
67  graph->ncon = 1;
68  }
69  break;
70  }
71 
72  gk_stopcputimer(params->parttimer);
73  if (gk_GetCurMemoryUsed() != 0)
74  printf("***It seems that Metis did not free all of its memory! Report this.\n");
75  params->maxmemory = gk_GetMaxMemoryUsed();
77 
78  if (status != METIS_OK) {
79  printf("\n***Metis returned with an error.\n");
80  }
81  else {
82  /* Write the graph */
83  gk_startcputimer(params->iotimer);
84  WriteGraph(graph, params->outfile);
85  gk_stopcputimer(params->iotimer);
86 
88  }
89 
90  FreeGraph(&graph);
91  FreeMesh(&mesh);
92  gk_free((void **)&params->filename, &params->outfile, &params, LTERM);
93 }
94 
95 
96 /*************************************************************************/
98 /*************************************************************************/
100 {
101  printf("******************************************************************************\n");
102  printf("%s", METISTITLE);
103  printf(" (HEAD: %s, Built on: %s, %s)\n", SVNINFO, __DATE__, __TIME__);
104  printf(" size of idx_t: %zubits, real_t: %zubits, idx_t *: %zubits\n",
105  8*sizeof(idx_t), 8*sizeof(real_t), 8*sizeof(idx_t *));
106  printf("\n");
107  printf("Mesh Information ------------------------------------------------------------\n");
108  printf(" Name: %s, #Elements: %"PRIDX", #Nodes: %"PRIDX"\n",
109  params->filename, mesh->ne, mesh->nn);
110 
111  printf("Options ---------------------------------------------------------------------\n");
112  printf(" gtype=%s, ncommon=%"PRIDX", outfile=%s\n",
113  gtypenames[params->gtype], params->ncommon, params->outfile);
114 
115  printf("\n");
116 }
117 
118 
119 /*************************************************************************/
121 /*************************************************************************/
123 {
124 
125  gk_startcputimer(params->reporttimer);
126 
127  printf(" - #nvtxs: %"PRIDX", #edges: %"PRIDX"\n", graph->nvtxs, graph->nedges);
128 
129  gk_stopcputimer(params->reporttimer);
130 
131 
132  printf("\nTiming Information ----------------------------------------------------------\n");
133  printf(" I/O: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->iotimer));
134  printf(" Partitioning: \t\t %7.3"PRREAL" sec (METIS time)\n", gk_getcputimer(params->parttimer));
135  printf(" Reporting: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->reporttimer));
136  printf("\nMemory Information ----------------------------------------------------------\n");
137  printf(" Max memory used:\t\t %7.3"PRREAL" MB\n", (real_t)(params->maxmemory/(1024.0*1024.0)));
138  printf("******************************************************************************\n");
139 
140 }
WriteGraph
void WriteGraph(graph_t *graph, char *filename)
Definition: programs/io.c:497
CreateGraph
#define CreateGraph
Definition: rename.h:95
gk_free
void gk_free(void **ptr1,...)
Definition: memory.c:202
mesh_t
Definition: libmetis/struct.h:126
mesh_t::eptr
idx_t * eptr
Definition: libmetis/struct.h:130
gk_getcputimer
#define gk_getcputimer(tmr)
Definition: gk_macros.h:35
params_t
Definition: fis.c:15
PRREAL
#define PRREAL
Definition: include/metis.h:135
main
int main(int argc, char *argv[])
Definition: m2gmetis.c:22
vanilla::params
static const SmartProjectionParams params
Definition: smartFactorScenarios.h:69
METIS_GTYPE_DUAL
@ METIS_GTYPE_DUAL
Definition: include/metis.h:309
gk_startcputimer
#define gk_startcputimer(tmr)
Definition: gk_macros.h:33
METIS_GTYPE_NODAL
@ METIS_GTYPE_NODAL
Definition: include/metis.h:310
METIS_OK
@ METIS_OK
Definition: include/metis.h:254
metisbin.h
LTERM
#define LTERM
Definition: gk_defs.h:14
gk_GetMaxMemoryUsed
size_t gk_GetMaxMemoryUsed()
Definition: memory.c:246
METIS_MeshToDual
int METIS_MeshToDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, idx_t *ncommon, idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy)
Definition: mesh.c:44
parse_cmdline
params_t * parse_cmdline(int argc, char *argv[])
Definition: fis.c:194
FreeGraph
#define FreeGraph
Definition: rename.h:98
mesh_t::eind
idx_t * eind
Definition: libmetis/struct.h:130
FreeMesh
#define FreeMesh
Definition: rename.h:155
METISTITLE
#define METISTITLE
Definition: libmetis/defs.h:18
PRIDX
#define PRIDX
Definition: include/metis.h:107
real_t
float real_t
Definition: include/metis.h:132
gtypenames
static char gtypenames[][15]
Definition: programs/defs.h:59
mesh_t::ncon
idx_t ncon
Definition: libmetis/struct.h:128
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
gk_GetCurMemoryUsed
size_t gk_GetCurMemoryUsed()
Definition: memory.c:233
mesh_t::ne
idx_t ne
Definition: libmetis/struct.h:127
METIS_MeshToNodal
int METIS_MeshToNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy)
Definition: mesh.c:114
M2GReportResults
void M2GReportResults(params_t *params, mesh_t *mesh, graph_t *graph)
Definition: m2gmetis.c:122
ReadMesh
mesh_t * ReadMesh(params_t *params)
Definition: programs/io.c:178
gk_stopcputimer
#define gk_stopcputimer(tmr)
Definition: gk_macros.h:34
gk_malloc_cleanup
void gk_malloc_cleanup(int showstats)
Definition: memory.c:118
M2GPrintInfo
void M2GPrintInfo(params_t *params, mesh_t *mesh)
Definition: m2gmetis.c:99
mesh_t::nn
idx_t nn
Definition: libmetis/struct.h:127
graph_t
Definition: libmetis/struct.h:82
idx_t
int32_t idx_t
Definition: include/metis.h:101
gk_malloc_init
int gk_malloc_init()
Definition: memory.c:99


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:44