dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #16665
Re: Value shape for subclasses of Expression
On Thu, Nov 26, 2009 at 02:20:56PM +0100, Anders Logg wrote:
> We are currently able to automatically detect the value shape of an
> Expression defined like this:
>
> f = Expression(("x[0]", "sin(x[1])"))
>
> But not if it is defined like this:
>
> class MyExpression(Expression):
> def eval(self, values, x):
> values[0] = x[0]
> values[1] = sin(x[1])
>
> How should the value shape be specified for a subclass of an
> expression?
>
> We had value_rank, value_dim before. We might either require
>
> def value_shape(self):
> return (2,)
>
> or sending value shape to the constructor:
>
> f = MyExpression(shape=(2,))
>
> Or there might be some other trick we can do.
I have added a dim() function to the interface of subclassed
Expressions.
This can return either an integer or a tuple:
1 <--> scalar
2 <--> vector of dimension 2
3 <--> vector of dimension 3
(1,) <--> scalar
(2,) <--> vector of dimension 2
(2, 2) <--> matrix of dimension 2 x 2
It should work now but the elasticity demo is failing because FFC is
not correctly adjusting the cells for mixed elements (I think).
--
Anders
Attachment:
signature.asc
Description: Digital signature
Follow ups
References