[petsc-users] Mat indices

Jed Brown jed at jedbrown.org
Sun Sep 21 13:34:02 CDT 2014


Feng  Shi <fshi at fit.edu> writes:

> Hi all,
>
> For 2-D finite difference problems with dof>1,to use
> MatSetValuesBlocked, what should be the indices used in that routine?
> Am I right if I just use the indices just like dof=1, but set
> (5*dof^2) values at one time?

That is the number of entries in a block row when using a 5-point stencil.

The row and column indices are by block, not by scalar.

> Specifically, I'm trying to use implicit TS solver with dof>1, as in example src/ts/examples/tutorials/ex10. I understand for 1-D finite diffrence cases, we have (3 by dof^2) matrix elements, and we can use as in the example: 
> MatSetValuesBlocked(B,1,&i,3,col,&K[0][0],INSERT_VALUES);
> to insert/form the Jacobian. In my 2-D cases with dof=3, I use 5-point finite difference regime, which means I will have (5*3^2=45) elements Jacobian to be set at one time as in the example, right? If I use the statement "Matstencil row, col[5]" as indices to insert values, after we set: "row.i=i, row.j=j and col[1:5].i=..., col[1:5].j=...", then just simply use:
> MatSetValuesBlocked(B,1,&row, 5, &col, &K[0][0],INSERT_VALUES);
> to insert these (5*3^2) values to form the Jacobian?
>
> I'm also confused by the dof defined in the Mat. Does it mean for each node, there are (dof^2) elements?

What "dof defined in the Mat"?
-------------- 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/0697fd68/attachment.pgp>


More information about the petsc-users mailing list