<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 4/29/14 7:07 AM, Anush Krishnan
wrote:<br>
</div>
<blockquote
cite="mid:CAGqzBJzA3_PZ9UtXAsmG7ARdGtwnxFpr-oqc11nZXDzrSLcraA@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div dir="ltr">
<div>
<div>Hi all,<br>
<br>
</div>
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.<br>
<br>
</div>
<div>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?<br>
</div>
<div><br>
</div>
<div>Thanks,<br>
</div>
<div>Anush<br>
</div>
</div>
</blockquote>
You can do the whole thing much easier (to my opinion).<br>
Since you created two DMDA anyway, just do:<br>
<br>
- find first index on every processor using MPI_Scan<br>
- create two global vectors (no ghosts)<br>
- put proper global indicies to global vectors<br>
- create two local vectors (with ghosts) and set ALL entries to -1
(to have what you need in boundary ghosts)<br>
- call global-to-local scatter<br>
<br>
Done!<br>
<br>
The advantage is that you can access global indices (including
ghosts) in every block using i-j-k indexing scheme.<br>
I personally find this way quite easy to implement with PETSc<br>
<br>
Anton<br>
</body>
</html>