[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
adding better support for petsc4py in core PETSc
- To: petsc-dev@xxxxxxxxxxx
- Subject: adding better support for petsc4py in core PETSc
- From: "Lisandro Dalcin" <dalcinl@xxxxxxxxx>
- Date: Fri, 30 May 2008 12:55:15 -0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=G07a8BaP+5Fzuu/pf1xltfEvkPUq85MaaVEqYMbp/W4=; b=uG5IjUKhvFbt3Vp7x0tduObDk+h9HtkzCN3gVr0AIHU3IbzCzEBuCPBS3BBEgEG3SPa1d7BkkVlt7GcY6X3jmG0CtlKReAMBYmjg6Xx5yHQhR0ifF7jcn1vWf6DLACt59sjA+9MPhFu+XONg/oo5S1inCtV6wanzCo5AxTWf0es=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=QXfFw4uizIKqiYpZhPDY6O2xsxmp9GC+edFcYeGIS0rbCSF/jamgjqfrXoKJvLztGCdSlzCioY4GNWiH9Ot3uy+aLinou8keiGGg77Qe5GQaE/9SlVXCuVqhUxQcbS/PA2LhCTTn4SCcHep8souN4HL7v9FVUML8T+sbGkEqvog=
- Reply-to: petsc-dev@xxxxxxxxxxx
- Sender: owner-petsc-dev@xxxxxxxxxxx
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