On 4/29/14 7:07 AM, Anush Krishnan wrote:
Hi all,

I created a DMComposite using two DMDAs (representing the x and y components of velocity in a 2-D staggered cartesian grid used for CFD simulations). DMCompositeGetISLocalToGlobalMappings gives me the global indices of the elements and ghost cells, which I can use to set up a matrix that operates on the vector created with the DMComposite. I obtain the correct global indices for all the interior points. But when I look at the global indices of the ghost cells, the ones outside the domain from the x-component DM return -1, but the ones outside the domain from the y-component DM return a positive value (which seems to be the largest global index of the interior points on Process 0). My question is: Why do they not return -1? Wouldn't that make matrix assembly easier (since MatSetValues ignores negative indices)? I have attached a code which demonstrates the above.

On a related note: Is it possible to use MatSetValuesStencil for assembling a block diagonal matrix that operates on a vector created using the above DMComposite?

Thanks,
Anush
You can do the whole thing much easier (to my opinion).
Since you created two DMDA anyway, just do:

- find first index on every processor using MPI_Scan
- create two global vectors (no ghosts)
- put proper global indicies to global vectors
- create two local vectors (with ghosts) and set ALL entries to -1 (to have what you need in boundary ghosts)
- call global-to-local scatter

Done!

The advantage is that you can access global indices (including ghosts) in every block using i-j-k indexing scheme.
I personally find this way quite easy to implement with PETSc

Anton

Reply via email to