[petsc-users] A question of DMPlexGetAdjacency

Lawrence Mitchell lawrence.mitchell at imperial.ac.uk
Mon Nov 14 09:09:42 CST 2016


> On 14 Nov 2016, at 14:59, leejearl <leejearl at 126.com> wrote:
> 
> Hi all:
> 
>    I am not sure the using of the function "DMPlexGetAdjacency".
> 
>    My codes are as follows:
> 
>    PetscInt adj, *adjSize=NULL;
> 
>    ierr = DMPlexGetAdjacency(dm, p,  &adj, &adj);


Your calling sequence is wrong:

PetscInt adjSize;
PetscInt *adj = NULL;

ierr = DMPlexGetAdjacency(dm, p, &adjSize, &adj); CHKERRQ(ierr);

adjSize is now the size of the adj array.  You should remember to free it afterwards:

/* use adj here *
...

ierr = PetscFree(adj); CHKERRQ(ierr);

Lawrence


More information about the petsc-users mailing list