[petsc-users] On the usage of MatSetValuesBlocked

Barry Smith bsmith at petsc.dev
Thu Nov 3 11:30:42 CDT 2022


  You can find the current F90 interface definitions we support for MatSetValuesBlocked() in 

/src/mat/f90-mod/petscmat.h90



> On Nov 3, 2022, at 12:16 PM, Edoardo alinovi <edoardo.alinovi at gmail.com> wrote:
> 
> Hello Jed/Barry/Petsc friends
> 
> I am trying to assemble a block matrix with 3x3 in 2D and 4x4 blocks in 3D coming from the fully coupled NS equation.
> 
> I am not sure I am understanding the example provided here:
> https://petsc.org/main/docs/manualpages/Mat/MatSetValuesBlocked/
> 
> The description says that " v - a logically two-dimensional array of values", while in the example is passed as a 1D array.
> 
> Should I pass a 2D array like v(1:nComp,1:nComp) or an array v(1:nComp*nComp) to MatSetValuesBlocked (I am using fortran that's why I start form 1 in my arrays) ? 

  We intend to support both approaches, whatever is most convenient for the rest of your code. (Perhaps more interface definitions are needed?)  

  When we say "logically" two-dimensions this is intended to mean that you can pass a one dimensional array that contains all the nonzeros in the block in the order of the first column, followed by the second column etc. (How Fortran handles two dimensional arrays normally). But in most circumstances I would guess providing directly the two dimensal Fortran array is more natural.

> 
> Are idxm and idxn the global index of each block right? I guess PETSc will correctly assign each block row and column as it knows the matrix has a given structure.

   Yes
> 
> Thank you as always! 
> 
> 

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


More information about the petsc-users mailing list