← Back to team overview

dolfin team mailing list archive

PyDOLFIN, SWIG and overloaded constructor

 

Hi

I have added a constructor to PETScMatrix to allow me to control whether the
matrix is to be created in parallel or not.  The declarations are given
below

/// Create empty matrix
explicit PETScMatrix(Type type=default_matrix);

/// Create an empty matrix explicitly setting the parallel flag
explicit PETScMatrix(bool is_parallel, Type type=default_matrix);

The idea is that I use

S = PETScMatrix(False)

If I want to create a matrix that is local.  The problem is that swig can't
differentiate between Type and bool (and uint for the PETScMatrix(uint M,
uint N, Type type=default_matrix); constructor).  I have seen that it is
possible to rename PETScMatrix(bool) to PETScMatrix_bool(bool) for example
so that the python call would be

S = PETScMatrix_bool(False),

but I can't seem to get this working.  Any suggestions?

Thanks
Evan

Follow ups