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