[petsc-users] On the usage of MatSetValuesBlocked

Barry Smith bsmith at petsc.dev
Thu Nov 3 15:08:49 CDT 2022


   The error indicates not enough nonzero blocks are preallocated for. Try something really simple, preallocate for one block and put in one block then call MatAssemblyBegin/End(), MatView(), if that works then work up to your full problem.

  Barry


> On Nov 3, 2022, at 3:11 PM, Edoardo alinovi <edoardo.alinovi at gmail.com> wrote:
> 
> Just to give a bit more of context I am doing like this:
> 
>         call MatCreate(PETSC_COMM_WORLD, this%A, ierr)
> 
>         call MatSetSizes(this%A, lm, lm, M, M, ierr) ! lm is the local size of the matrix , M the global one
> 
>         call MatSetType(this%A, myType, ierr) ! myType is MATMPIBAIJ
>  
>         call MatSetBlockSize(this%A, 4-bdim, ierr) ! 4-bdim is equal to 3 in this case
> 
>         call MatMPIBAIJSetPreallocation(this%A, 4-bdim, flubioSolvers%d_nz, mesh%d_nnz, flubioSolvers%o_nz, mesh%o_nnz, ierr) ! d_nnz and o_nnz is the number of diagonal and off diagonal non zero blocks
> 
>         call MatSetUp(this%A, ierr)
>         
>        ... some non relevant code .....
> 
>          call MatSetValuesBlocked(this%A, 4-bdim, mesh%cellGlobalAddr(iElement)-1, 4-bdim, mesh%cellGlobalAddr(iElement)-1, blockValues, INSERT_VALUES, ierr)  mesh%cellGlobalAddr(iElement)-1 is an integer equal (not an array) to the block element number the block matrix blockValues (3x3) belongs to.
> 
> Any evident errors? 
> 
> 
> 
> 

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


More information about the petsc-users mailing list