← Back to team overview

ufl team mailing list archive

Re: ListTensor

 

Quoting Anders Logg <logg@xxxxxxxxx>:

> On Tue, Mar 03, 2009 at 09:10:50PM +0100, Martin Sandve Alnæs wrote:
> > On Tue, Mar 3, 2009 at 12:18 AM, Anders Logg <logg@xxxxxxxxx> wrote:
> > > Is there a way to transform an expression to remove ListTensor from
> > > the tree? I'm struggling with the monomial transformation.
> > >
> > > Take for example the following expression:
> > >
> > >  inner(as_tensor([v[0], v[1]]), as_tensor([u[0], u[0].dx(1)]))
> > >
> > > This might be rewritten as
> > >
> > >  a = v[0]*u[0] + v[1]*u[0].dx(1)
> > >
> > > This I can handle, but not the version containing ListTensor.
> > 
> > You have something similar in FFC, right?
> > vec and mat or something?
> > How do you handle those?
> > 
> > Martin
> 
> The corresponding thing in FFC is regular Python lists. For example,
> here's the grad() operator:
> 
> def grad(v):
>     "Return gradient of given function."
>     # Get shape dimension
>     d = __cell_dimension(v)
>     # Check if we have a vector
>     if value_rank(v) == 1:
>         return [[D(v[i], j) for j in range(d)] for i in range(len(v))]
>     # Otherwise assume we have a scalar
>     return [D(v, i) for i in range(d)]
> 
> At some later point, the list will appear as an argument of a dot
> product or it might be indexed (with a fixed index). The result of
> both operations will remove the list and return a scalar expression.
> 
> So when a form has been defined correctly, the resulting expression is
> always a scalar which does not contain any lists. What makes this
> simpler in FFC might be that only fixed indices (ints) are allowed as
> indices in a list, whereas UFL allows general indices to be used.
> 
> In particular, the following is not allowed in FFC:
> 
>   a = grad(v)[i]*grad(u)[i]*dx
> 
> One must write one of the following:
> 
>   a = dot(grad(v), grad(u))*dx
>   a = v.dx(i)*u.dx(i)*dx
> 
> The important point here is that dot() will pick out the elements in
> the list one by one and return something that is not a list.
> 
> I don't know if it would be a too severe restriction to disallow
> general indices in a ListTensor.

If I understood it correctly, it should be
'general indices OF a ListTensor' ??

Kristian

> -- 
> Anders
> 




Follow ups

References