[petsc-users] Mat indices

Feng Shi fshi at fit.edu
Sun Sep 21 13:59:18 CDT 2014


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

Best regards,

Feng

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

Feng  Shi <fshi at fit.edu> writes:

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

If you use a collocated discretization, yes.  Though you might want to
use a staggered/mixed scheme for curl-compatibility.

> For each node in this case, there are 6*6=36 elements for each block,
> am I right?

Yes, for collocated.

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

The "..." part above is important, but yes, that's the general idea.


More information about the petsc-users mailing list