[petsc-users] Mat indices

Feng Shi fshi at fit.edu
Sun Sep 21 13:45:22 CDT 2014


Hi Jed,

I mean, for the 3-D Maxwellian equations, the field E and B are both vectors, so we have 6 scalars, in which case I can define dof=6 for each node, right? For each node in this case, there are 6*6=36 elements for each block, am I right? 

As for setting the values, I understand I can use routine MatSetValuesBlockedStencil to set Jacobian. But I don't know what indices we should use in this case? Just as the same indices as the case with dof=1? row.i=i, row.j=j and col[1:5].i=..., col[1:5].j=... then call:
MatSetValuesBlockedStencil(B,1,&row, 7, &col, &Value[0][0],INSERT_VALUES);
Am I right?

Thank you in advance!

Best regards,

Feng

________________________________________
From: Jed Brown [jed at jedbrown.org]
Sent: Sunday, September 21, 2014 2:34 PM
To: Feng  Shi; petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] Mat indices

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"?


More information about the petsc-users mailing list