[2051] | 1 | /* |
---|
| 2 | * Copyright 1997, Regents of the University of Minnesota |
---|
| 3 | * |
---|
| 4 | * partdmesh.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: partdmesh.c,v 1.1 1998/11/27 17:59:38 karypis Exp $ |
---|
| 13 | * |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include <metis.h> |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | /************************************************************************* |
---|
| 21 | * Let the game begin |
---|
| 22 | **************************************************************************/ |
---|
| 23 | main(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 Dual Graph... ------------------------------------------\n"); |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | starttimer(DUALTmr); |
---|
| 60 | METIS_PartMeshDual(&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 = nn; |
---|
| 77 | graph.xadj = idxmalloc(nn+1, "xadj"); |
---|
| 78 | graph.vwgt = idxsmalloc(nn, 1, "vwgt"); |
---|
| 79 | graph.adjncy = idxmalloc(20*nn, "adjncy"); |
---|
| 80 | graph.adjwgt = idxsmalloc(20*nn, 1, "adjncy"); |
---|
| 81 | |
---|
| 82 | METIS_MeshToNodal(&ne, &nn, elmnts, &etype, &numflag, graph.xadj, graph.adjncy); |
---|
| 83 | |
---|
| 84 | ComputePartitionInfo(&graph, nparts, npart); |
---|
| 85 | |
---|
| 86 | GKfree(&graph.xadj, &graph.adjncy, &graph.vwgt, &graph.adjwgt, LTERM); |
---|
| 87 | */ |
---|
| 88 | |
---|
| 89 | GKfree(&elmnts, &epart, &npart, LTERM); |
---|
| 90 | |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | |
---|