Subject: [UFL-dev] Bug in purge_list_tensors?

From: Anders Logg <[email-masked]>
Date: Wed, 4 Mar 2009 14:12:55 +0100

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: Martin Sandve Alnæs <[email-masked]>
Date: Wed, 4 Mar 2009 14:27:09 +0100

> Is expand_compounds a requirement before calling purge_list_tensors?

Yes. Actually, I assumed expand_derivatives had been applied.

> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkmuflcACgkQTuwUCDsYZdFd4gCfbo499KfWxiCk9Ga6BmosqO1z
> AIgAoI5bvZwAKbgcCnjUHtgTqsAzMq1q
> =8ZIm
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> UFL-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufl-dev
>
>

---

From: Anders Logg <[email-masked]>
Date: Wed, 4 Mar 2009 14:36:20 +0100

> Yes. Actually, I assumed expand_derivatives had been applied.

ok. What about the second example, should that work?

-- 
Anders

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Wed, 4 Mar 2009 15:20:57 +0100

Yes. Now it does.

Martin

On Wed, Mar 4, 2009 at 2:36 PM, Anders Logg <[email-masked]> wrote:
> iEYEARECAAYFAkmug9MACgkQTuwUCDsYZdGqhwCePAZefk8o9kR01fFlGNlXscnW
> wTkAnj16YbCStRHfDqhXxk1VcJ146eEW
> =8iKN

---

From: Anders Logg <[email-masked]>
Date: Wed, 4 Mar 2009 16:26:47 +0100

Thanks!

-- 
Anders