Hi Chris, On 10/03/16 11:49, Chris Eldred wrote:
Hey All,
I am not sure if this is the correct mailing list for this, but I am using instant and petsc4py from a Firedrake install so I figured I would start here.
I am trying to get instant to compile a (minimal) example of a C function that takes in a DM (actually a DMDA), a Vec and a Mat, and then call this compiled function from a python script.
Here is the code: ****************************** import sys, petsc4py petsc4py.init(sys.argv) from petsc4py import PETSc import instant import os
include_dirs = [os.path.join(os.getenv('PETSC_DIR'), 'include'), petsc4py.get_include(), '/usr/lib/openmpi/include', '/usr/lib/openmpi/include/openmpi', ]
swig_include_dirs = [petsc4py.get_include()] library_dirs = [os.path.join(os.getenv('PETSC_DIR'),'lib')] libraries = ['petsc']
test_routine = r""" #ifdef SWIG #%include "petsc4py/petsc4py.i" #endif
#include <petsc.h>
PetscErrorCode testfunction(DM da, Mat A, Vec v) {
} """
testfunction = instant.build_module(code=test_routine, include_dirs=include_dirs, library_dirs=library_dirs, libraries=libraries,
swig_include_dirs=swig_include_dirs).testfunction
da = PETSc.DMDA().create([10,],stencil_width=1,comm=PETSc.COMM_WORLD) mat = PETSc.Mat().create(comm=PETSc.COMM_WORLD) vec = PETSc.Vec().create(comm=PETSc.COMM_WORLD) testfunction(da,mat,vec) ******************************************** This fails with:
File "minimal_instant_fail_example.py", line 37, in <module> testfunction(da,mat,vec) TypeError: in method 'testfunction', argument 1 of type 'DM'
It looks like DMDA is not being properly recognized as a subclass of DM? Is there something else that I am missing? Any help is greatly appreciated!
We dropped SWIG and instant a while ago, most due to not being able to bend our minds round the typemaps issues. So I'm at a loss as to what might be the correct solution. Lawrence