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 
87  M2GReportResults(params, mesh, graph);
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 }
Definition: fis.c:15
#define gk_startcputimer(tmr)
Definition: gk_macros.h:33
int main(int argc, char *argv[])
Definition: m2gmetis.c:22
idx_t ncon
idx_t * xadj
#define gk_stopcputimer(tmr)
Definition: gk_macros.h:34
#define FreeGraph
Definition: rename.h:98
char * filename
Definition: fis.c:18
mesh_t * ReadMesh(params_t *params)
Definition: programs/io.c:178
size_t gk_GetMaxMemoryUsed()
Definition: memory.c:246
idx_t nvtxs
#define METISTITLE
Definition: libmetis/defs.h:18
NonlinearFactorGraph graph
real_t parttimer
params_t * parse_cmdline(int argc, char *argv[])
Definition: fis.c:194
#define PRIDX
idx_t nedges
size_t gk_GetCurMemoryUsed()
Definition: memory.c:233
#define FreeMesh
Definition: rename.h:155
void M2GPrintInfo(params_t *params, mesh_t *mesh)
Definition: m2gmetis.c:99
static char gtypenames[][15]
Definition: programs/defs.h:59
idx_t numflag
int32_t idx_t
size_t maxmemory
void M2GReportResults(params_t *params, mesh_t *mesh, graph_t *graph)
Definition: m2gmetis.c:122
idx_t ncon
static SmartStereoProjectionParams params
void gk_malloc_cleanup(int showstats)
Definition: memory.c:118
float real_t
#define gk_getcputimer(tmr)
Definition: gk_macros.h:35
char * outfile
Definition: gkgraph.c:22
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
#define CreateGraph
Definition: rename.h:95
real_t iotimer
void gk_free(void **ptr1,...)
Definition: memory.c:202
idx_t * adjncy
#define PRREAL
void WriteGraph(graph_t *graph, char *filename)
Definition: programs/io.c:497
real_t reporttimer
idx_t * eptr
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
int gk_malloc_init()
Definition: memory.c:99
idx_t * eind
idx_t ncommon
#define LTERM
Definition: gk_defs.h:14


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:35