Expression doesn't work properly within assembly

Bug #995452 reported by Simone Pezzuto
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DOLFIN
Confirmed
Medium
Johan Hake

Bug Description

 Small testcase:

from dolfin import *
mesh = UnitSquare(16, 16)

x = Expression(("x[0]", "x[1]"))
n = FacetNormal(mesh)

area = assemble( Constant(0.5)*dot(x,n)*ds )

Result:
[...]
ufl.log.UFLException: Missing index or invalid dimension in provided idims.

Expected result: area = 1.0

This is a regression, because on FEniCS 1.0 works well.

Related branches

Revision history for this message
Martin Sandve Alnæs (martinal) wrote :

I can't reproduce this. Which versions are you using? I suggest you update and try again.

I had to pass the mesh to assemble, but otherwise your code works fine here:

from dolfin import *
mesh = UnitSquare(16, 16)

x = Expression(("x[0]", "x[1]"))
n = FacetNormal(mesh)

a = Constant(0.5)*dot(x,n)*ds
area = assemble(a, mesh=mesh)
print area # shows 1.0

Revision history for this message
Simone Pezzuto (junki-gnu) wrote :

Actually I discovered that I get the expected result on a cluster Johan set up few month ago (January),
while on my laptop both FEniCS 1.0 and last revision of UFL (revno: 1404) I get an exception (of different kind).

To be more specific, with 1.0 there's a "non-integer index" exception.

I'll try again with the last revision of the whole framework.

Btw, is it related to UFL? It seems the most active branch at the moment.

Thanks!
 Simone

Revision history for this message
Martin Sandve Alnæs (martinal) wrote :

It seems to be related to UFL. Note that you probably can't use UFL from trunk with 1.0 versions of ffc and maybe dolfin.

Revision history for this message
Simone Pezzuto (junki-gnu) wrote :

I tried again, with an empty tree I reinstalled everything (trunk version).

Still the same error, seems to be raised by ufl/indexing.py:148.

I also found another weird behavior:

mesh = UnitSquare(16, 16)
V = VectorFunctionSpace(mesh, "CG", 1)

ufl/constantvalue.py:76 raises an "Expecting tuple of int", while

V = VectorFunctionSpace(mesh, "CG", 1, 2)

works well.

Is it possible that we're working on different branches of UFL?

Revision history for this message
Martin Sandve Alnæs (martinal) wrote :

I am pretty sure an error in the construction of a Vector Function Space would make the buildbot complain a lot. Anyone else getting this?

Sure you have installed trunk versions of all fenics projects? UFL, FFC and DOLFIN at least?

Revision history for this message
Johan Hake (johan-hake) wrote : Re: [Bug 995452] Re: Expression doesn't work properly within assembly

It works here.

bzr versions:
UFL: 1404
FFC: 1751
DOLFIN: 6702

Sure your paths are set correctly and that you do not load an old
version of some of the packages?

Johan

On 05/08/2012 09:15 AM, Martin Sandve Alnæs wrote:
> I am pretty sure an error in the construction of a Vector Function Space
> would make the buildbot complain a lot. Anyone else getting this?
>
> Sure you have installed trunk versions of all fenics projects? UFL, FFC
> and DOLFIN at least?
>

Revision history for this message
Johannes Ring (johannr) wrote :

The code in comment #1 fails on my laptop with the same error as initially reported, but I have tested it on all the buildbots and it works fine on them.

Revision history for this message
Martin Sandve Alnæs (martinal) wrote :

My guess now is that you need to update FFC to latest trunk, at least revision 1749. That revision has a bugfix I commited simultaneously with adding some stricter assertions in UFL, which I think is the ones you see.

If that doesn't help, please post the full stacktrace of the error. (That is always a good idea to do in bug reports).

Revision history for this message
Johannes Ring (johannr) wrote :
Download full text (4.3 KiB)

I have the same versions as Johan on my laptop.

$ python /tmp/test.py
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
Missing index or invalid dimension in provided idims.
Traceback (most recent call last):
  File "/tmp/test.py", line 8, in <module>
    area = assemble(a, mesh=mesh)
  File "/home/johannr/dev/fenics/src/dolfin/trunk/local/lib/python2.7/site-packages/dolfin/fem/assembling.py", line 158, in assemble
    common_cell=common_cell)
  File "/home/johannr/dev/fenics/src/dolfin/trunk/local/lib/python2.7/site-packages/dolfin/fem/form.py", line 56, in __init__
    common_cell)
  File "/home/johannr/dev/fenics/src/dolfin/trunk/local/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 66, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/home/johannr/dev/fenics/src/dolfin/trunk/local/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 154, in jit
    return jit_compile(form, parameters=p, common_cell=common_cell)
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ffc/jitcompiler.py", line 73, in jit
    return jit_form(ufl_object, parameters, common_cell)
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ffc/jitcompiler.py", line 90, in jit_form
    form_data = form.compute_form_data(common_cell=common_cell)
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/form.py", line 132, in compute_form_data
    element_mapping=element_mapping)
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/preprocess.py", line 81, in preprocess
    form = expand_derivatives(form, common_cell.geometric_dimension()) # FIXME: Split out expand_compounds from expand_derivatives
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/ad.py", line 118, in expand_derivatives1
    return transform_integrands(form, _expand_derivatives)
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/transformer.py", line 250, in transform_integrands
    integrand = transform(itg.integrand())
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/ad.py", line 97, in _expand_derivatives
    expression = expand_compounds(expression, dim)
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/expand_compounds.py", line 315, in expand_compounds1
    return apply_transformer(e, CompoundExpander(dim))
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/transformer.py", line 275, in apply_transformer
    return transform_integrands(e, _transform)
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/transformer.py", line 266, in transform_integrands
    return transform(expr)
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/transformer.py", line 274, in _transform
    return transformer.visit(expr)
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/transformer.py", line 101, in visit
    r = h(o, *map(self.visit, o.operands()))
  File "/home/johannr/dev/fenics/trunk/lib/python2.7/site-packages/ufl/algorithms/transformer.py", li...

Read more...

Revision history for this message
Johan Hake (johan-hake) wrote :

What version of SWIG are you running Simone? My guess is 2.0.5 or more.
It seems to be a type conversion regression introduced by the latest
SWIG. If you try running the python unit test suite:

   make run_quicktest

with the latest SWIG you will probably also get a lot of errors. I have
tried to overlook this regression for a while now, but it seems I have
to see if the error is ours or SWIGs... Not a fun task.

If it is possible I suggest you downgrade your SWIG to 2.0.4 as a quick fix.

Johan

Changed in dolfin:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Johan Hake (johan-hake)
Revision history for this message
Simone Pezzuto (junki-gnu) wrote :

I confirm that Swig is the problem: version 2.0.5 (and 2.0.6) have this problem, while swig 2.0.4 does not.

Thanks for figuring out this! At least this helped finding a regression with swig!

Best!
 Simone

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.