I'm using FEniCS 2016.1 and I have the following issue.
A minimal example:
from dolfin import *
cmesh = UnitSquareMesh(32, 32, "crossed")
fmesh = refine(cmesh)
U = FunctionSpace(cmesh, "Lagrange", 1)
Z = FunctionSpace(fmesh, "Lagrange", 1)
phi = TestFunction(U)
z = Function(Z)
vec = assemble((z * Dx(phi, 0)) * dx(fmesh))
This gives the following output:
Number of cells increased from 4096 to 16384 (300.0% increase).
Traceback (most recent call last):
File "basistest.py", line 12, in
vec = assemble((z * Dx(phi, 0)) * dx(fmesh))
File "/usr/local/lib/python2.7/dist-packages/dolfin/fem/assembling.py", line 192, in assemble
dolfin_form = _create_dolfin_form(form, form_compiler_parameters)
File "/usr/local/lib/python2.7/dist-packages/dolfin/fem/assembling.py", line 66, in _create_dolfin_form
function_spaces=function_spaces)
File "/usr/local/lib/python2.7/dist-packages/dolfin/fem/form.py", line 94, in init
mpi_comm=mesh.mpi_comm())
File "/usr/local/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 65, in mpi_jit
return local_jit(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 124, in jit
result = ffc.jit(ufl_object, parameters=p)
File "/usr/local/lib/python2.7/dist-packages/ffc/jitcompiler.py", line 196, in jit
module_name = "ffc_%s_%s" % (kind, jit_object.signature())
File "/usr/local/lib/python2.7/dist-packages/ffc/jitobject.py", line 73, in signature
form_signature = self.ufl_object.signature()
File "/usr/local/lib/python2.7/dist-packages/ufl/form.py", line 227, in signature
self._compute_signature()
File "/usr/local/lib/python2.7/dist-packages/ufl/form.py", line 401, in _compute_signature
self._signature = compute_form_signature(self, self._compute_renumbering())
File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/signature.py", line 138, in compute_form_signature
terminal_hashdata = compute_terminal_hashdata(integrands, renumbering)
File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/signature.py", line 75, in compute_terminal_hashdata
data = expr._ufl_signature_data_(renumbering)
File "/usr/local/lib/python2.7/dist-packages/ufl/argument.py", line 109, in _ufl_signature_data_
fsdata = self._ufl_function_space._ufl_signature_data_(renumbering)
File "/usr/local/lib/python2.7/dist-packages/ufl/functionspace.py", line 74, in _ufl_signature_data_
ddata = None if domain is None else domain._ufl_signature_data_(renumbering)
File "/usr/local/lib/python2.7/dist-packages/ufl/domain.py", line 128, in _ufl_signature_data_
return ("Mesh", renumbering[self], self._ufl_coordinate_element)
KeyError: Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 0)
Aborted (core dumped)
The finite-element function z is from the space Z, defined on the finer mesh fmesh. The space U being defined on a coarser mesh, cmesh, is a (lower-dimensional) subspace of Z and clearly any function in U can be seen as (interpolate to) a function in Z. This of course (in theory) should also hold for test functions on U. However, FEniCS does not know automatically how to handle this and I'm looking for a way to explicitly make it work. Of course, the following line works
vec = assemble((z * Dx(phi, 0)) * dx(cmesh))
but it does not respect the known structure of z.
Some advice how to address this and perform assemble on a finer mesh using test function (basis functions) on a coarser mesh (i.e. on a macro-element) would be highly appreciated. While in principle this is a clear task, it is not so clear to me how to implement it in FEniCS, especially in an efficient way.
Thank you!