Re: [petsc-dev] Why do we use void* instead of PetscObject in PETSc?

2019-03-04 Thread Jed Brown via petsc-dev
Dave May writes: > On Mon, 4 Mar 2019 at 21:30, Jed Brown 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

Re: [petsc-dev] Why do we use void* instead of PetscObject in PETSc?

2019-03-04 Thread Jed Brown via petsc-dev
Dave May via petsc-dev writes: > I think there would be a lot of merit (in the long run) if user contexts, > such as given to KSPSetComputeOperators(), SNESSetJacobian() etc were > changed to be of type PetscObject rather than void*. > > Some obvious benefits would be: > [1] Type checking! How

Re: [petsc-dev] Why do we use void* instead of PetscObject in PETSc?

2019-03-04 Thread Isaac, Tobin G via petsc-dev
I've been working on a nonlinear map object: it would wrap up the function/derivative/second-derivative callbacks for SNES/Tao/maybe TS in an object. It doesn't do what Dave is asking: at the moment, the user still passes a (void *) as ctx to that object. Rather, I'm interested in use cases

Re: [petsc-dev] Why do we use void* instead of PetscObject in PETSc?

2019-03-04 Thread Smith, Barry F. via petsc-dev
> On Mar 4, 2019, at 5:54 AM, Dave May wrote: > > Hi Barry, > > > On Mon, 4 Mar 2019 at 03:26, Smith, Barry F. wrote: > >There is a lot of merit for this alternative approach. > >This suggestion is also closely related to the (I think it's Toby's) > proposal to replace the

Re: [petsc-dev] Why do we use void* instead of PetscObject in PETSc?

2019-03-04 Thread Hapla Vaclav via petsc-dev
Something related are functions like https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetConvergenceTest.html https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPMonitorSet.html which even have 3 parameters - the "evaluation" function, the context, and

Re: [petsc-dev] Why do we use void* instead of PetscObject in PETSc?

2019-03-03 Thread Smith, Barry F. via petsc-dev
There is a lot of merit for this alternative approach. This suggestion is also closely related to the (I think it's Toby's) proposal to replace the (function), ctx pairs that manage call backs in PETSc with objects. There will be a bit of an issue with dealing with the Fortran