[petsc-users] MATIS and DMDA in petsc4py

Loic Gouarin loic.gouarin at math.u-psud.fr
Mon Apr 23 06:25:11 CDT 2018


Thanks Lawrence for your reply.

Le 23/04/2018 à 12:36, Lawrence Mitchell a écrit :
>
>> 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?
The problem probably comes from the conda package. I reinstalled a new 
environment and tried again but I still have this issue.

Did you compile petsc and petsc4py ?

The versions that I use are those given on conda-forge : petsc-3.8.4 and 
petsc4py-3.8.1.

I did the following thing

conda create -n petsc_tmp
source activate petsc_tmp
conda install petsc4py -c conda-forge

and execute my script.

Loic
>
> 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
>>

-- 
Tel: 01 69 15 60 14
http://www.math.u-psud.fr/~gouarin
https://github.com/gouarin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180423/e7dfd331/attachment.html>


More information about the petsc-users mailing list