Subject: [UFL-dev] UFL expand indices bug?

From: Kristian Oelgaard <[email-masked]>
Date: Fri, 06 Mar 2009 11:14:55 +0100

Hi,

The following gives me an error (it used to work):

element = FiniteElement("Lagrange", triangle, 2)
v = TestFunction(element)
u = TrialFunction(element)

a = div(grad(v))*u*dx

print tree_format(a)  OK

a = expand_derivatives(a)
print tree_format(a)  OK

a = expand_indices(a)
print tree_format(a)  ERROR:

    a = expand_indices(a)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 827,
in expand_indices
    return apply_transformer(e, IndexExpander())
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 786,
in apply_transformer
    return transform_integrands(e, _transform)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 774,
in transform_integrands
    for itg in form.integrals()]
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 785,
in _transform
    return transformer.visit(expr)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 112,
in visit
    return h(o, *map(self.visit, o.operands()))
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 116,
in visit
    return h(o)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 694,
in index_sum
    ops.append(self.visit(summand))
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 116,
in visit
    return h(o)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 718,
in indexed
    result = self.visit(A)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 116,
in visit
    return h(o)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 741,
in component_tensor
    result = self.visit(expression)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 116,
in visit
    return h(o)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 763,
in spatial_derivative
    f = self.visit(f) # taking component if necessary
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 116,
in visit
    return h(o)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 764,
in spatial_derivative
    j = self.visit(i) # mapping to constant if necessary
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 116,
in visit
    return h(o)
  File "/home/oelgaard/fenics/ufl/ufl/algorithms/transformations.py", line 708,
in multi_index
    return x._uflclass(self._multi_index(x))
  File "/home/oelgaard/fenics/ufl/ufl/indexing.py", line 89, in __init__
    ii = tuple(as_index(j) for j in ii)
  File "/home/oelgaard/fenics/ufl/ufl/indexing.py", line 89, in <genexpr>
    ii = tuple(as_index(j) for j in ii)
  File "/home/oelgaard/fenics/ufl/ufl/indexing.py", line 146, in as_index
    error("Invalid object %s to create index from." % repr(i))
  File "/home/oelgaard/fenics/ufl/ufl/log.py", line 64, in error
    raise UFLException(self._format_raw(*message))
ufl.log.UFLException: Invalid object None to create index from.

I couldn't find an appropriate place to add a unit test.

Kristian

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Fri, 6 Mar 2009 11:29:22 +0100

I'm on it.

Tests are under test/, feel free to modify the files there or create
new testcase files and send them to me/ufl-dev. During debugging
I usually make stand-alone scripts though, I'm just getting confused
by the magic features of the unittest module :)

Martin

On Fri, Mar 6, 2009 at 11:14 AM, Kristian Oelgaard
<[email-masked]> wrote:
> _______________________________________________
> UFL-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufl-dev
>