On 19/8/2015 4:26 PM, Dave May wrote:


On 19 August 2015 at 10:20, TAY wee-beng <[email protected] <mailto:[email protected]>> wrote:


    On 19/8/2015 1:17 PM, Dave May wrote:


    On 19 August 2015 at 03:38, TAY wee-beng <[email protected]
    <mailto:[email protected]>> wrote:

        Hi,

        I am using DA. For e.g.

        DM da_u

        call
        
DMDACreate3d(MPI_COMM_WORLD,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DMDA_STENCIL_STAR,size_x,size_y,&

        
size_z,1,PETSC_DECIDE,PETSC_DECIDE,1,stencil_width,lx,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da_u,ierr)

        call DMCreateGlobalVector(da_u,u_global,ierr)

        call DMCreateLocalVector(da_u,u_local,ierr)

        To update the ghost values, I use:

        call DMLocalToLocalBegin(da_u,u_local,INSERT_VALUES,u_local,ierr)

        call DMLocalToLocalEnd(da_u,u_local,INSERT_VALUES,u_local,ierr)



    This is incorrect.
    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."
    To update ghost values from a global vector (e.g. to perform the
    scatter) you need to use DMGlobalToLocalBegin() ,
    DMGlobalToLocalEnd().


I must apologize (and should have read my own email :D)
- I misunderstood what DMLocalToLocalBegin/End does.
Indeed it will give produce the correct / updated ghost values.

    Hi Dave,

    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

    So for 2 procs,

    there will be 2 da_u_array - da_u_array(1:5) and da_u_array(4:8)

    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:

    call DMLocalToLocalBegin(da_u,u_local,INSERT_VALUES,u_local,ierr)

    call DMLocalToLocalEnd(da_u,u_local,INSERT_VALUES,u_local,ierr)

    and it seems to be enough. I check the ghost values and they have
    been updated.


Yeah, this is correct.
Sorry about my mistake in the previous email regarding what DMLocalToLocal actually does.

    So if I am not using the linear solvers, I do not need the global
    vector,is that so?


I guess in the end it is application specific whether you need a global vector or not.
I would have thought you always would want a global vector.

What is your application where you don't require a global vector?
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.

Thanks

Cheers,
  Dave


Reply via email to