Sorry, maybe I see some difference. I'm reading line 1253 from 
http://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex48.c.html

MatSetValuesBlockedStencil(B,8,rc,8,rc,&Ke[0][0],ADD_VALUES);

The Ke is 16 by 16, but rc is of length 8, so that means a 2 by 2 block is 
written into each stencil point of B. Is that correct? Now, why the compiler 
necessarily knows that Ke is of size 16 by 16? 

Best,
Hui

________________________________________
From: Sun, Hui
Sent: Saturday, June 21, 2014 4:35 PM
To: Jed Brown; [email protected]
Subject: RE: [petsc-users] Vec Set DM and Mat Set DM

I was reading examples about MatSetValuesStencil and MatSetValuesBlockStencil, 
I cannot see any difference. Why would recommend MatSetValuesBlockedStencil 
please?

It seems that there are many examples about MatSetValuesStencil but the only 
example about MatSetValuesBlockedStencil is snes/.../ex48.

Hui


________________________________________
From: Jed Brown [[email protected]]
Sent: Saturday, June 21, 2014 3:43 PM
To: Sun, Hui; [email protected]
Subject: RE: [petsc-users] Vec Set DM and Mat Set DM

"Sun, Hui" <[email protected]> writes:

> If I have a DM object with dof=3. So in each grid point, there are 3 
> components. Now if I set a Mat according to this DM object, I have something 
> like:
> MatSetValuesStencil(jac,1,&row,5,col,v,INSERT_VALUES);
>
> What shall I put in col? Usually I should have something like:
> col[0].i = i;   col[0].j = j-1;   col[1].i = i;   col[1].j = j;   etc  ...
>
> But now I want to do something like:
> col[0].i.u = i;   col[0].j.u = j-1;   col[0].i.v = i;   col[0].j.v = j-1;   
> col[0].i.p = i;   col[0].j.p = j-1;   etc  ...

MatStencil has col[0].c = 0 {1,2,...}, but I recommend using
MatSetValuesBlockedStencil() if possible.

Reply via email to