[petsc-users] Get DM used to create Vec

Matthew Knepley knepley at gmail.com
Thu Nov 16 09:39:50 CST 2023


On Thu, Nov 16, 2023 at 10:30 AM Barry Smith <bsmith at petsc.dev> wrote:

>
> https://petsc.org/release/manualpages/DM/VecGetDM/
>
> Note there is also
> https://petsc.org/release/manualpages/Sys/PetscObjectCompose/ which along
> with https://petsc.org/release/manualpages/Sys/PetscContainerCreate/ allows
> you to attach any data you like to a Vec for later access. This approach
> supports layering your own higher-level vector information on top of
> regular Vec (it is done this way to support C and old Fortran that don't
> support inheritance).
>

Caution: It is not hard to create reference cycles when using
PetscObjectCompose().

  Thanks,

     Matt


> On Nov 16, 2023, at 9:02 AM, Carl-Johan Thore <carljohanthore at gmail.com>
> wrote:
>
> Hi,
>
> Given a Vec (or Mat) created at some point with DMCreate...,
> is it possible to retrieve from this Vec a pointer to the DM used
> to create it?
>
> (I could perhaps build my own Vec-type on top of PETSc's
> which carried with it such a pointer but that doesn't seem like
> a good idea)
>
> Kind regards,
> Carl-Johan
>
>
>

-- 
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/20231116/767394cc/attachment.html>


More information about the petsc-users mailing list