This is probably not safe to merge right now, since it likely breaks form compilers. Although I'm pretty sure that most cases are broken already. In particular, cell_avg is not imported into the global namespace with from dolfin import * and:
In [2]: from dolfin import *
from
In [3]: from ufl import cell_avg
In [4]: mesh = UnitSquareMesh(1, 1)
In [5]: V = FunctionSpace(mesh, "CG", 1)
In [6]: f = project(SpatialCoordinate(mesh)**2, V)
In[7]: assemble(cell_avg(grad(f)[0])*dx)
/usr/local/lib/python3.5/dist-packages/ffc/uflacs/analysis/balancing.py in _modifier(self, expr, *ops)
77
78 def _modifier(self, expr, *ops):
---> 79 return balance_modified_terminal(expr)
80
81 reference_value = _modifier
/usr/local/lib/python3.5/dist-packages/ffc/uflacs/analysis/balancing.py in balance_modified_terminal(expr)
52 layers = [expr]
53 while not expr._ufl_is_terminal_:
---> 54 assert expr._ufl_is_terminal_modifier_
55 expr = expr.ufl_operands[0]
56 layers.append(expr)
AssertionError:
Similarly, if I switch to the quadrature backend:
In [8]: parameters["form_compiler"]["representation"] = "quadrature"
In [9]: assemble(cell_avg(grad(f)[0])*dx)
Calling FFC just-in-time (JIT) compiler, this may take some time.
/usr/local/lib/python3.5/dist-packages/ffc/quadrature/quadraturerepresentation.py:58: QuadratureRepresentationDeprecationWarning:
*** ===================================================== ***
*** FFC: quadrature representation is deprecated! It will ***
*** likely be removed in 2018.1.0 release. Use uflacs ***
*** representation instead. ***
*** ===================================================== ***
issue_deprecation_warning()
---------------------------------------------------------------------------
...
/usr/local/lib/python3.5/dist-packages/ffc/quadrature/quadratureutils.py in flatten_psi_tables(tables, entity_type)
94 # There's a set of tables for non-averaged and averaged
95 # (averaged only occurs with num_points == 1)
---> 96 for avg, entity_tables in sorted_items(avg_tables):
97
98 # There's a set of tables for each entity number (only
/usr/local/lib/python3.5/dist-packages/ffc/quadrature/quadratureutils.py in sorted_items(mapping, **sorted_args)
76
77 def sorted_items(mapping, **sorted_args):
---> 78 return [(k, mapping[k]) for k in sorted(mapping.keys(), **sorted_args)]
79
80 # Initialise return values and element counter.
TypeError: unorderable types: NoneType() < str()
Addresses #102.
This is probably not safe to merge right now, since it likely breaks form compilers. Although I'm pretty sure that most cases are broken already. In particular,
cell_avg
is not imported into the global namespace withfrom dolfin import *
and:In [2]: from dolfin import * from In [3]: from ufl import cell_avg In [4]: mesh = UnitSquareMesh(1, 1) In [5]: V = FunctionSpace(mesh, "CG", 1) In [6]: f = project(SpatialCoordinate(mesh)**2, V) In[7]: assemble(cell_avg(grad(f)[0])*dx) /usr/local/lib/python3.5/dist-packages/ffc/uflacs/analysis/balancing.py in _modifier(self, expr, *ops) 77 78 def _modifier(self, expr, *ops): ---> 79 return balance_modified_terminal(expr) 80 81 reference_value = _modifier /usr/local/lib/python3.5/dist-packages/ffc/uflacs/analysis/balancing.py in balance_modified_terminal(expr) 52 layers = [expr] 53 while not expr._ufl_is_terminal_: ---> 54 assert expr._ufl_is_terminal_modifier_ 55 expr = expr.ufl_operands[0] 56 layers.append(expr) AssertionError:
Similarly, if I switch to the quadrature backend:
In [8]: parameters["form_compiler"]["representation"] = "quadrature" In [9]: assemble(cell_avg(grad(f)[0])*dx) Calling FFC just-in-time (JIT) compiler, this may take some time. /usr/local/lib/python3.5/dist-packages/ffc/quadrature/quadraturerepresentation.py:58: QuadratureRepresentationDeprecationWarning: *** ===================================================== *** *** FFC: quadrature representation is deprecated! It will *** *** likely be removed in 2018.1.0 release. Use uflacs *** *** representation instead. *** *** ===================================================== *** issue_deprecation_warning() --------------------------------------------------------------------------- ... /usr/local/lib/python3.5/dist-packages/ffc/quadrature/quadratureutils.py in flatten_psi_tables(tables, entity_type) 94 # There's a set of tables for non-averaged and averaged 95 # (averaged only occurs with num_points == 1) ---> 96 for avg, entity_tables in sorted_items(avg_tables): 97 98 # There's a set of tables for each entity number (only /usr/local/lib/python3.5/dist-packages/ffc/quadrature/quadratureutils.py in sorted_items(mapping, **sorted_args) 76 77 def sorted_items(mapping, **sorted_args): ---> 78 return [(k, mapping[k]) for k in sorted(mapping.keys(), **sorted_args)] 79 80 # Initialise return values and element counter. TypeError: unorderable types: NoneType() < str()
The support in TSFC is done here: https://github.com/firedrakeproject/tsfc/pull/158