[petsc-users] On the usage of MatSetValuesBlocked

Matthew Knepley knepley at gmail.com
Thu Nov 3 11:26:15 CDT 2022


On Thu, 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) ?
>

No, you pass a contiguous chunk of memory, but it is _logically_ 2D in that
the size is (idxm * bs) x (idxn * bs)

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.

  Thanks,

     Matt


> Thank you as always!
>
>
>

-- 
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/20221103/4bbca1e2/attachment.html>


More information about the petsc-users mailing list