On Thu, Mar 12, 2009 at 10:41:28AM +0100, Johan Hake wrote: > On Thursday 12 March 2009 10:32:10 Anders Logg wrote: > > On Thu, Mar 12, 2009 at 10:25:36AM +0100, Martin Sandve Alnæs wrote: > > > I have serious problems with the idea of letting user-defined > > > functions change nature to discrete functions as a side effect > > > of other operations, effectively hiding the user-defined implementation > > > of eval. > > > > > > (I know this concept wasn't introduced in this discussion, but it's > > > related). > > > > You mean by calling u.vector()? Yes, I agree it's problematic. > > > > But I don't know how to handle it otherwise. Consider the following > > example: > > > > u = Function(V) > > FYI: > u is a discrete function here. This is a difference between the python and > c++ > interface. Please shout if this is not what we want. The c++ base class of u > is the cpp.DiscreteFunction defined SpecialFunctions.h. > > I did this mostly for avoiding the director wrapper attached to all python > functions that inherits the cpp.Function, and with the assumption that when a > Function is instantiated as: > > u = Function(V) > > you also want a discrete function. The only thing the DiscreteFunction does > is > instantiating the vector and defining some constructors that is used else > where in the python interface. > > Johan
This looks good to me. I didn't know. Too bad we can't do the same thing in C++. It's a bit odd now. A Function is by default discrete in Python, but not in C++ where it is by default user-defined. Should we add a flag to the constructor(s) of Function so everything is by default discrete? Function(const FunctionSpace& V, user_defined=false); or Function(const FunctionSpace& V, has_eval=true); If a Function is user-defined, the call to vector() would give an error and suggest that the Function be interpolated first: u.interpolate(); u.vector(); This would require adding a flag to all user-defined functions in C++. It would also silently break all user code and make functions without the flag correctly set just return zero (from the initialized zero vector). But it might be worth it. -- Anders
signature.asc
Description: Digital signature
_______________________________________________ DOLFIN-dev mailing list [email protected] http://www.fenics.org/mailman/listinfo/dolfin-dev
