[petsc-users] Understanding DMDAGetElements()

Constantine Khroulev c.khroulev at gmail.com
Tue Feb 2 19:17:52 CST 2016


Hello PETSc developers,  I recently discovered 
DMDAGetElements()[1] and got excited about using it... but then I 
realized that I don't understand what it does well enough to use 
it.   So, here is a question. Consider the four by four grid 
pictured below, split across 2 processes. There are 16 nodes 
(marked with MPI ranks that own them) and 9 elements. 
#+BEGIN_SRC artist 
  1---------1---------1---------1 |         |         |         | 
  |    6    |    7    |    8    | |         |         |         | 
  1---------1---------1---------1 |         |         |         | 
  |    3    |    4    |    5    | |         |         |         | 
  0---------0---------0---------0 |         |         |         | 
  |    0    |    1    |    2    | |         |         |         | 
  0---------0---------0---------0 
#+END_SRC  I expect DMDAGetElements(...) to return 6 elements (0, 
1, 2, 3, 4, 5) on rank 0, because those are the elements I would 
need to integrate over to add up contributions to nodes owned by 
this rank. Similarly, on rank 1 I also expect to get 6 elements 
(3, 4, 5, 6, 7, 8).   Instead I see 3 elements on rank 0 and 6 
elements on rank 1.

Please see the minimal setup in dm-get-elements.c; running it on 2 
cores produces the following.

$ mpiexec -n 2 ./dm-get-elements rank 0: 3 elements element 0: [ 0 
1 5 4 ] element 1: [ 1 2 6 5 ] element 2: [ 2 3 7 6 ] rank 1: 6 
elements element 0: [ 0 1 5 4 ] element 1: [ 1 2 6 5 ] element 2: 
[ 2 3 7 6 ] element 3: [ 4 5 9 8 ] element 4: [ 5 6 10 9 ] element 
5: [ 6 7 11 10 ]

What am I doing wrong here?   Thank you!

[1]: 
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMDAGetElements.html 

-- 
Constantine

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dm-get-elements.c
Type: application/octet-stream
Size: 2026 bytes
Desc: A minimal test program
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160202/f89617c2/attachment-0001.obj>


More information about the petsc-users mailing list