coneoproject / COFFEE

COFFEE - A COmpiler For Fast Expression Evaluation
Other
9 stars 6 forks source link

Expansion error: no symbol: FE1_C0_D1 #18

Closed ctjacobs closed 9 years ago

ctjacobs commented 9 years ago

This code:

from firedrake import *

mesh = UnitIntervalMesh(5)

# Define the mixed function space
U = VectorFunctionSpace(mesh, "CG", 2)
H = FunctionSpace(mesh, "CG", 1)
W = MixedFunctionSpace([U, H])

# The solution field defined on the mixed function space
solution = Function(W)
u, h = split(solution)
w, v = TestFunctions(W)

# Define the compulsory shallow water fields
solution_old = Function(W)
solution_old.interpolate(Expression(("0.1*sin(pi*x[0])", "cos(pi*x[0])")))
u_old, h_old = split(solution_old)

# The solution should first hold the initial condition.
solution.assign(solution_old)

# The form, F
F = 0

A_momentum = inner(dot(grad(u), u), w)*dx
F += A_momentum

viscosity = Constant(0.7)
K_momentum = -viscosity*inner(grad(u) + grad(u).T, grad(w))*dx + viscosity*(2.0/3.0)*inner(div(u)*Identity(1), grad(w))*dx
F -= K_momentum

# Construct the solver objects
problem = NonlinearVariationalProblem(F, solution, bcs=[])
solver = NonlinearVariationalSolver(problem)

solver.solve()

fails with:

Compiling form form00

Compiler stage 1: Analyzing form(s)
-----------------------------------

  Geometric dimension:       1
  Number of cell subdomains: 0
  Rank:                      2
  Arguments:                 '(v_0, v_1)'
  Number of coefficients:    3
  Coefficients:              '[Coordinates, function_7, w_4]'
  Unique elements:           'Vector<1 x CG2(?)>, Vector<1 x CG1(?)>, Mixed<Vector<1
                              x CG2(?)>, CG1(?)>, R0(?)'
  Unique sub elements:       'Vector<1 x CG2(?)>, Vector<1 x CG1(?)>, Mixed<Vector<1
                              x CG2(?)>, CG1(?)>, R0(?), CG2(?), CG1(?), CG1(?)'

  representation:    quadrature
  quadrature_degree: auto --> 5
  quadrature_rule:   auto --> default

Compiler stage 1 finished in 0.0159612 seconds.

Compiler stage 2: Computing intermediate representation
-------------------------------------------------------
  Computing representation of integrals
  Computing quadrature representation
  Transforming cell integral

Compiler stage 2 finished in 0.0123069 seconds.

Compiler stage 3: Optimizing intermediate representation
--------------------------------------------------------
  Skipping optimizations, add -O to optimize

Compiler stage 3 finished in 0.000216007 seconds.

Compiler stage 4 finished in 0.00485611 seconds.

FFC finished in 0.034586 seconds.
Traceback (most recent call last):
  File "test3.py", line 35, in <module>
    solver = NonlinearVariationalSolver(problem)
  File "/data/firedrake/firedrake/variational_solver.py", line 97, in __init__
    form_compiler_parameters=self._problem.form_compiler_parameters)
  File "/data/firedrake/firedrake/assemble.py", line 58, in assemble
    form_compiler_parameters=form_compiler_parameters)
  File "/data/firedrake/firedrake/assemble.py", line 79, in _assemble
    kernels = ffc_interface.compile_form(f, "form", parameters=form_compiler_parameters)
  File "/data/firedrake/firedrake/ffc_interface.py", line 268, in compile_form
    ffc_kernel = FFCKernel(f, name + str(i) + str(j), parameters)
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/caching.py", line 202, in __new__
    obj = make_obj()
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/caching.py", line 192, in make_obj
    obj.__init__(*args, **kwargs)
  File "/data/firedrake/firedrake/ffc_interface.py", line 194, in __init__
    (name, it.integral_type(), it.subdomain_id()), opts, inc),
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/backends.py", line 118, in __call__
    return t(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/caching.py", line 202, in __new__
    obj = make_obj()
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/caching.py", line 192, in make_obj
    obj.__init__(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/base.py", line 3632, in __init__
    self._code = self._ast_to_c(code, opts)
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/host.py", line 63, in _ast_to_c
    ast_handler.plan_cpu(opts)
  File "build/bdist.linux-x86_64/egg/coffee/plan.py", line 405, in plan_cpu
  File "build/bdist.linux-x86_64/egg/coffee/plan.py", line 241, in _generate_cpu_code
  File "build/bdist.linux-x86_64/egg/coffee/optimizer.py", line 110, in rewrite
  File "build/bdist.linux-x86_64/egg/coffee/rewriter.py", line 171, in expand
  File "build/bdist.linux-x86_64/egg/coffee/rewriter.py", line 572, in expand
  File "build/bdist.linux-x86_64/egg/coffee/rewriter.py", line 574, in expand
  File "build/bdist.linux-x86_64/egg/coffee/rewriter.py", line 572, in expand
  File "build/bdist.linux-x86_64/egg/coffee/rewriter.py", line 607, in expand
  File "build/bdist.linux-x86_64/egg/coffee/rewriter.py", line 607, in expand
  File "build/bdist.linux-x86_64/egg/coffee/rewriter.py", line 572, in expand
  File "build/bdist.linux-x86_64/egg/coffee/rewriter.py", line 575, in expand
  File "build/bdist.linux-x86_64/egg/coffee/rewriter.py", line 592, in expand
RuntimeError: Expansion error: no symbol: FE1_C0_D1

Remove, for example, A_momentum or viscosity* in viscosity*(2.0/3.0) and the error goes away. No idea why though.

FabioLuporini commented 9 years ago

This should be fixed in branch fix-issues-8-18-19. Please, @ctjacobs, have a look when you've some time. I've rushed for a solution since I'm leaving tomorrow for Amsterdam, and won't be able to look at this till the next (next) week . Hope this fixes the issue.

ctjacobs commented 9 years ago

That fixes the issue. Thanks Fabio.

FabioLuporini commented 9 years ago

Closing since fixed by PR #21