KeyError: 'init_mesh'

Asked by Paul Constantine on 2013-01-11

While running demo_navier-stokes.py...

$ python demo_navier-stokes.py
Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
  File "demo_navier-stokes.py", line 37, in <module>
    V = VectorFunctionSpace(mesh, "CG", 2)
  File "/usr/local/lib64/python2.6/site-packages/dolfin/functions/functionspace.py", line 538, in __init__
    FunctionSpaceBase.__init__(self, mesh, element)
  File "/usr/local/lib64/python2.6/site-packages/dolfin/functions/functionspace.py", line 87, in __init__
    ufc_element, ufc_dofmap = jit(self._ufl_element)
  File "/usr/local/lib64/python2.6/site-packages/dolfin/compilemodules/jit.py", line 66, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/local/lib64/python2.6/site-packages/dolfin/compilemodules/jit.py", line 154, in jit
    return jit_compile(form, parameters=p, common_cell=common_cell)
  File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 71, in jit
    return jit_element(ufl_object, parameters)
  File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 183, in jit_element
    compiled_form, module, form_data, prefix = jit_form(form, parameters)
  File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 136, in jit_form
    common_cell=common_cell)
  File "/usr/lib/python2.6/site-packages/ffc/compiler.py", line 175, in compile_form
    format_code(code, wrapper_code, prefix, parameters)
  File "/usr/lib/python2.6/site-packages/ffc/formatting.py", line 73, in format_code
    code_h += _format_h("dofmap", code_dofmap, parameters)
  File "/usr/lib/python2.6/site-packages/ffc/formatting.py", line 116, in _format_h
    return templates[class_type + "_combined"] % code + "\n"
KeyError: 'init_mesh'

I have the latest builds of ffc, fiat, instant, ufc, ufl and dolfin.

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Martin Sandve Alnæs
Solved:
2013-01-15
Last query:
2013-01-15
Last reply:
2013-01-12
Johan Hake (johan-hake) said : #1

Are you using the latest revision of the development branches of the
FEniCS packages? These are under heavy development and I would recommend
to revert back to the 1.1 tag of FFC, UFL, and DOLFIN and 2.1.0 for UFC.

Johan

On 01/11/2013 10:11 PM, Paul Constantine wrote:
> New question #218977 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/218977
>
> While running demo_navier-stokes.py...
>
> $ python demo_navier-stokes.py
> Calling FFC just-in-time (JIT) compiler, this may take some time.
> Traceback (most recent call last):
> File "demo_navier-stokes.py", line 37, in <module>
> V = VectorFunctionSpace(mesh, "CG", 2)
> File "/usr/local/lib64/python2.6/site-packages/dolfin/functions/functionspace.py", line 538, in __init__
> FunctionSpaceBase.__init__(self, mesh, element)
> File "/usr/local/lib64/python2.6/site-packages/dolfin/functions/functionspace.py", line 87, in __init__
> ufc_element, ufc_dofmap = jit(self._ufl_element)
> File "/usr/local/lib64/python2.6/site-packages/dolfin/compilemodules/jit.py", line 66, in mpi_jit
> return local_jit(*args, **kwargs)
> File "/usr/local/lib64/python2.6/site-packages/dolfin/compilemodules/jit.py", line 154, in jit
> return jit_compile(form, parameters=p, common_cell=common_cell)
> File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 71, in jit
> return jit_element(ufl_object, parameters)
> File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 183, in jit_element
> compiled_form, module, form_data, prefix = jit_form(form, parameters)
> File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 136, in jit_form
> common_cell=common_cell)
> File "/usr/lib/python2.6/site-packages/ffc/compiler.py", line 175, in compile_form
> format_code(code, wrapper_code, prefix, parameters)
> File "/usr/lib/python2.6/site-packages/ffc/formatting.py", line 73, in format_code
> code_h += _format_h("dofmap", code_dofmap, parameters)
> File "/usr/lib/python2.6/site-packages/ffc/formatting.py", line 116, in _format_h
> return templates[class_type + "_combined"] % code + "\n"
> KeyError: 'init_mesh'
>
> I have the latest builds of ffc, fiat, instant, ufc, ufl and dolfin.
>

What Johan says. And run instant-clean.

Martin

On 11 January 2013 23:45, Johan Hake
<email address hidden>wrote:

> Question #218977 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/218977
>
> Status: Open => Answered
>
> Johan Hake proposed the following answer:
> Are you using the latest revision of the development branches of the
> FEniCS packages? These are under heavy development and I would recommend
> to revert back to the 1.1 tag of FFC, UFL, and DOLFIN and 2.1.0 for UFC.
>
> Johan
>
> On 01/11/2013 10:11 PM, Paul Constantine wrote:
> > New question #218977 on DOLFIN:
> > https://answers.launchpad.net/dolfin/+question/218977
> >
> > While running demo_navier-stokes.py...
> >
> > $ python demo_navier-stokes.py
> > Calling FFC just-in-time (JIT) compiler, this may take some time.
> > Traceback (most recent call last):
> > File "demo_navier-stokes.py", line 37, in <module>
> > V = VectorFunctionSpace(mesh, "CG", 2)
> > File
> "/usr/local/lib64/python2.6/site-packages/dolfin/functions/functionspace.py",
> line 538, in __init__
> > FunctionSpaceBase.__init__(self, mesh, element)
> > File
> "/usr/local/lib64/python2.6/site-packages/dolfin/functions/functionspace.py",
> line 87, in __init__
> > ufc_element, ufc_dofmap = jit(self._ufl_element)
> > File
> "/usr/local/lib64/python2.6/site-packages/dolfin/compilemodules/jit.py",
> line 66, in mpi_jit
> > return local_jit(*args, **kwargs)
> > File
> "/usr/local/lib64/python2.6/site-packages/dolfin/compilemodules/jit.py",
> line 154, in jit
> > return jit_compile(form, parameters=p, common_cell=common_cell)
> > File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 71,
> in jit
> > return jit_element(ufl_object, parameters)
> > File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 183,
> in jit_element
> > compiled_form, module, form_data, prefix = jit_form(form, parameters)
> > File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 136,
> in jit_form
> > common_cell=common_cell)
> > File "/usr/lib/python2.6/site-packages/ffc/compiler.py", line 175, in
> compile_form
> > format_code(code, wrapper_code, prefix, parameters)
> > File "/usr/lib/python2.6/site-packages/ffc/formatting.py", line 73, in
> format_code
> > code_h += _format_h("dofmap", code_dofmap, parameters)
> > File "/usr/lib/python2.6/site-packages/ffc/formatting.py", line 116,
> in _format_h
> > return templates[class_type + "_combined"] % code + "\n"
> > KeyError: 'init_mesh'
> >
> > I have the latest builds of ffc, fiat, instant, ufc, ufl and dolfin.
> >
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>

Thanks so much for all your attentive help. The support you provide is beyond outstanding.

Still having some issues. I went to 1.1 on everything and ran instant-clean. Here's my current error, followed by the instant compile log.

$ python demo_navier-stokes.py
Calling FFC just-in-time (JIT) compiler, this may take some time.
In instant.recompile: The module did not compile, see '/home/paulcon/.instant/error/a096a21db40e01afea745c6672c67d6bbbe1d377/compile.log'
Traceback (most recent call last):
  File "demo_navier-stokes.py", line 37, in <module>
    V = VectorFunctionSpace(mesh, "CG", 2)
  File "/usr/local/lib64/python2.6/site-packages/dolfin/functions/functionspace.py", line 533, in __init__
    FunctionSpaceBase.__init__(self, mesh, element)
  File "/usr/local/lib64/python2.6/site-packages/dolfin/functions/functionspace.py", line 78, in __init__
    ufc_element, ufc_dofmap = jit(self._ufl_element)
  File "/usr/local/lib64/python2.6/site-packages/dolfin/compilemodules/jit.py", line 66, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/local/lib64/python2.6/site-packages/dolfin/compilemodules/jit.py", line 154, in jit
    return jit_compile(form, parameters=p, common_cell=common_cell)
  File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 71, in jit
    return jit_element(ufl_object, parameters)
  File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 177, in jit_element
    compiled_form, module, form_data, prefix = jit_form(form, parameters)
  File "/usr/lib/python2.6/site-packages/ffc/jitcompiler.py", line 145, in jit_form
    cache_dir = cache_dir)
  File "/usr/local/lib64/python2.6/site-packages/ufc_utils/build.py", line 73, in build_ufc_module
    **kwargs)
  File "/usr/lib/python2.6/site-packages/instant/build.py", line 482, in build_module
    recompile(modulename, module_path, setup_name, new_compilation_checksum)
  File "/usr/lib/python2.6/site-packages/instant/build.py", line 105, in recompile
    "compile, see '%s'" % compile_log_filename_dest)
  File "/usr/lib/python2.6/site-packages/instant/output.py", line 49, in instant_error
    raise RuntimeError(text)
RuntimeError: In instant.recompile: The module did not compile, see '/home/paulcon/.instant/error/a096a21db40e01afea745c6672c67d6bbbe1d377/compile.log'

----

$ cat compile.log
running build_ext
building '_a096a21db40e01afea745c6672c67d6bbbe1d377' extension
creating build
creating build/temp.linux-x86_64-2.6
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/include -I/usr/local/include -I/usr/include/python2.6 -c a096a21db40e01afea745c6672c67d6bbbe1d377_wrap.cxx -o build/temp.linux-x86_64-2.6/a096a21db40e01afea745c6672c67d6bbbe1d377_wrap.o -O0
a096a21db40e01afea745c6672c67d6bbbe1d377_wrap.cxx: In function ‘PyObject* _wrap_ffc_form_a096a21db40e01afea745c6672c67d6bbbe1d377_cell_integral_0_0_tabulate_tensor__SWIG_1(PyObject*, int, PyObject**)’:
a096a21db40e01afea745c6672c67d6bbbe1d377_wrap.cxx:3548: error: ‘SWIG_exception’ was not declared in this scope
error: command 'gcc' failed with exit status 1

I do appear to have two versions of swig.

Recent install:
/usr/local/share/swig/2.0.9

Older install
/usr/share/swig/1.3.40

However, the temporary .cxx file was generated with the correct, newer version. From the file:
...
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.9
...

Thanks Martin Sandve Alnæs, that solved my question.

Nico Schlömer (nschloe) said : #6

I experience the same issue as the original poster for something as simple as

from dolfin import *
mesh = UnitIntervalMesh(20)
V = FunctionSpace(mesh, "CG", 1)

Going back to 1.1.0 is not an option for me right now since I would like to try out a fix for another Dolfin bug.

Since this malfunction is so fundamental, I'm thinking it's something that the devs aren't seeing at all on their machines.
Anything I could do to debug?

Marie Rognes (meg-simula) said : #7

You probably have a mismatch in the FFC/UFC/DOLFIN versions installed/picked up. init_mesh is a function that has been removed from UFC, but your FFC still thinks it's there.

Johan Hake (johan-hake) said : #8

You need to make sure that the python modules of ufc is installed correctly.

%(init_mesh)s is in:

  src/utils/python/ufc_utils/dofmap.py

for both 2.0.1 and 2.1.0 but not in trunk. You most probably have an old ufc_utils hanging around.

Johan

Johan Hake (johan-hake) said : #9

On 01/22/2013 08:15 PM, Marie Rognes wrote:
> Question #218977 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/218977
>
> Marie Rognes posted a new comment:
> You probably have a mismatch in the FFC/UFC/DOLFIN versions
> installed/picked up. init_mesh is a function that has been removed from
> UFC, but your FFC still thinks it's there.

I think it is the other way around :)

The templates from ufc_utils expects a form with "init_mesh", which ffc
does not generate anymore.

Johan

Nico Schlömer (nschloe) said : #10

> You most probably have an old ufc_utils hanging around.

Indeed:

>> import dolfin
>> dolfin.__file__
'/home/nschloe/Work/FEniCS/lib/python2.7/site-packages/dolfin/__init__.pyc'
>> import ufc_utils
>> ufc_utils.__file__
'/usr/lib/python2.7/dist-packages/ufc_utils/__init__.pyc'

The problem is with Dorsal I think:
All packages are installed into

~/Work/FEniCS/lib/python2.7/site-packages/

except UFC which sits in

~/Work/FEniCS/lib/python2.7/dist-packages/.

Anders Logg (logg) said : #11

On Tue, Jan 22, 2013 at 08:06:01PM -0000, Nico Schlömer wrote:
> Question #218977 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/218977
>
> Nico Schlömer posted a new comment:
> > You most probably have an old ufc_utils hanging around.
>
> Indeed:
>
> >> import dolfin
> >> dolfin.__file__
> '/home/nschloe/Work/FEniCS/lib/python2.7/site-packages/dolfin/__init__.pyc'
> >> import ufc_utils
> >> ufc_utils.__file__
> '/usr/lib/python2.7/dist-packages/ufc_utils/__init__.pyc'
>
> The problem is with Dorsal I think:
> All packages are installed into
>
> ~/Work/FEniCS/lib/python2.7/site-packages/
>
> except UFC which sits in
>
> ~/Work/FEniCS/lib/python2.7/dist-packages/.

Did you try removing the old installation before installing the new
one?

--
Anders

Nico Schlömer (nschloe) said : #12

That's what Garth suggested suggested at https://bugs.launchpad.net/dorsal/+bug/1103153 too. -- And it worked. Thanks!