[petsc-users] Better understanding VecScatter

Matthew Knepley knepley at gmail.com
Thu Oct 4 09:34:48 CDT 2018


On Thu, Oct 4, 2018 at 8:56 AM Phil Tooley <phil.tooley at 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 may not be understanding correctly, but it sounds like this can be done
simply
using two DMs. The first DM is your original one holding the field values.
The
second one would set dof = dim in your new DM but everything else the same.
You can use


https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMDA/DMDACreateCompatibleDMDA.html

Then stick the gradients in a global vector for the new DM. Then do
GlobalToNatural
for that DM.

Is this what you want?

  Thanks,

     Matt


> 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
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181004/0e1e1b1d/attachment.html>


More information about the petsc-users mailing list