METIS_MeshToDual Interface

interface
public function METIS_MeshToDual(ne, nn, eptr, eind, ncommon, numflag, xadj, adjncy) result(ierr) bind(C,name="METIS_MeshToDual")

Arguments

Type IntentOptional AttributesName
integer(kind=idx_t), intent(in) :: ne

The number of elements in the mesh.

integer(kind=idx_t), intent(in) :: nn

The number of nodes in the mesh.

integer(kind=idx_t), intent(in), dimension(*):: eptr

The pair of arrays storing the mesh as described in Section 5.6 of the manual.

integer(kind=idx_t), intent(in), dimension(*):: eind

The pair of arrays storing the mesh as described in Section 5.6 of the manual.

integer(kind=idx_t), intent(in) :: ncommon

The number of common nodes that two elements must have in order to put an edge between them in the dual graph.

integer(kind=idx_t), intent(in) :: numflag

Used to indicate which numbering scheme is used for eptr and eind. The possible values are:
0 - C-style numbering is assumed that starts from 0
1 - Fortran-style numbering is assumed that starts from 1

type(c_ptr), intent(out) :: xadj

These arrays store the adjacency structure of the generated dual graph. The format of the adjacency structure is described in Section 5.5 of the manual.

type(c_ptr), intent(out) :: adjncy

These arrays store the adjacency structure of the generated dual graph. The format of the adjacency structure is described in Section 5.5 of the manual.

Return Value integer(kind=idx_t)

METIS_OK - Indicates that the function returned normally.
METIS_ERROR_INPUT - Indicates an input error.
METIS_ERROR_MEMORY - Indicates that it could not allocate the required memory.
METIS_ERROR - Indicates some other type of error.

Description

This function is used to generate the dual graph of a mesh.

Example

The code below generates the nodal graph of the following mesh: image

use iso_c_binding, only : c_ptr, c_f_pointer
use metis_interface, only: idx_t, METIS_MeshToDual, METIS_Free
integer(kind=idx_t), parameter :: ne = 3, nn = 8, npel = 4
integer(kind=idx_t) :: ierr, eptr(ne+1), eind(ne*npel), numflag, ncommon
type(c_ptr) :: xadj, adjncy
integer(kind=idx_t), dimension(:), pointer :: fxadj => null(), fadjncy => null()

numflag = 0 ! C-style numbering
ncommon = 2 ! 2 common nodes per edge
eptr = [0,4,8,12]
eind = [0,1,2,3,1,4,5,2,4,6,7,5] ! note four nodes per element

ierr = METIS_MeshToDual(ne,nn,eptr,eind,ncommon,numflag,xadj,adjncy)
call c_f_pointer(xadj,fxadj,shape=[ne+1]) ! xadj is of the size ne+1
call c_f_pointer(adjncy,fadjncy,shape=[fxadj(ne+1)]) ! last value in xadj is the size of adjncy

 !... use values in fxadj and fadjncy ...

call METIS_Free(xadj)
call METIS_Free(adjncy)
end