2009/2/14 Johan Hake <[email protected]>:
> On Saturday 14 February 2009 21:09:34 A Navaei wrote:
>> 2009/2/14 Johan Hake <[email protected]>:
>>  [snip]
>>
>> >> > Again, you do not want to do this as you then won't be able to use
>> >> > your overloaded eval function, as the Function will then be treated to
>> >> > be discrete, i.e., using the coefficients in _vector together with the
>> >> > basis function in the FunctionSpace to interpolate any eval().
>> >>
>> >> Yes, that's why I'm working on wrapping shared_ptr.
>> >
>> > Then you should definetly switch to the development version, or you won't
>> > get it to work ;)
>>
>> Raw pointers get wrapped fine.
>
> Ok.
>
>> I simply tried replacing
>> dolfin/swig/*.i with the new development versions, but it didn't help.
>
> No you have to switch the whole cake, together with ufc, ffc, and instant :)
>

I've tried it with the development version. Finally, boost:shared_ptr
gets wrapped, however, the resulting python objects are not really
useful. Again, this is not specific to my code and the problem exists
in the current dolfin wrapping mechamism. Here is a demonstraion:

In [43]: from dolfin import *
In [44]: mesh = UnitSquare(100, 100)
In [45]: V = FunctionSpace(mesh, "CG", 1)
In [46]: f = Function(V)

In [47]: f.function_space()
Out[47]: <dolfin.functionspace.FunctionSpace; proxy of <Swig Object of
type 'boost::shared_ptr< dolfin::FunctionSpace > *' at 0x9e64880> >

In [48]: f.function_space_ptr()
Out[48]: <dolfin.cpp.FunctionSpace; proxy of <Swig Object of type
'boost::shared_ptr< dolfin::FunctionSpace > *' at 0xa9d8540> >

So, they are both proxies of the same class defined in different
modules. Now, let's check the type:

In [50]: isinstance(f.function_space(), FunctionSpace)
Out[50]: True

In [51]: isinstance(f.function_space_ptr(), FunctionSpace)
Out[51]: False

Despite this, all functions can be called just the same as each other:

In [53]: f.function_space().dim()
Out[53]: 10201

In [54]: f.function_space_ptr().dim()
Out[54]: 10201

So effectively, since the python functions perform type checking using
isinstance, they block the wrapped shared pointers, eg:

interpolate(f, f.function_space())

works, but,

interpolate(f, f.function_space_ptr())

doesn't.


-Ali
_______________________________________________
DOLFIN-dev mailing list
[email protected]
http://www.fenics.org/mailman/listinfo/dolfin-dev

Reply via email to