On Thursday 02 July 2009 23:22:35 Garth N. Wells wrote: > Anders Logg wrote: > > On Thu, Jul 02, 2009 at 01:42:41PM +0200, Johan Hake wrote: > >> On Thursday 02 July 2009 13:24:28 Garth N. Wells wrote: > >>> Johan Hake wrote: > >>>> On Thursday 02 July 2009 13:07:47 Garth N. Wells wrote: > >>>>> Marie Rognes wrote: > >>>>>> Garth N. Wells wrote: > >>>>>>> Marie Rognes wrote: > >>>>>>>> The following code gives r = 0.0. It is not supposed to be. > >>>>>>>> > >>>>>>>> The problem seems to be that f's vector is still all zeros at the > >>>>>>>> call to interpolate. Could this be easily fixed? > >>>>>>> > >>>>>>> This example should have led to an error message since f is not a > >>>>>>> discrete function. I'll take a look. > >>>>>> > >>>>>> Ok, thanks! > >>>>>> > >>>>>> However, > >>>>>> > >>>>>> (a) Why is f not a discrete function? (It is defined on a finite > >>>>>> element space?) > >>>>> > >>>>> On second thought, it may be a discrete function. I think that this > >>>>> is defined in the Python interface and not the C++ interface, so I'll > >>>>> take a look. > >>>> > >>>> A user defined function is not a discrete function untill you either > >>>> call interpolate() or vector, also in python. The problem with the > >>>> later is that you then create a vector which is initialized to 0. > >>>> > >>>> I think this has been discussed before, but should we populate the > >>>> vector using f.interpolate() when vector is called on a userdefined > >>>> function? > >>> > >>> Or perhaps Function::vector() should throw an error if the vector has > >>> not already been allocated. > >> > >> I vote for this. > >> > >> The error message can include information about the user might want to > >> call interpolate? > >> > >> Johan > > > > Sounds good. > > Unfortunately this won't work because we often do > > Function u(V); > solve(A, u.vector(), b);
I see. It would have worked in python though, as u would have been a discrete Function when created. However this is now implemented as a call to vector() in the constructor of DiscreteFunction, so that would also need some attention. Johan > Garth > > > Just to check: this only occurs (in Python) when a user defines a > > Function using a C++ expression or overloads eval(), right? > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > DOLFIN-dev mailing list > > DOLFIN-dev@fenics.org > > http://www.fenics.org/mailman/listinfo/dolfin-dev > > _______________________________________________ > DOLFIN-dev mailing list > DOLFIN-dev@fenics.org > http://www.fenics.org/mailman/listinfo/dolfin-dev _______________________________________________ DOLFIN-dev mailing list DOLFIN-dev@fenics.org http://www.fenics.org/mailman/listinfo/dolfin-dev