[petsc-dev] Why do we use void* instead of PetscObject in PETSc?
Dave May
dave.mayhem23 at gmail.com
Mon Mar 4 15:51:57 CST 2019
On Mon, 4 Mar 2019 at 21:47, Jed Brown <jed at jedbrown.org> wrote:
> Dave May <dave.mayhem23 at gmail.com> writes:
>
> > On Mon, 4 Mar 2019 at 21:30, Jed Brown <jed at jedbrown.org> wrote:
> >
> >> If reusing, would the interface require
> >> casting the function pointers to void(*)(void) instead of what is
> >> currently type-safe for most function pointers?
> >
> >
> > No. I don't see that casting a function pointer would be required.
> > We would have
> >
> > SNESSetJacobian(SNES snes,Mat Amat,Mat Pmat,PetscErrorCode
> > (*J)(SNES,Vec,Mat,Mat,PetscObject),PetscObject ctx)
>
> Oh, the PetscObject would only contain the context, not the function
> pointer (at least not publicly).
Yes.
> What does user code look like?
>
> PetscErrorCode f(..., PetscObject ctx) {
> User user;
> ierr =
> PetscContainerGetPointer((PetscContainer)ctx,&user);CHKERRQ(ierr);
> ...
> }
>
For most basic use-cases, yes exactly like that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20190304/2705a3e5/attachment.html>
More information about the petsc-dev
mailing list