So if you have three processors you would want the first processor to have all x gradients, etc.?
You could use ISCreateGeneral: https://www.mcs.anl.gov/petsc/petsc-current/src/dm/examples/tutorials/ex6.c.html You need to create an integer array with the global indices that you want to bring to your new vector locally. On Thu, Oct 4, 2018 at 8:56 AM Phil Tooley <phil.too...@sheffield.ac.uk> wrote: > Hi all, > > I am trying to understand how to create a custom scatter from petsc > ordering in a local vector to natural ordering in a global vector. > > I have a 3D DMDA and local vector containing field data and am > calculating the x y and z gradients into their own local vectors. I > then need to scatter these gradients to different parts of a single > vector so they are arranged [x_1 .. x_n y_1 .. y_n z_1 .. z_n] with > natural ordering. (This is for use in a custom numerical scheme that I > have been asked to parallelise) > > I can of course do this using multiple scatters but I need to perform > this operation regularly and would like to express it as a single > scatter operation if possible. > > I know I need to get the relevant AO from my DMDA and use it to > construct appropriate ISs to build the scatter context but I am unsure > how exactly to go about this. > > Can someone point me in the right direction please? > > Many Thanks > > Phil > > -- > Phil Tooley > Research Software Engineering > University of Sheffield > >