Form fails to compile after bzr pull on trunk

Asked by Charles on 2013-02-14

I pulled an update today and I am no longer able to compile my forms. A simple example that was working before the update:

element = FiniteElement("Lagrange", interval, 4)

#Q : Value
q = Coefficient(element)

u = TrialFunction(element)
w = TestFunction(element)

# X-dimension
x = interval.x

a = u*w*x*x*dx
L = grad(q)*w*x*x*dx

The output:

Product can only represent products of scalars.
Traceback (most recent call last):
  File "/usr/local/bin/ffc", line 195, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/local/bin/ffc", line 159, in main
    ufd = load_ufl_file(filename)
  File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/formfiles.py", line 195, in load_ufl_file
    namespace = execute_ufl_code(uflcode, filename)
  File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/formfiles.py", line 99, in execute_ufl_code
    m = __import__(basename)
  File "/media/sf_E_DRIVE/Users/Charles/Dropbox/School/Ufl-PhD/Research/compressible/trunk/include/forms/CalculateGradient2_debug.py", line 17, in <module>
    a = u*w*x*x*dx
  File "/usr/local/lib/python2.7/dist-packages/ufl/exproperators.py", line 181, in _mul
    return _mult(self, o)
  File "/usr/local/lib/python2.7/dist-packages/ufl/exproperators.py", line 154, in _mult
    p = Product(a, b[ii])
  File "/usr/local/lib/python2.7/dist-packages/ufl/algebra.py", line 174, in __new__
    error("Product can only represent products of scalars.")
  File "/usr/local/lib/python2.7/dist-packages/ufl/log.py", line 154, in error
    raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Product can only represent products of scalars.

If I remove the coordinate terms:

element = FiniteElement("Lagrange", interval, 4)

#Q : Value
q = Coefficient(element)

u = TrialFunction(element)
w = TestFunction(element)

# X-dimension
x = interval.x

a = u*w*dx
L = grad(q)*w*dx

I get:

Trying to integrate expression of rank 1 with free indices ().
Traceback (most recent call last):
  File "/usr/local/bin/ffc", line 195, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/local/bin/ffc", line 159, in main
    ufd = load_ufl_file(filename)
  File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/formfiles.py", line 195, in load_ufl_file
    namespace = execute_ufl_code(uflcode, filename)
  File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/formfiles.py", line 99, in execute_ufl_code
    m = __import__(basename)
  File "/media/sf_E_DRIVE/Users/Charles/Dropbox/School/Ufl-PhD/Research/compressible/trunk/include/forms/CalculateGradient2_debug.py", line 18, in <module>
    L = grad(q)*w*dx
  File "/usr/local/lib/python2.7/dist-packages/ufl/integral.py", line 269, in __rmul__
    % (integrand.rank(), integrand.free_indices()))
  File "/usr/local/lib/python2.7/dist-packages/ufl/log.py", line 154, in error
    raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Trying to integrate expression of rank 1 with free indices ().

How should I massage the form(s)?

Thank you

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Charles
Solved:
2013-02-14
Last query:
2013-02-14
Last reply:
Charles (rodbourn) said : #1

Adding indices to terms does not appear to work either.

Invalid number of indices (1) for tensor expression of rank 0:
 Argument(FiniteElement('Lagrange', Domain(Cell('interval', 1), 'interval_multiverse', 1, 1), 4, None), -1)

Charles (rodbourn) said : #2

And a bit of guessing/checking with hints from errors I found a working solution.

vector = VectorElement("Lagrange", interval, 4)
scalar = FiniteElement("Lagrange", interval, 4)

q = Coefficient(scalar)

u = TrialFunction(vector)
w = TestFunction(vector)

a = inner(u,w)*inner(x,x)*dx
L = inner(grad(q),w)*inner(x,x)*dx

Pretty slick that its now checking ranks :)

I changed 1D vector quantities to have vector shape (1,) instead of being
scalar. This allows more forms to be written dimension independently. This
affects at least grad, vector elements, interval.x, interval.n. You can use
x = interval.x[0] and f.dx(0) to work with scalar quantities.

Martin
Den 14. feb. 2013 23:11 skrev "Charles" <
<email address hidden>> følgende:

> Question #221907 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/221907
>
> Status: Open => Solved
>
> Charles confirmed that the question is solved:
> And a bit of guessing/checking with hints from errors I found a working
> solution.
>
>
>
> vector = VectorElement("Lagrange", interval, 4)
> scalar = FiniteElement("Lagrange", interval, 4)
>
> q = Coefficient(scalar)
>
>
> u = TrialFunction(vector)
> w = TestFunction(vector)
>
>
> a = inner(u,w)*inner(x,x)*dx
> L = inner(grad(q),w)*inner(x,x)*dx
>
>
> Pretty slick that its now checking ranks :)
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>

Charles (rodbourn) said : #4

Martin,

This is actually something that I needed to do in a few months (support 2,3D), so this is just helping me support that earlier.

Thank you

Charles