On Fri, Sep 03, 2010 at 04:36:40PM -0700, Johan Hake wrote:
Hello!
Garth found an ambiguity in the Expression doc string regarding how a user
should initiate a user defined Expression (not a compiled one) in Python. If
the Expression is vector or tensor valued the user need to provide information
about this.
This can be done in two ways. Either overload the dim method or provide a ufl
FiniteElement while instantiating the Expression. Neither of these methods are
documented in the docstring.
In the mixed poisson demo both dim and rank are overloaded. I think rank is
not needed (works fine without). However dim is just a method introduced to be
able to automatically select a FiniteElement.
First I am not sure dim is the correct name. We could use value_size as this
is present in the GenericFunction interface for just this purpose. Second I am
not sure overloading a method is the best and most clear way to provide this
information. Maybee he could do it while instantiating the Expression instead?
class BoundarySource(Expression):
def eval_data(self, values, data):
g = sin(5*data.x()[0])
values[0] = g*data.normal()[0]
values[1] = g*data.normal()[1]
s = BoundarySource(value_size=2)
Or just use the FiniteElement which is a litle bit over kill but already
possible as it is.
s = BoundarySource(element=BDM.ufl_element())
What you say?
I'm not sure what the names should be, other than that it would be
good to change as little as possible since we are getting closer to
1.0 and there have been numerous iterations back and forth on the
expression/function interface.
Either way, it shouldn't be an argument to the constructor (from the
user side). It should be part of the class. Otherwise, it looks like
one can instantiate a BoundarySource thing for other value sizes when
the value size is fixed.