Martin Sandve Alnæs wrote: > On Sat, Feb 14, 2009 at 6:08 PM, Johan Hake <[email protected]> wrote: >> On Saturday 14 February 2009 17:45:44 Martin Sandve Alnæs wrote: >>> On Sat, Feb 14, 2009 at 5:34 PM, Johan Hake <[email protected]> wrote: >>>> On Saturday 14 February 2009 17:28:18 Garth N. Wells wrote: >>>>> Johan Hake wrote: >>>>>> On Saturday 14 February 2009 13:48:05 A Navaei wrote: >>>>>>> It seems that the error can be re-produced even without sub-classing >>>>>>> and using existing dolfin classes in pure c++. Based on the >>>>>>> itk-dolfin interface code, the below minimal code should generate the >>>>>>> error (note that I use the binary distribution which uses std::tr1, >>>>>>> replacing it with boost shared pointer should not have any effect). >>>>>> Not in c++ but swig only support std::tr1::shared_ptr from version >>>>>> 1.3.37. But if you intend to use shared_ptr only internally there >>>>>> whould not be any problems. >>>>>> >>>>>>> After wrapping in python: >>>>>>> >>>>>>> (1) Calling FunctionTest.CreateFunction(), which returns by value, >>>>>>> results this error: >>>>>>> >>>>>>> RuntimeError: *** Error: Unable to assign to function, missing >>>>>>> coefficients (user-defined function). >>>>>> You cannot assign another user-defined function to another Function. >>>>>> It must be a discrete function, which has an initialized _vector. This >>>>>> is probably a feature that other developers should answer for. >>>>>> >>>>>> However this means that you cannot copy a userdefined function, with >>>>>> the side effect of not beeing able to return a user-defined Function >>>>>> by value. >>>>>> >>>>>>> Since dolfin::Function does come with the required copy ctors, the >>>>>>> problem cannot be stemmed from this. >>>>>> This use the assignment operator which requires the Function to be a >>>>>> discrete and not a user-defined Function. >>>>>> >>>>>> I consider this to be a bug in the library. Any other comments from >>>>>> the C++ DOLFIN developers (I am mostly dealing with the python >>>>>> interface)? >>>>> In a nutshell, are you suggesting that the Function copy constructor >>>>> should work for user-defined Functions? >>>> Yes. Why shouldn't it? >>>> >>>> I can see why the assigment operator should not work. >>> If I understand this right, what you propose is probably not >>> technically possible in C++ with the current design. The old design >>> which used the envelope-letter could have dealt with this. >> Why's that? >> >> The only data that needs to be copied are the FunctionSpace, when _vector is >> null, and this is shared? Am I missing somthing wrt to the copting of any >> derived class of Function? >> >> Johan > > I haven't followed this in detail, so I may misunderstand, but if you > have a subclass MyFunction of Function, copying it to a Function can't > possibly work. How could it?
It doesn't work, but it is now possible to copy a MyFunction to a MyFunction, which wasn't possible before. Garth However, Function can make a discrete > function from MyFunction, then it's ok. > > Martin _______________________________________________ DOLFIN-dev mailing list [email protected] http://www.fenics.org/mailman/listinfo/dolfin-dev
