Metadata and compilation error

Hi, I’m trying to run some legacy code. I found compilation error till the assemble line. Is there some issues with the code? It will be great If anyone could share more about usage of metadata, I did not found much information regarding metadata in the tutorial document.

from fenics import *

mesh = UnitSquareMesh(10, 10)

Q = FunctionSpace(mesh, 'CG', 1)

qdegree = 2*Q._ufl_element.degree()

metadata = {"quadrature_degree" : qdegree}

element = FiniteElement("Quadrature", Q.mesh().ufl_cell(), qdegree, quad_scheme="default")

Qh = FunctionSpace(Q.mesh(), element)

p = TrialFunction(Qh)

q = TestFunction(Qh)

Mqh = assemble(inner(p, q)*dx(metadata=metadata))

Error is show as follow

Calling FFC just-in-time (JIT) compiler, this may take some time.
Moving new file over differing existing file:
src: /home/src/jitfailure-ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2/error.log.b68e088b2eaf4e0594ad4442f77d2826
dst: /home/src/jitfailure-ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2/error.log
backup: /home/src/jitfailure-ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2/error.log.old
Backup file exists, overwriting.
------------------- Start compiler output ------------------------
/tmp/tmp6tuyp3nt/ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2.cpp: In member function 'virtual void ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2_cell_integral_main_otherwise::tabulate_tensor(double*, const double* const*, const double*, int) const':
/tmp/tmp6tuyp3nt/ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2.cpp:106:29: error: 'FE6_C0_Q3' was not declared in this scope
             TF0[iq] = fw0 * FE6_C0_Q3[0][iq][iq];
                             ^~~~~~~~~
/tmp/tmp6tuyp3nt/ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2.cpp:106:29: note: suggested alternative: 'FE3_C0_D01_Q3'
             TF0[iq] = fw0 * FE6_C0_Q3[0][iq][iq];
                             ^~~~~~~~~
                             FE3_C0_D01_Q3
/tmp/tmp6tuyp3nt/ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2.cpp:107:34: error: 'FE6_C0_Q3' was not declared in this scope
         BF0[iq][iq] += TF0[iq] * FE6_C0_Q3[0][iq][iq];
                                  ^~~~~~~~~
/tmp/tmp6tuyp3nt/ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2.cpp:107:34: note: suggested alternative: 'FE3_C0_D01_Q3'
         BF0[iq][iq] += TF0[iq] * FE6_C0_Q3[0][iq][iq];
                                  ^~~~~~~~~
                                  FE3_C0_D01_Q3

-------------------  End compiler output  ------------------------
Compilation failed! Sources, command, and errors have been written to: /home/juntao/Desktop/jetFlowRANS/src/jitfailure-ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2
Traceback (most recent call last):
  File "/home/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/ptvsd_launcher.py", line 43, in <module>
    main(ptvsdArgs)
  File "/home/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/__main__.py", line 432, in main
    run()
  File "/home/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/__main__.py", line 316, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/home/anaconda3/envs/fenics/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/home/anaconda3/envs/fenics/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/anaconda3/envs/fenics/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/src/test.py", line 17, in <module>
    Mqh = assemble(inner(p, q)*dx(metadata=metadata))
  File "/home/anaconda3/envs/fenics/lib/python3.6/site-packages/dolfin/fem/assembling.py", line 198, in assemble
    dolfin_form = _create_dolfin_form(form, form_compiler_parameters)
  File "/home/anaconda3/envs/fenics/lib/python3.6/site-packages/dolfin/fem/assembling.py", line 58, in _create_dolfin_form
    function_spaces=function_spaces)
  File "/home/anaconda3/envs/fenics/lib/python3.6/site-packages/dolfin/fem/form.py", line 44, in __init__
    mpi_comm=mesh.mpi_comm())
  File "/home/anaconda3/envs/fenics/lib/python3.6/site-packages/dolfin/jit/jit.py", line 47, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/home/anaconda3/envs/fenics/lib/python3.6/site-packages/dolfin/jit/jit.py", line 97, in ffc_jit
    return ffc.jit(ufl_form, parameters=p)
  File "/home/.local/lib/python3.6/site-packages/ffc/jitcompiler.py", line 217, in jit
    module = jit_build(ufl_object, module_name, parameters)
  File "/home/.local/lib/python3.6/site-packages/ffc/jitcompiler.py", line 133, in jit_build
    generate=jit_generate)
  File "/home/.local/lib/python3.6/site-packages/dijitso/jit.py", line 217, in jit
    % err_info['fail_dir'], err_info)
dijitso.jit.DijitsoError: Dijitso JIT compilation failed, see '/home/src/jitfailure-ffc_form_86b3e7ca5534c808e68909d10e7db6c93f8593d2' for details

There is a bug in the default UFLACS form compiler representation, and you cannot solve problems in which the test/trial spaces are of type “Quadrature”. You can either fall back on the deprecated quadrature representation:

parameters["form_compiler"]["representation"] = "quadrature"

# (To shut off deprecation warnings)
import warnings
from ffc.quadrature.deprecation \
    import QuadratureRepresentationDeprecationWarning
warnings.simplefilter("ignore", QuadratureRepresentationDeprecationWarning)

(which cannot handle very complicated forms) or use the new TSFC representation

parameters["form_compiler"]["representation"] = "tsfc"

although TSFC isn’t installed by default, so you need to add a few extra packages:

pip3 install git+https://github.com/blechta/tsfc.git@2018.1.0
pip3 install git+https://github.com/blechta/COFFEE.git@2018.1.0
pip3 install git+https://github.com/blechta/FInAT.git@2018.1.0
pip3 install singledispatch networkx pulp

Thank you so much.

Approach 1 works. Trying with “tsfc method” now.