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
|
/*
* Copyright 1997, Regents of the University of Minnesota
*
* mesh2nodal.c
*
* This file reads in the element node connectivity array of a mesh and writes
* out its dual in the format suitable for Metis.
*
* Started 9/29/97
* George
*
* $Id: mesh2nodal.c,v 1.1 1998/11/27 17:59:35 karypis Exp $
*
*/
#include <metis.h>
/*************************************************************************
* Let the game begin
**************************************************************************/
main(long argc, char *argv[])
{
long i, j, ne, nn, etype, numflag=0;
idxtype *elmnts, *xadj, *adjncy;
timer IOTmr, DUALTmr;
char fileout[256], etypestr[4][5] = {"TRI", "TET", "HEX", "QUAD"};
if (argc != 2) {
printf("Usage: %s <meshfile>\n",argv[0]);
exit(4);
}
cleartimer(IOTmr);
cleartimer(DUALTmr);
starttimer(IOTmr);
elmnts = ReadMesh(argv[1], &ne, &nn, &etype);
stoptimer(IOTmr);
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("Forming Nodal Graph... ----------------------------------------------\n");
xadj = idxmalloc(nn+1, "main: xadj");
adjncy = idxmalloc(20*nn, "main: adjncy");
starttimer(DUALTmr);
METIS_MeshToNodal(&ne, &nn, elmnts, &etype, &numflag, xadj, adjncy);
stoptimer(DUALTmr);
printf(" Nodal Information: #Vertices: %ld, #Edges: %ld\n", nn, xadj[nn]/2);
sprintf(fileout, "%s.ngraph", argv[1]);
starttimer(IOTmr);
WriteGraph(fileout, nn, xadj, adjncy);
stoptimer(IOTmr);
printf("\nTiming Information --------------------------------------------------\n");
printf(" I/O: \t\t %7.3f\n", gettimer(IOTmr));
printf(" Nodal Creation:\t\t %7.3f\n", gettimer(DUALTmr));
printf("**********************************************************************\n");
GKfree(&elmnts, &xadj, &adjncy, LTERM);
}
|