/* * Copyright 1997, Regents of the University of Minnesota * * mesh.c * * This file contains routines for converting 3D and 4D finite element * meshes into dual or nodal graphs * * Started 8/18/97 * George * * $Id: mesh.c,v 1.1 1998/11/27 17:59:20 karypis Exp $ * */ #include /***************************************************************************** * This function creates a graph corresponding to the dual of a finite element * mesh. At this point the supported elements are triangles, tetrahedrons, and * bricks. ******************************************************************************/ void METIS_MeshToDual(int *ne, int *nn, idxtype *elmnts, int *etype, int *numflag, idxtype *dxadj, idxtype *dadjncy) { int esizes[] = {-1, 3, 4, 8, 4}; if (*numflag == 1) ChangeMesh2CNumbering((*ne)*esizes[*etype], elmnts); GENDUALMETIS(*ne, *nn, *etype, elmnts, dxadj, dadjncy); if (*numflag == 1) ChangeMesh2FNumbering((*ne)*esizes[*etype], elmnts, *ne, dxadj, dadjncy); } /***************************************************************************** * This function creates a graph corresponding to the finite element mesh. * At this point the supported elements are triangles, tetrahedrons. ******************************************************************************/ void METIS_MeshToNodal(int *ne, int *nn, idxtype *elmnts, int *etype, int *numflag, idxtype *dxadj, idxtype *dadjncy) { int esizes[] = {-1, 3, 4, 8, 4}; if (*numflag == 1) ChangeMesh2CNumbering((*ne)*esizes[*etype], elmnts); switch (*etype) { case 1: TRINODALMETIS(*ne, *nn, elmnts, dxadj, dadjncy); break; case 2: TETNODALMETIS(*ne, *nn, elmnts, dxadj, dadjncy); break; case 3: HEXNODALMETIS(*ne, *nn, elmnts, dxadj, dadjncy); break; case 4: QUADNODALMETIS(*ne, *nn, elmnts, dxadj, dadjncy); break; } if (*numflag == 1) ChangeMesh2FNumbering((*ne)*esizes[*etype], elmnts, *nn, dxadj, dadjncy); } /***************************************************************************** * This function creates the dual of a finite element mesh ******************************************************************************/ void GENDUALMETIS(int nelmnts, int nvtxs, int etype, idxtype *elmnts, idxtype *dxadj, idxtype *dadjncy) { int i, j, jj, k, kk, kkk, l, m, n, nedges, mask; idxtype *nptr, *nind; idxtype *mark, ind[200], wgt[200]; int esize, esizes[] = {-1, 3, 4, 8, 4}, mgcnum, mgcnums[] = {-1, 2, 3, 4, 2}; mask = (1<<11)-1; mark = idxsmalloc(mask+1, -1, "GENDUALMETIS: mark"); /* Get the element size and magic number for the particular element */ esize = esizes[etype]; mgcnum = mgcnums[etype]; /* Construct the node-element list first */ nptr = idxsmalloc(nvtxs+1, 0, "GENDUALMETIS: nptr"); for (j=esize*nelmnts, i=0; i0; i--) nptr[i] = nptr[i-1]; nptr[0] = 0; for (i=0; i=nptr[n]; k--) { if ((kk = nind[k]) <= i) break; kkk = kk&mask; if ((l = mark[kkk]) == -1) { ind[m] = kk; wgt[m] = 1; mark[kkk] = m++; } else if (ind[l] == kk) { wgt[l]++; } else { for (jj=0; jj0; i--) dxadj[i] = dxadj[i-1]; dxadj[0] = 0; free(mark); free(nptr); free(nind); } /***************************************************************************** * This function creates the nodal graph of a finite element mesh ******************************************************************************/ void TRINODALMETIS(int nelmnts, int nvtxs, idxtype *elmnts, idxtype *dxadj, idxtype *dadjncy) { int i, j, jj, k, kk, kkk, l, m, n, nedges; idxtype *nptr, *nind; idxtype *mark; /* Construct the node-element list first */ nptr = idxsmalloc(nvtxs+1, 0, "TRINODALMETIS: nptr"); for (j=3*nelmnts, i=0; i0; i--) nptr[i] = nptr[i-1]; nptr[0] = 0; mark = idxsmalloc(nvtxs, -1, "TRINODALMETIS: mark"); nedges = dxadj[0] = 0; for (i=0; i0; i--) nptr[i] = nptr[i-1]; nptr[0] = 0; mark = idxsmalloc(nvtxs, -1, "TETNODALMETIS: mark"); nedges = dxadj[0] = 0; for (i=0; i0; i--) nptr[i] = nptr[i-1]; nptr[0] = 0; mark = idxsmalloc(nvtxs, -1, "HEXNODALMETIS: mark"); nedges = dxadj[0] = 0; for (i=0; i0; i--) nptr[i] = nptr[i-1]; nptr[0] = 0; mark = idxsmalloc(nvtxs, -1, "QUADNODALMETIS: mark"); nedges = dxadj[0] = 0; for (i=0; i