[petsc-users] question about DA

Jed Brown jedbrown at mcs.anl.gov
Sat Aug 27 15:45:49 CDT 2011


On Sat, Aug 27, 2011 at 15:39, Likun Tan <likunt at andrew.cmu.edu> wrote:

>
> I made s simple test,
>
> if i assign S[j][i]=temp[2][1][1] for all j, i; it is no problem.
>
> while, when assign S[j][i]=temp[2][3][3] for all j, i, it gives me error.
>

What are m,n,p the first time you call it and what are those values the
second time?


>
> Your last statement means that i should use temp[j][i][k] if i want to sum
> over k?
>

You can't just change the meaning of the indices when you index. Once you
fix this problem, feel confident that you understand why, and want to make
the memory access better for performance, you can look at the calls to
DMDACreate3d() and the compatible DMDACreate2d() in
src/snes/examples/tutorials/ex48.c. Also look at the calls to
DMDAGetCorners() which changes the meaning of x,y,z relative to what PETSc
uses internally.

Unfortunately this can be somewhat error-prone, so you should understand why
things work the way they do, otherwise it's too easy to get confused.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110827/53485242/attachment.htm>


More information about the petsc-users mailing list