[petsc-users] petsc4py: PetSc is no longer initialised when calling C Function from Cython

Brad Aagaard baagaard at usgs.gov
Fri Oct 21 15:13:48 CDT 2011


We use SWIG in PyLith, which which uses PETSc and Sieve, and has 
high-level code in Python and low-level code in C++. With typemaps from 
numpy and just a very few of our own custom typemaps, we have wrapped 
all of our objects and functions using stripped down C++ header files. 
This has been much less work for us than using Pyrex or Cython. It 
seamless handles pointers. The typemaps from numpy make it possible to 
pass numpy arrays as C arrays (i.e., double*) with sizes with just one 
extra line to specify which typemap to use.


On 10/21/2011 09:02 AM, Jeff Wiens wrote:
> On Fri, Oct 21, 2011 at 6:53 AM, Lisandro Dalcin<dalcinl at gmail.com>  wrote:
>> BTW, have you ever used SWIG? If the functions you need to wrap are
>> simple (let say, any PetscObject subtype and scalar paramenters) you
>> can get your wrappers with less code to write on your side.
> I have heard very little about SWIG. I will take a look at it. The
> PETSc program that I'm trying to encapsulate is far from simple. If
> SWIG can only handle simple functions, it probably won't be very
> helpful.
> BTW, I removed the dynamic flag --with-dynamic from my PETSc
> installation. For some reason, my test program didn't work (the first
> time) when I installed PETSc with only the --with-shared option.
> However, I must have changed something else because it worked the
> second time I tried re-installing PETSc.
> Jeff

More information about the petsc-users mailing list