<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 20, 2014 at 1:31 PM, Danyang Su <span dir="ltr"><<a href="mailto:danyang.su@gmail.com" target="_blank">danyang.su@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi All,<br>
<br>
I use DMDA for a flow problem and found the local vector and global
vector does not match for 2D and 3D problem when dof >1.<br>
<br>
For example, the mesh is as follows:<br>
<br>
|proc 1| proc 2 | proc 3 |<br>
|7 8 9|16 17 18|25 26 27|<br>
|4 5 6|13 14 15|22 23 24|<br>
|1 2 3|10 11 12|19 20 21|<br>
<br>
<font color="#ff0000"><i>The following functions are used to create
DMDA object, global vector and local vector.</i></font><br>
<br>
call DMDACreate2d(Petsc_Comm_World,DMDA_BOUNDARY_NONE, &<br>
DMDA_BOUNDARY_NONE,
DMDA_STENCIL_BOX, &<br>
nvxgbl,nvzgbl,PETSC_DECIDE,PETSC_DECIDE, &<br>
dmda_flow%dof,
dmda_flow%swidth, &<br>
PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, &<br>
dmda_flow%da,ierr) <br>
call DMCreateGlobalVector(dmda_flow%da,x_flow,ierr)<br>
call VecDuplicate(x_flow,b_flow,ierr)<br>
call DMCreateLocalVector(dmda_flow%da,x_flow_loc,ierr)<br>
call VecDuplicate(x_flow_loc,b_flow_loc,ierr)<br>
<br>
<i><font color="#ff0000">The following functions are used to compute
the function (b_flow_loc)</font></i><br>
<br>
call VecGetArrayF90(b_flow_loc, vecpointer, ierr)<br>
<font color="#000099">vecpointer = (compute the values here...)</font><br>
call VecRestoreArrayF90(b_flow_loc,vecpointer,ierr)<br>
call
DMLocalToGlobalBegin(dmda_flow%,b_flow_loc,INSERT_VALUES,
&<br>
b_flow,ierr)<br>
call
DMLocalToGlobalEnd(dmda_flow%,b_flow_loc,INSERT_VALUES,
&<br>
b_flow,ierr)<br>
<br>
<br>
<i><font color="#ff0000">The data of local vector b_flow_loc for
proc1, proc2 and proc3 are as follows (just an example, without
ghost value)</font></i><br>
proc 1 proc 2 proc 3<br>
1 10 19<br>
2 11 20<br>
3 12 21<br>
4 13 22<br>
5 14 23<br>
6 15 24<br>
... ... ...<br>
<br>
<i><font color="#ff0000">But the global vector b_flow from Vecview
shows that the data is stored as follows (left column). I
thought the global vector b_flow is like the right column. Is
anything wrong here?</font></i></div></blockquote><div><br></div><div>On output, the global vectors are automatically permuted to the natural ordering.</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 bgcolor="#FFFFFF" text="#000000"><br>
Process [0] Process [0]<br>
1 1<br>
2 2<br>
3 3<br>
10 4<br>
11 5<br>
12 6<br>
... ... <br>
Process [1] Process [1]<br>
4 10<br>
5 11<br>
6 12<br>
13 13<br>
14 14<br>
15 15<br>
... ...<br>
Process [2] Process [2]<br>
... ...<br>
<br>
Though the data distribution is different from what I thought
before, the code works well for 1D problem and most of the 2D and 3D
problem, but failed in newton iteration for some 2D problem with dof
> 1. I use KSP solver, not SNES solver at present.<br>
<br>
Thanks and regards,<br>
<br>
Danyang<br>
<br>
<br>
</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>