[petsc-users] Mat indices

Jed Brown jed at jedbrown.org
Sun Sep 21 14:06:59 CDT 2014


Feng  Shi <fshi at fit.edu> writes:

> Hi Jed,
>
> Thank you very much!
>
> I think I understand that now. It's really helpful to me and other beginners who will use Finite Difference with Petsc in solving 2-D and 3-D problems. Thank you.
>
> row.i=i, row.j=j, row.k=k and col[1:7].i=i,i+/-1, col[1:7].j=j,j+/-1,
> col[1:7].k=k,k+/-1. 

Note that it's really col[0] through col[6].

> then call: MatSetValuesBlockedStencil(B,1,&row, 7, &col,
> &Value[0][0],INSERT_VALUES); where Value[][] should be an array with
> 7*36=252 elements.

Yes.  If it makes the indexing more clear, you can use

PetscScalar Value[1][bs][7][bs];

there is only one row and the columns are laid out as above (same as is
most natural for a scalar problem).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140921/935c3baa/attachment.pgp>


More information about the petsc-users mailing list