UFL

Triggered assertion 'no weights' on a valid functional

Bug #888720 reported by Martin Sandve Alnæs
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
UFL
Fix Released
High
Martin Sandve Alnæs

Bug Description

from dolfin import *
mesh = UnitSquare(10,10)
assemble(1.0/(y+1)*dx, mesh=mesh) # works
assemble((y+1)**-1*dx, mesh=mesh) # triggers assertion

Traceback:

---------------------------------------------------------------------------
Exception Traceback (most recent call last)

/home/martinal/dev/fenics/ffc/work/test/<ipython console> in <module>()

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/dolfin/fem/assembling.pyc in assemble(form, tensor, mesh, coefficients, function_spaces, cell_domains, exterior_facet_domains, interior_facet_domains, reset_sparsity, add_values, finalize_tensor, backend, form_compiler_parameters)
    156 coefficients=coefficients,
    157 form_compiler_parameters=form_compiler_parameters,
--> 158 common_cell=common_cell)
    159
    160 # Set mesh if specified (important for functionals without a function spaces)

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/dolfin/fem/form.pyc in __init__(self, form, function_spaces, coefficients, subdomains, form_compiler_parameters, common_cell)
     52 = jit(form,
     53 form_compiler_parameters,
---> 54 common_cell)
     55 else:
     56 self._compiled_form = form

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/dolfin/compilemodules/jit.pyc in mpi_jit(*args, **kwargs)
     64 # Just call JIT compiler when running in serial

     65 if MPI.num_processes() == 1:
---> 66 return local_jit(*args, **kwargs)
     67
     68 # Compile first on process 0

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/dolfin/compilemodules/jit.pyc in jit(form, form_compiler_parameters, common_cell)
    148 jit_compile = form_compiler.jit
    149 except AttributeError:
    150 raise RuntimeError, "Form compiler must implement the jit function."
    151
--> 152 return jit_compile(form, parameters=p, common_cell=common_cell)

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/jitcompiler.pyc in jit(ufl_object, parameters, common_cell)
     71 return jit_element(ufl_object, parameters)
     72 else:
---> 73 return jit_form(ufl_object, parameters, common_cell)
     74
     75 def jit_form(form, parameters=None, common_cell=None):

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/jitcompiler.pyc in jit_form(form, parameters, common_cell)
    128 prefix=prefix,
    129 parameters=parameters,
--> 130 common_cell=common_cell)
    131
    132 # Build module using Instant (through UFC)

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/compiler.pyc in compile_form(forms, object_names, prefix, parameters, common_cell)
    163 # Stage 4: code generation

    164 cpu_time = time()
--> 165 code = generate_code(oir, prefix, parameters)
    166 _print_timing(4, time() - cpu_time)
    167

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/codegeneration.pyc in generate_code(ir, prefix, parameters)
     74 # Generate code for integrals

     75 info("Generating code for integrals")
---> 76 code_integrals = [_generate_integral_code(ir, prefix, parameters) for ir in ir_integrals]
     77
     78 # Generate code for forms

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/codegeneration.pyc in _generate_integral_code(ir, prefix, parameters)
    198
    199 # Generate code

--> 200 code = r.generate_integral_code(ir, prefix, parameters)
    201
    202 # Indent code (unused variables should already be removed)

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/quadrature/quadraturegenerator.pyc in generate_integral_code(ir, prefix, parameters)
     51 code["initializer_list"] = ""
     52 code["destructor"] = format["do nothing"]
---> 53 code["tabulate_tensor"] = _tabulate_tensor(ir, parameters)
     54 code["tabulate_tensor_quadrature"] = format["exception"](tabulate_tensor_quadrature_error)
     55 code["additional_includes_set"] = ir["additional_includes_set"]

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/quadrature/quadraturegenerator.pyc in _tabulate_tensor(ir, parameters)
    165 # the unused transformations and tabulate the used psi tables and weights.

    166 common = [remove_unused(jacobi_code, trans_set)]
--> 167 common += _tabulate_weights([quadrature_weights[p] for p in used_weights])
    168 name_map = ir["name_map"]
    169 tables = ir["unique_tables"]

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/quadrature/quadraturegenerator.pyc in _tabulate_weights(quadrature_weights)
    453 # FIXME: For now, raise error if we don't have weights.

    454 # We might want to change this later.

--> 455 ffc_assert(weights.any(), "No weights.")
    456
    457 # Create name and value for weight.

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/log.pyc in ffc_assert(condition, *message)
     44 def ffc_assert(condition, *message):
     45 "Assert that condition is true and otherwise issue an error with given message."
---> 46 condition or error(*message)
     47
     48 # Set default log level

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/log.pyc in <lambda>(*message)

/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ufl/log.pyc in error(self, *message)
    146 "Write error message and raise an exception."
    147 self._log.error(*message)
--> 148 raise self._exception_type(self._format_raw(*message))
    149
    150 def begin(self, *message):

Exception: No weights.

Revision history for this message
Marie Rognes (meg-simula) wrote :

What is y? (I rather get NameError: name 'y' is not defined ;-) )

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

Going through my reported bugs I found this, and it is still there with a slightly different message. Heres a working reproduction:

from dolfin import *
mesh = UnitSquareMesh(10,10)
x, y = mesh.ufl_cell().x
print assemble(1.0/(y+1)*dx, mesh=mesh) # works
print assemble((y+1)**-1*dx, mesh=mesh) # triggers assertion

now gives

...
  File "/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/quadrature/quadraturerepresentation.py", line 193, in _tabulate_basis
    (points, weights) = create_quadrature(cell_domain, degree, rule)
  File "/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/quadrature_schemes.py", line 70, in create_quadrature
    return _triangle_scheme(degree)
  File "/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/quadrature_schemes.py", line 160, in _triangle_scheme
    x, w = _fiat_scheme("triangle", degree)
  File "/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/quadrature_schemes.py", line 85, in _fiat_scheme
    return fiat_create_quadrature(shape, num_points_per_axis)
  File "/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/ffc/fiatinterface.py", line 145, in create_quadrature
    quad_rule = FIAT.make_quadrature(reference_cell(shape), num_points)
  File "/home/martinal/opt/fenics/dorsal-unstable/lib/python2.7/site-packages/FIAT/quadrature.py", line 169, in make_quadrature
    assert (m > 0), msg
AssertionError: Expecting at least one (not 0) quadrature point per direction

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) wrote :

The error is in 'estimate_total_polynomial_degree' from algorithms which returns 1 for the first form and -1 for the second

affects: ffc → ufl
Changed in ufl:
status: New → Confirmed
Changed in ufl:
assignee: nobody → Martin Sandve Alnæs (martinal)
importance: Undecided → High
status: Confirmed → Fix Committed
milestone: none → 1.1.0-alpha
Changed in ufl:
status: Fix Committed → Fix Released
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.