[petsc-users] MatSetValue in Fortran

Yann Jobic yann.jobic at univ-amu.fr
Wed Feb 9 04:56:30 CST 2022


Dear All,

I'm facing a strange problem. I did not succeed in putting some values 
in an MPI matrix. I'm using Petsc 3.16.4. The matrix is pre-allocated, 
with some zeroes at the right position.

To explain the context, it's a finit elements code, thus in the tangent 
matrix creation, i've got a first loop over the elements, and feed the 
matrix accordingly. This part is working. I'm using ADD_VALUES.

I then have to put the periodic boundary conditions on some nodes, that 
is to say that i've got 1 at the diagonal, and -1 on the mirror element 
of the designated ddl  (i've got a Newton-Raphson minimisation 
procedure). I'm using INSERT_VALUES here.

According to the documentation, i should do :

Loop over Elements
call MatSetValues
end loop
call MatAssemblyBegin(A,MAT_FLUSH_ASSEMBLY,ierr);CHKERRA(ierr)
call MatAssemblyEnd(A,MAT_FLUSH_ASSEMBLY,ierr);CHKERRA(ierr)

Loop over periodic nodes
call MatSetValue
end loop
call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr);CHKERRA(ierr)
call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr);CHKERRA(ierr)

But it's not working. I don't have those values from the periodic 
boundary condition in the global matrix. The return value of MatSetValue 
is 0.

I tried valgrind, but memory access looks ok. I really don't know how to 
debug this. Do you have any idea of what could happen here ?
Debug ideas ?

Many thanks,

Best Regards,

Yann


More information about the petsc-users mailing list