<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 19 August 2015 at 10:20, TAY wee-beng <span dir="ltr"><<a href="mailto:zonexo@gmail.com" target="_blank">zonexo@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"><span class="">
<br>
<div>On 19/8/2015 1:17 PM, Dave May wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 19 August 2015 at 03:38, TAY
wee-beng <span dir="ltr"><<a href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am using DA. For e.g.<br>
<br>
DM da_u<br>
<br>
call
DMDACreate3d(MPI_COMM_WORLD,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DMDA_STENCIL_STAR,size_x,size_y,&<br>
<br>
size_z,1,PETSC_DECIDE,PETSC_DECIDE,1,stencil_width,lx,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da_u,ierr)<br>
<br>
call DMCreateGlobalVector(da_u,u_global,ierr)<br>
<br>
call DMCreateLocalVector(da_u,u_local,ierr)<br>
<br>
To update the ghost values, I use:<br>
<br>
call
DMLocalToLocalBegin(da_u,u_local,INSERT_VALUES,u_local,ierr)<br>
<br>
call
DMLocalToLocalEnd(da_u,u_local,INSERT_VALUES,u_local,ierr)<br>
</blockquote>
<div><br>
<br>
</div>
<div>This is incorrect. <br>
The manpage for DMLocalToLocal clearly says "Maps from a
local vector (including ghost points that contain
irrelevant values) to another local vector where the ghost
points in the second are set correctly."</div>
<div>To update ghost values from a global vector (e.g. to
perform the scatter) you need to use
DMGlobalToLocalBegin() , DMGlobalToLocalEnd().<br>
</div>
</div>
</div>
</div>
</blockquote>
</span></div></blockquote><div><br></div><div>I must apologize (and should have read my own email :D) <br>- I misunderstood what DMLocalToLocalBegin/End does. <br>Indeed it will give produce the correct / updated ghost values.<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class="">
</span><span class=""><div>Hi Dave, </div>
<div><br>
</div>
<div>Thanks for the clarification although I'm still confused.
Supposed I have a 1D vector da_u, It has size 8, so it's like
da_u_array(8), with stencil width 1</div>
<div><br>
</div>
<div>So for 2 procs,</div>
<div><br>
</div>
<div>there will be 2 da_u_array - da_u_array(1:5) and
da_u_array(4:8)</div>
<div><br>
</div>
<div>After performing some operations on each procs's da_u_array, I
need to update 1st procs's da_u_array(5) and 2nd procs's
da_u_array(4) from the 2nd and 1st procs respectively. I simply
call:</div>
<div><br>
</div>
<div>call
DMLocalToLocalBegin(da_u,u_local,INSERT_VALUES,u_local,ierr)<br>
<br>
call DMLocalToLocalEnd(da_u,u_local,INSERT_VALUES,u_local,ierr)<br>
</div>
<div><br>
</div>
<div>and it seems to be enough. I check the ghost values and they
have been updated. </div></span></div></blockquote><div><br></div><div>Yeah, this is correct. <br>Sorry about my mistake in the previous email regarding what DMLocalToLocal actually does.<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class=""><div>So if I am not using the linear solvers, I do
not need the global vector,is that so?</div></span></div></blockquote><div><br></div><div>I guess in the end it is application specific whether you need a global vector or not.<br></div><div>I would have thought you always would want a global vector.<br></div><div><br>What is your application where you don't require a global vector?<br></div><br></div><div class="gmail_quote">Cheers,<br></div><div class="gmail_quote"> Dave<br></div><div class="gmail_quote"> <div><br></div></div></div></div>