[petsc-users] MatSetValue in Fortran

Matthew Knepley knepley at gmail.com
Wed Feb 9 05:46:15 CST 2022


On Wed, Feb 9, 2022 at 5:56 AM Yann Jobic <yann.jobic at univ-amu.fr> wrote:

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

This is strange since we have tests for this kind of insertion. I would
make a tiny
code that adds two neighboring cells and a periodic boundary between the
other side.
If that fails it will be easy for us to look at the figure out what is
happening.

  Thanks,

     Matt


> Many thanks,
>
> Best Regards,
>
> Yann
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220209/598e9869/attachment.html>


More information about the petsc-users mailing list