[petsc-users] MATIS and DMDA in petsc4py

Lawrence Mitchell lawrence.mitchell at imperial.ac.uk
Mon Apr 23 05:36:22 CDT 2018



> On 23 Apr 2018, at 11:32, Loic Gouarin <loic.gouarin at math.u-psud.fr> wrote:
> 
> Hi,
> 
> I try to use MATIS from petsc4py but I am not able to use setValuesLocal (I have a segmentation fault). And I don't understand why.
> 
> Could you tell me if I did a mistake or if it's a bug ?

This code works for me with:

PETSc: 7bfdb6492ce
petsc4py: 9137bf78e

Perhaps you have a mismatching petsc4py/PETSc combo?

Lawrence

> My example
> =======
> from petsc4py import PETSc
> import numpy as np
> 
> n = 10
> da = PETSc.DMDA().create([n, n], dof=1, stencil_width=1)
> da.setMatType(PETSc.Mat.Type.IS)
> 
> A = da.createMatrix()
> #ltog = da.getLGMap()
> #A.setLGMap(ltog, ltog)
> 
> elem = da.getElements()
> melem = np.ones((4, 4))
> 
> for e in elem:
>     A.setValuesLocal(e, e, melem, PETSc.InsertMode.ADD_VALUES)
> 
> Thanks,
> Loic
> 
> -- 
> Tel: 01 69 15 60 14
> http://www.math.u-psud.fr/~gouarin
> https://github.com/gouarin
> 



More information about the petsc-users mailing list