[Dune-devel] [GSoC2016] Junior job about the Python bindings

Michaël Sghaïer sghaier.michael at gmail.com
Wed Mar 16 08:25:17 CET 2016


Hi,

I have been working on the junior job related to the Python bindings for
two days and I have some questions:

2016-03-15 14:51 GMT-04:00 Andreas Dedner:

> Note that FieldVector derives from DenseVector and many methods that need
> to be wrapped are implemented there.
>

Do we have to wrap the methods of DenseVector too or just the methods of
FieldVector?

Until this junior job, I never used Boost.Python. Though I found it very
interesting and funny to play with, it's a little tricky to use. Can you
confirm me that we can't wrap the following constructors, due to the fact
that templates have to be instanciated at compile time:


template<class C>
FieldVector (const DenseVector<C> &x, ...)

and

template<class K1, int SIZE1>
explicit FieldVector(const FieldVector<K1, SIZE1> & x)

?

(same for Base::operator= I guess)

Last question, the junior job says that the wrapper should work with a
range of dimensions. I assume that means it should be easy for a user to
add a wrapper for a particular dimension (because templates can't be
specialized at runtime, through the Python interpreter, right?).

I tried to define a template<int SIZE> struct registerFieldVector which
defines a static function pointer get_item to wrap operator[] but it
doesn't work. I have been debugging for hours now and I don't find a
solution.

For example,

static double& (*get_item) (Dune::FieldVector<double, SIZE>::size_type);

...

template<>
double& (*RegisterFieldVector<7>::get_item) (Dune::FieldVector<double,
7>::size_type = &Dune::FieldVector<double, 7>::operator[];

raises the error: "error: cannot declare pointer to ‘double&’ in
static double& (*get_item) (Dune::FieldVector<double,
SIZE>::size_type);"


Could you give me any lead?

Best,
Michaël
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20160316/58c27267/attachment.htm>


More information about the Dune-devel mailing list