[petsc-users] Accessing Global Vector Data with

Matthew Knepley knepley at gmail.com
Thu Aug 15 10:09:46 CDT 2019


On Thu, Aug 15, 2019 at 10:59 AM Daniel Mckinnell via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hi,
> Attached is a way I came up with to access data in a global vector, is
> this the best way to do this or are there other ways? It would seem
> intuitive to use the global PetscSection and VecGetValuesSection but this
> doesn't seem to work on global vectors.
>
> Instead I have used VecGetValues and VecSetValues, however I also have a
> problem with these when extracting more than one value, I initialise the
> output of VecGetValues as PetscScalar *values; and then call VecGetValues(Other
> stuff... , values). This seems to work some times and not others and I
> can't find any rhyme or reason to it?
>

I guess I should write something about this. I like to think of it as a
sort of decision tree.

1) Get just local values, meaning those owned by this process

    These can be obtained from either a local or global vector.

2) Get ghosted values, meaning those values lying on unowned points that
exist in the default PetscSF

    These can only get obtained from a local vector

3) Get arbitrary values

    You must use a VecScatter or custom PetscSF to get these

For 1) and 2), I think the best way to get values normally is to use


https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMPLEX/DMPlexPointLocalRef.html

https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMPLEX/DMPlexPointGlobalRef.html

These also have Read versions, and Field version to split off a particular
field in the Section.

  Does this help?

    Thanks,

      Matt


> Finally I was wondering if there is a good reference code base on Github
> including DMPlex that would be helpful in viewing applications of the
> DMPlex functions?
> Thanks,
> Daniel Mckinnell
>


-- 
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/20190815/adf28cf0/attachment-0001.html>


More information about the petsc-users mailing list