/***************************************************************************** * 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 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); }
int METIS_MeshToDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, idx_t *ncommon, idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy) { int sigrval=0, renumber=0; /* set up malloc cleaning code and signal catchers */ if (!gk_malloc_init()) return METIS_ERROR_MEMORY; gk_sigtrap(); if ((sigrval = gk_sigcatch()) != 0) goto SIGTHROW; /* renumber the mesh */ if (*numflag == 1) { ChangeMesh2CNumbering(*ne, eptr, eind); renumber = 1; } /* create dual graph */ *r_xadj = *r_adjncy = NULL; CreateGraphDual(*ne, *nn, eptr, eind, *ncommon, r_xadj, r_adjncy); SIGTHROW: if (renumber) ChangeMesh2FNumbering(*ne, eptr, eind, *ne, *r_xadj, *r_adjncy); gk_siguntrap(); gk_malloc_cleanup(0); if (sigrval != 0) { if (*r_xadj != NULL) free(*r_xadj); if (*r_adjncy != NULL) free(*r_adjncy); *r_xadj = *r_adjncy = NULL; } return metis_rcode(sigrval); }