<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <div class="moz-cite-prefix">On 19/8/2015 4:26 PM, Dave May wrote:<br>
    </div>
    <blockquote
cite="mid:CAJ98EDpTBwxU5M-Zqg-yu8p_X=Frsq-tObH8cMbeKeYesDP_cw@mail.gmail.com"
      type="cite">
      <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 moz-do-not-send="true"
                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
                              moz-do-not-send="true"
                              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>
          </div>
        </div>
      </div>
    </blockquote>
    Well, I mean when I don't need to solve the linear eqn. But of
    course, later on in the code, when I need to, I will require the
    global vector.<br>
    <br>
    Thanks<br>
    <blockquote
cite="mid:CAJ98EDpTBwxU5M-Zqg-yu8p_X=Frsq-tObH8cMbeKeYesDP_cw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote"><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>
    </blockquote>
    <br>
  </body>
</html>