source: inundation/pymetis/metis-4.0/Programs/mesh2dual.c @ 3031

Last change on this file since 3031 was 2051, checked in by jack, 19 years ago

Python interface to metis. Currently provides only the
METIS_PartMeshNodal function, since that is what is currently needed for partitioning.
Module name is metis.

File size: 2.0 KB
Line 
1/*
2 * Copyright 1997, Regents of the University of Minnesota
3 *
4 * mesh2dual.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: mesh2dual.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**************************************************************************/
23main(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 Dual Graph... -----------------------------------------------\n");
47
48  xadj = idxmalloc(ne+1, "main: xadj");
49  adjncy = idxmalloc(10*ne, "main: adjncy");
50
51  starttimer(DUALTmr);
52  METIS_MeshToDual(&ne, &nn, elmnts, &etype, &numflag, xadj, adjncy);
53  stoptimer(DUALTmr);
54
55  printf("  Dual Information: #Vertices: %d, #Edges: %d\n", ne, xadj[ne]/2);
56
57  sprintf(fileout, "%s.dgraph", argv[1]);
58  starttimer(IOTmr);
59  WriteGraph(fileout, ne, 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("  Dual Creation:\t\t %7.3f\n", gettimer(DUALTmr));
66  printf("**********************************************************************\n");
67
68  GKfree(&elmnts, &xadj, &adjncy, LTERM);
69
70}
71
72
Note: See TracBrowser for help on using the repository browser.