source: inundation/pymetis/metis-4.0/Programs/partnmesh.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.6 KB
Line 
1/*
2 * Copyright 1997, Regents of the University of Minnesota
3 *
4 * partnmesh.c
5 *
6 * This file reads in the element node connectivity array of a mesh and
7 * partitions both the elements and the nodes using KMETIS on the dual graph.
8 *
9 * Started 9/29/97
10 * George
11 *
12 * $Id: partnmesh.c,v 1.1 1998/11/27 17:59:39 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, nparts, edgecut;
26  idxtype *elmnts, *epart, *npart;
27  timer IOTmr, DUALTmr;
28  char etypestr[4][5] = {"TRI", "TET", "HEX", "QUAD"};
29  GraphType graph;
30
31  if (argc != 3) {
32    printf("Usage: %s <meshfile> <nparts>\n",argv[0]);
33    exit(0);
34  }
35
36  nparts = atoi(argv[2]);
37  if (nparts < 2) {
38    printf("nparts must be greater than one.\n");
39    exit(0);
40  }
41   
42  cleartimer(IOTmr);
43  cleartimer(DUALTmr);
44
45  starttimer(IOTmr);
46  elmnts = ReadMesh(argv[1], &ne, &nn, &etype);
47  stoptimer(IOTmr);
48
49  epart = idxmalloc(ne, "main: epart");
50  npart = idxmalloc(nn, "main: npart");
51
52  printf("**********************************************************************\n");
53  printf("%s", METISTITLE);
54  printf("Mesh Information ----------------------------------------------------\n");
55  printf("  Name: %s, #Elements: %d, #Nodes: %d, Etype: %s\n\n", argv[1], ne, nn, etypestr[etype-1]);
56  printf("Partitioning Nodal Graph... -----------------------------------------\n");
57
58
59  starttimer(DUALTmr);
60  METIS_PartMeshNodal(&ne, &nn, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart);
61  stoptimer(DUALTmr);
62
63  printf("  %d-way Edge-Cut: %7d, Balance: %5.2f\n", nparts, edgecut, ComputeElementBalance(ne, nparts, epart));
64
65  starttimer(IOTmr);
66  WriteMeshPartition(argv[1], nparts, ne, epart, nn, npart);
67  stoptimer(IOTmr);
68
69
70  printf("\nTiming Information --------------------------------------------------\n");
71  printf("  I/O:          \t\t %7.3f\n", gettimer(IOTmr));
72  printf("  Partitioning: \t\t %7.3f\n", gettimer(DUALTmr));
73  printf("**********************************************************************\n");
74
75/*
76  graph.nvtxs = ne;
77  graph.xadj = idxmalloc(ne+1, "xadj");
78  graph.vwgt = idxsmalloc(ne, 1, "vwgt");
79  graph.adjncy = idxmalloc(10*ne, "adjncy");
80  graph.adjwgt = idxsmalloc(10*ne, 1, "adjncy");
81
82  METIS_MeshToDual(&ne, &nn, elmnts, &etype, &numflag, graph.xadj, graph.adjncy);
83
84  ComputePartitionInfo(&graph, nparts, epart);
85
86  GKfree(&graph.xadj, &graph.adjncy, &graph.vwgt, &graph.adjwgt, LTERM);
87*/
88
89  GKfree(&elmnts, &epart, &npart, LTERM);
90
91}
92
93
Note: See TracBrowser for help on using the repository browser.