File: partdmesh.c

package info (click to toggle)
metis-edf 4.1-2-4
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, bullseye, buster, sid
  • size: 3,696 kB
  • sloc: ansic: 15,702; makefile: 121; sh: 100; fortran: 61
file content (93 lines) | stat: -rw-r--r-- 2,814 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 /* 
  * Copyright 1997, Regents of the University of Minnesota 
  * 
  * partdmesh.c 
  * 
  * This file reads in the element node connectivity array of a mesh and  
  * partitions both the elements and the nodes using KMETIS on the dual graph. 
  * 
  * Started 9/29/97 
  * George 
  * 
  * $Id: partdmesh.c,v 1.1 1998/11/27 17:59:38 karypis Exp $ 
  * 
  */ 

 #include <metis.h> 



 /************************************************************************* 
 * Let the game begin 
 **************************************************************************/ 
 main(long argc, char *argv[]) 
 { 
   long i, j, ne, nn, etype, numflag=0, nparts, edgecut; 
   idxtype *elmnts, *epart, *npart; 
   timer IOTmr, DUALTmr; 
   char etypestr[4][5] = {"TRI", "TET", "HEX", "QUAD"}; 
   GraphType graph; 

   if (argc != 3) { 
     printf("Usage: %s <meshfile> <nparts>\n",argv[0]); 
     exit(4); 
   } 

   nparts = atoi(argv[2]); 
   if (nparts < 2) { 
     printf("nparts must be greater than one.\n"); 
     exit(4); 
   } 
     
   cleartimer(IOTmr); 
   cleartimer(DUALTmr); 

   starttimer(IOTmr); 
   elmnts = ReadMesh(argv[1], &ne, &nn, &etype); 
   stoptimer(IOTmr); 

   epart = idxmalloc(ne, "main: epart"); 
   npart = idxmalloc(nn, "main: npart"); 

   printf("**********************************************************************\n"); 
   printf("%s", METISTITLE); 
   printf("Mesh Information ----------------------------------------------------\n"); 
   printf("  Name: %s, #Elements: %ld, #Nodes: %ld, Etype: %s\n\n", argv[1], ne, nn, etypestr[etype-1]); 
   printf("Partitioning Dual Graph... ------------------------------------------\n"); 


   starttimer(DUALTmr); 
   METIS_PartMeshDual(&ne, &nn, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); 
   stoptimer(DUALTmr); 

   printf("  %ld-way Edge-Cut: %7ld, Balance: %5.2f\n", nparts, edgecut, ComputeElementBalance(ne, nparts, epart)); 

   starttimer(IOTmr); 
   WriteMeshPartition(argv[1], nparts, ne, epart, nn, npart); 
   stoptimer(IOTmr); 


   printf("\nTiming Information --------------------------------------------------\n"); 
   printf("  I/O:          \t\t %7.3f\n", gettimer(IOTmr)); 
   printf("  Partitioning: \t\t %7.3f\n", gettimer(DUALTmr)); 
   printf("**********************************************************************\n"); 

 /* 
   graph.nvtxs = nn; 
   graph.xadj = idxmalloc(nn+1, "xadj"); 
   graph.vwgt = idxsmalloc(nn, 1, "vwgt"); 
   graph.adjncy = idxmalloc(20*nn, "adjncy"); 
   graph.adjwgt = idxsmalloc(20*nn, 1, "adjncy"); 

   METIS_MeshToNodal(&ne, &nn, elmnts, &etype, &numflag, graph.xadj, graph.adjncy); 

   ComputePartitionInfo(&graph, nparts, npart); 

   GKfree(&graph.xadj, &graph.adjncy, &graph.vwgt, &graph.adjwgt, LTERM); 
 */ 

   GKfree(&elmnts, &epart, &npart, LTERM); 

 }