<div dir="ltr">On Fri, Oct 4, 2013 at 6:11 AM, Bishesh Khanal <span dir="ltr"><<a href="mailto:bisheshkh@gmail.com" target="_blank">bisheshkh@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Dear all,<br></div><br>I have a part of a code that does NOT use Petsc, and contains an image K of dimensions mXnXr. <br>
</div><div>It also provides me with a function to access any value at (i,j,k), e.g. using K.getVoxelAt(i,j,k). <br>
<br></div><div><br>Now in my petsc code I create a DMDA of size mXnXr to solve a pde. The coefficients of the pde at each grid point should physically correspond to the one in the image K.<br></div><div>The usual code I would use to create a matrix from DM is:<br>

<br>DMDALocalInfo info;<br>ierr = DMDAGetLocalInfo(da,&info);CHKERRQ(ierr);<br><br>for (PetscInt k = info.zs; k<info.zs+<a href="http://info.zm" target="_blank">info.zm</a>; ++k) {<br>        for (PetscInt j = info.ys; j < info.ys+info.ym; ++j) {<br>

            for (PetscInt i = info.xs; i < info.xs+info.xm; ++i) { <br><br></div><div>//Here (i,j,k) refers to the indexing/ordering that is internally organized/distributed to different processors.<br></div><div><br>
            }<br>
        }<br> }<br><br></div><div>Now, the problem is that I cannot use getVoxel(i,j,k) within the above loop because the ordering and distribution of the image K and the function getVoxel(i,j,k) knows nothing about the "da" I create in my part of the code. K might have been stored by each processor locally. So I believe if I want to use the coefficients from the image K in my code within the above loop, first I need to either:<br>

1) create global vectors from the DMDA and copy all the values of image K to this global vector. Then access the values from this global vector.<br></div><div>or <br></div><div>2) find a way to transform (i,j,k) within the above loop to a valid (i,j,k) for the function getVoxel(i,j,k)<br>

<br></div><div>What should I do to resolve the problem ?<br></div></div></blockquote><div><br></div><div>This explanation is confused. I do not think you mean "global vector", but rather you mean the K would be completely held by every process. There</div>
<div>is only one question here:</div><div><br></div><div>   Is your image K distributed across processes?</div><div><br></div><div>If so, just match your DA to that distribution. If not, its replicated on every process and getVoxel() will work fine.</div>
<div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks,<br>Bishesh<br></div><div><br><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>