1 /*
2 * Copyright 1997, Regents of the University of Minnesota
3 *
4 * mesh2nodal.c
5 *
6 * This file reads in the element node connectivity array of a mesh and writes
7 * out its dual in the format suitable for Metis.
8 *
9 * Started 9/29/97
10 * George
11 *
12 * $Id: mesh2nodal.c,v 1.1 1998/11/27 17:59:35 karypis Exp $
13 *
14 */
15
16 #include <metis.h>
17
18
19
20 /*************************************************************************
21 * Let the game begin
22 **************************************************************************/
main(int argc,char * argv[])23 main(int argc, char *argv[])
24 {
25 int i, j, ne, nn, etype, numflag=0;
26 idxtype *elmnts, *xadj, *adjncy;
27 timer IOTmr, DUALTmr;
28 char fileout[256], etypestr[4][5] = {"TRI", "TET", "HEX", "QUAD"};
29
30 if (argc != 2) {
31 printf("Usage: %s <meshfile>\n",argv[0]);
32 exit(0);
33 }
34
35 cleartimer(IOTmr);
36 cleartimer(DUALTmr);
37
38 starttimer(IOTmr);
39 elmnts = ReadMesh(argv[1], &ne, &nn, &etype);
40 stoptimer(IOTmr);
41
42 printf("**********************************************************************\n");
43 printf("%s", METISTITLE);
44 printf("Mesh Information ----------------------------------------------------\n");
45 printf(" Name: %s, #Elements: %d, #Nodes: %d, Etype: %s\n\n", argv[1], ne, nn, etypestr[etype-1]);
46 printf("Forming Nodal Graph... ----------------------------------------------\n");
47
48 xadj = idxmalloc(nn+1, "main: xadj");
49 adjncy = idxmalloc(20*nn, "main: adjncy");
50
51 starttimer(DUALTmr);
52 METIS_MeshToNodal(&ne, &nn, elmnts, &etype, &numflag, xadj, adjncy);
53 stoptimer(DUALTmr);
54
55 printf(" Nodal Information: #Vertices: %d, #Edges: %d\n", nn, xadj[nn]/2);
56
57 sprintf(fileout, "%s.ngraph", argv[1]);
58 starttimer(IOTmr);
59 WriteGraph(fileout, nn, xadj, adjncy);
60 stoptimer(IOTmr);
61
62
63 printf("\nTiming Information --------------------------------------------------\n");
64 printf(" I/O: \t\t %7.3f\n", gettimer(IOTmr));
65 printf(" Nodal Creation:\t\t %7.3f\n", gettimer(DUALTmr));
66 printf("**********************************************************************\n");
67
68 GKfree(&elmnts, &xadj, &adjncy, LTERM);
69
70 }
71
72
73