<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">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><br>Thanks,<br>Bishesh<br></div><div><br><br></div></div>