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

What is the right syntax for doing this?

After setting up the stencils I want to call:
MatSetValuesStencil(jac,1,&row,15,col,v,INSERT_VALUES);

Should I put 15 as the number of columns being entered. (5 point stencil, 3 
degrees of freedom in each point)

Best,
Hui
________________________________________
From: Jed Brown [[email protected]]
Sent: Saturday, June 21, 2014 11:28 AM
To: Sun, Hui; [email protected]
Subject: Re: [petsc-users] Vec Set DM and Mat Set DM

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

> I'm thinking about defining a distributed Vec using grid information. The 
> usual way to do that is to call VecCreateMPI, or VecCreate and VecSetSizes. 
> However, that does not necessarily distribute Vec according to the grid 
> information, DM. I'm thinking of doing something like:
>
> ierr = DMDAGetInfo(da,0,&mx,&my,0,0,0,0,0,0,0,0,0,0);CHKERRQ(ierr);
>
> ierr = DMDAGetCorners(da,&xs,&ys,NULL,&xm,&ym,NULL);
>
>
> and then define the Vec according to (xs,ys,xm,ym).

Use DMCreateGlobalVector() and DMCreateLocalVector().

Reply via email to