← Back to team overview

dolfin team mailing list archive

Re: A minimal c++ Function test and some bugs

 

2009/2/17 A Navaei <axnavaei@xxxxxxxxxxxxxx>:
> 2009/2/17 Anders Logg <logg@xxxxxxxxx>:
>> On Tue, Feb 17, 2009 at 04:06:50PM +0000, A Navaei wrote:
>>> 2009/2/17 Anders Logg <logg@xxxxxxxxx>:
>>> > On Tue, Feb 17, 2009 at 03:59:51PM +0000, A Navaei wrote:
>>> >> 2009/2/17 A Navaei <axnavaei@xxxxxxxxxxxxxx>:
>>> >> > The following minimal test for Function in c++ reveals some bugs. I
>>> >> > guess this example can help me with dealing with the current issues of
>>> >> > ImageFunction.
>>> >> >
>>> >> > (1) interpolate.py does not work when a Function is created in c++ and
>>> >> > wrapped (see comment [2]). It seems that the bug is originated from
>>> >> > the copy constructor (see comment [3])
>>> >> >
>>> >> > (2) In order to perform the interpolation, why is it necessary to
>>> >> > create another Function and then copy it?
>>> >> >
>>> >> > (3) Signature checkes seem not working properly (see comment [1]). The
>>> >> > signature-based assignments are error-prone anyway, why the
>>> >> > object-oriented approach is not used?
>>> >> >
>>> >> >
>>> >> I'm adding another issue:
>>> >>
>>> >> (4) Sub-classing Function and calling the sub-class interpolate()
>>> >> function does not call eval().
>>> >
>>> > Which interpolate() function? There are 4 different.
>>>
>>> The one used in comment [4].
>>
>> Yes, I see that now. This is expected behavior. The reason is that the
>> call to vector() will create a zero vector if there is no vector. Once
>> the vector has been created, the Function will change from being a
>> user-defined function to a discrete function which means that eval()
>> will not be called.
>>
>> I don't know what the best solution is. We could either add a new
>> function just called interpolate() without arguments that interpolates
>> the function to its function space.
>
> I think this is a good idea, as calling
>
> v.interpolate(v.vector(), v.function_space());
>
> is somehow pointless.
>
>
> -Ali
>
>> Or one can work around it by
>>
>>  Vector x;
>>  v.interpolate(x, v.function_space());
>>  v.vector() = x;

This is what interpolate.py does. Like I explained in (1), this is
buggy when Function is created in c++ and then wrapped in python.
Also, the above answered question (2).


-Ali

>>
>> --
>> Anders
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (GNU/Linux)
>>
>> iEYEARECAAYFAkma5H0ACgkQTuwUCDsYZdFvpwCdFb7i80BdC7XDqxwbtlr28FV0
>> g30AnjcDnux+6kRuTBSKdnhtKAnV7zuz
>> =ri5f
>> -----END PGP SIGNATURE-----
>>
>> _______________________________________________
>> DOLFIN-dev mailing list
>> DOLFIN-dev@xxxxxxxxxx
>> http://www.fenics.org/mailman/listinfo/dolfin-dev
>>
>>
>


Follow ups

References