Lisandro, Go ahead and add it. Barry On May 30, 2008, at 10:55 AM, Lisandro Dalcin wrote:
I want to ask all you for adding better support for petsc4py in core PETSc.
All what I need to to add to opaque pointers in the base PetscObject structure, like this
void *pycontext PetscErrorcode (*pydestroy)(void*)
As you see, this will not make core PETSc depend on Python in any way. Additionally, the extra memory overhead is small, just to pointers..
My intention is to put a Python dictionary in the pycontext pointer, and call pydestroy function pointer (I'll set if when needed) at the time PetscHeaderDestroy is called.
Such a feature is currently being emulated with PetscContainer and PetscObjectCompose, but I would really like to cleanup this hackery and implement things the right way.
I've started to migrate my SWIG-based wrappers to use Cython. This is preliminar and not yet ready for public consumption, but at firts I anticipate this approach if far easier to understand, extend, and maintain than the previous one. In the near future, making petsc4py interoperate with C/C++/Fortran user code will be possible and easy.
For example, I saw the new Picard implementation in SNES. Such a feature could be implemented with a few lines of pure Python code, no point to have to write a full SNES type implementation (unless it is really needed). Just write in Python a custom nonlinear solver, and now run your C/C++/Fortran code with an special option in the command line, and PETSc picks-up and used the Python code implementing your solver.
-- Lisandro Dalc�n --------------- Centro Internacional de M�todos Computacionales en Ingenier�a (CIMEC) Instituto de Desarrollo Tecnol�gico para la Industria Qu�mica (INTEC) Consejo Nacional de Investigaciones Cient�ficas y T�cnicas (CONICET) PTLC - G�emes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594