← Back to team overview

ufl team mailing list archive

Bug in purge_list_tensors?

 

I get an error when trying purge_list_tensors.

Here's a simple example:

  element = VectorElement("Lagrange", "triangle", 1)

  v = TestFunction(element)
  u = TrialFunction(element)

  a = inner(as_tensor([v[0], v[1]]), as_tensor([u[0], u[1]]))

This seems to work if I first call expand_compounds, but not without.
Is expand_compounds a requirement before calling purge_list_tensors?

Another example that fails is

  b = inner(as_tensor([v[0], v[1]]), as_tensor([u[0], u[1].dx(0)]))

If I call this without first calling expand_derivatives, I get

  File "/usr/lib/python2.5/site-packages/ufl/algorithms/transformations.py",
  line 727, in list_tensor
     c0, c1 = c[0], c[1:]
  IndexError: tuple index out of range

If I first call expand_derivatives, I get

 File
 "/usr/lib/python2.5/site-packages/ufl/algorithms/transformations.py",
 line 133, in reuse_if_possible
    r = o.reconstruct(*operands)
  File "/usr/lib/python2.5/site-packages/ufl/expr.py", line 159, in
  reconstruct
    return self._uflclass(*operands)
  File "/usr/lib/python2.5/site-packages/ufl/algebra.py", line 139, in
  __new__
    or error("Product can only represent products of scalars.")
  File "/usr/lib/python2.5/site-packages/ufl/log.py", line 64, in
  error
    raise UFLException(self._format_raw(*message))
 ufl.log.UFLException: Product can only represent products of scalars.

I've attached a small test script.

-- 
Anders
from ufl import *
from ufl.algorithms import purge_list_tensors, expand_compounds, expand_derivatives

element = VectorElement("Lagrange", "triangle", 1)

v = TestFunction(element)
u = TrialFunction(element)

a = inner(as_tensor([v[0], v[1]]), as_tensor([u[0], u[1]]))
b = inner(as_tensor([v[0], v[1]]), as_tensor([u[0], u[1].dx(0)]))

# Fails without expand_compounds
#a = expand_compounds(a)
#a = purge_list_tensors(a)

# Fails with and without expand_derivatives but in different ways
b = expand_derivatives(b)
b = purge_list_tensors(b)

Attachment: signature.asc
Description: Digital signature


Follow ups