[petsc-users] Inserting nonlocal values in DMDA vector

Barry Smith bsmith at mcs.anl.gov
Wed Nov 12 16:05:42 CST 2014


> On Nov 12, 2014, at 3:48 PM, Ghosh, Swarnava <sghosh2012 at gatech.edu> wrote:
> 
> 
> Hello,
> 
>    I have a DMDA vector and I need to set values in locations which are in different processors. I am going over the mesh points in z,y and x directions so I know the k,j,i indices of every point. However the 3D array obtained using DMDAVecGetArray will not let me access the points which are in other processors. 

   I think you really want each process to handle only its own values and not have some other processor stick in those values. 


> 
> Is there some function like "VecSetValuesStencil" similar to MatSetValuesStencil which will insert values at locations which are in other processors using k,j,i index? OR Is there any function that maps the k,j,i index to a linear index so I can use VecSetValues?

Note that MatSetValuesStencil() only works for matrix entries that arise from the ghosted region of the processors domain, you cannot stick values into any old locations with MatSetValuesStencil() it will generate an error.

  You can use DMDAGetAO() then if id[] contains the numbering of your points in the global natural ordering use AOApplicationToPetsc() to map them to the PETSc ordering and then us VecSetValues(). Try it on a small problem first to make sure the correct mapping is being done.

  Barry


> 
> Regards,
> Swarnava
> -- 
> Swarnava Ghosh
> PhD Candidate,
> Structural Engineering, Mechanics and Materials
> School of Civil and Environmental Engineering
> Georgia Institute of Technology
> Atlanta, GA 30332



More information about the petsc-users mailing list