On 11/23/07, Matthew Knepley <knepley at gmail.com> wrote:
> Yes, we should definitely do this. I think I already have the support for
> linking to the Python library somewhere.
>
> > Perhaps I will also ask in the near future for adding two 'slots' in
> > the base PetscObject structure for better supporting petsc4py.
>
> Yes, this is fine too. We should try and do it before the next release
> since it will be a major release.

Nice, then I'll try to add the needed changes in petsc-dev, and I'll
will surely need your help for adding support in configure system.

> > If any of you want to take a look, I have a trivial C SNES example,
>
> Cool, where is it?

Well, all this is in petsc4py SVN repo, the specific example for SNES
is at this location:

http://petsc4py.googlecode.com/svn/trunk/petsc/lib/ext/petsc/src/snes/impls/python/

The C example is 'ex1.c' (note the line calling Py_Initialize() ), the
equivalent Python example is 'ex1.py'. Both examples calls the methods
of class 'MyNewton' (implemented in file 'mysolver.py').

The actual SNESPYTHON type is implemented in file 'python.c', but that
type is actually available through petsc4py, and automatically
registered at import time.

To run the example, you have to build petsc4py SVN using petsc-2.3.3
or petsc-dev (use shared libs), and install petsc4py somewere (and put
that location on PYTHONPATH). After that, build 'ex1.c' (the
'makefile' is using the old bmake paths, fix for the petsc-dev case)
and run it like the following;

$ make ex1
$ ./ex1 -snes_type python -trace

Your will see in your terminal (because of -trace option, look at
mysolver.py at MyNewton.setFromOptions() methods) a lot of ouput
showing the methods and aguments passed during the complete nonlinear
solve.

Ask me if you have trouble with something.

I'll wait for your comments. Please note that all this is very
preliminar and was develeped in a couple of days, there is room for a
lot of improvement.


-- 
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


Reply via email to