Two reoccurring problems while running FEniCS

Hi all,

Hope that your weekend is going well!

While running FEniCS tutorial examples taken from https://fenicsproject.org/tutorial/,

on Spyder 4.15, Mac 10.15.7 or on Terminal in the fenicsproject envi., I am facing two reoccurring issues that prevent the files from compile. My Python version is 3.8.

The failures to compile so far persist in two forms:

1-runfile(’/opt/anaconda3/envs/fenicsproject/ft01_poisson.py’, wdir=’/opt/anaconda3/envs/fenicsproject’)

File “/opt/anaconda3/envs/fenicsproject/ft01_poisson.py”, line 21

from __future__ import print_function

^

SyntaxError: from future imports must occur at the beginning of the file.

After copy, paste and run of: ft01_poisson.py or ft02_poisson.py

2- File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/jit/jit.py”, line 170, in compile_class

raise RuntimeError("Unable to compile C++ code with dijitso")

RuntimeError: Unable to compile C++ code with dijitso

After copy, paste and run of: ft03_heat.py and ft05_poisson_nonlinear.py.

Any help would be great to have!

Saar

The first issue is easily solved by removing the import of the print function. As you are using Python3.x there isnt any reason for importing it.
As for your other problems, you need to actually copy-paste the code you are running here and point to which line the error is in.

Note that the tutorials were created for FEniCS 2016.2.0. There has been a lot of API changes since then, and you need to specify which version of fenics you are using.

1 Like

Hello!
Thank you so much for answering over the weekend and leading me to provide more precise data!

1.All my downloads were via conda-forge (FeniCS, Dolfin and their dependencies)
2. Spyder 4.15, Mac 10.15.7, Python version 3.8, FEniCS version 2019.1.0 py38h32f6830_10 is the last on in a long list that I see after typing conda search fenics conda-forge
3. The problems occur both in executing In terminal (fenicsproject environment) or with Spyder in the fenicsproject environment.
4.I am new to Python and wishing to convert from Mathematica and Java to Python. My need in a working PDE library is due to my own mathematical research in conformal mapping.
5. The remarks below relate to the examples, which I copy and paste to Spyder, from here https://fenicsproject.org/tutorial.

ft01_poisson.py - works with no issues.


ft02_poisson_membrane.py fails to compile. As far as I can tell, it fails right after the cal to
from mshr import *.

runfile(’/opt/anaconda3/envs/fenicsproject/ft02_poisson_membrane.py’, wdir=’/opt/anaconda3/envs/fenicsproject’)
Traceback (most recent call last):

File “/opt/anaconda3/envs/fenicsproject/ft02_poisson_membrane.py”, line 3, in
from mshr import *

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/mshr/init.py”, line 24, in
from .cpp import Circle

ImportError: generic_type: type “CSGGeometry” referenced unknown base type “dolfin::Variable”


ft_03_heat.py. Fails to compile

runfile(’/opt/anaconda3/envs/fenicsproject/ft03_heat.py’, wdir=’/opt/anaconda3/envs/fenicsproject’)
------------------- Start compiler output ------------------------
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

------------------- End compiler output ------------------------
Compilation failed! Sources, command, and errors have been written to: /opt/anaconda3/envs/fenicsproject/jitfailure-dolfin_expression_aff4bdda4932159eae1eaa8144a93f7b
Traceback (most recent call last):

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/jit/jit.py”, line 165, in compile_class
module, signature = dijitso_jit(cpp_data, module_name, params,

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/jit/jit.py”, line 47, in mpi_jit
return local_jit(*args, **kwargs)

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/jit/jit.py”, line 103, in dijitso_jit
return dijitso.jit(*args, **kwargs)

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dijitso/jit.py”, line 216, in jit
raise DijitsoError(“Dijitso JIT compilation failed, see ‘%s’ for details”

DijitsoError: Dijitso JIT compilation failed, see ‘/opt/anaconda3/envs/fenicsproject/jitfailure-dolfin_expression_aff4bdda4932159eae1eaa8144a93f7b’ for details

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “/opt/anaconda3/envs/fenicsproject/ft03_heat.py”, line 17, in
u_D = Expression(‘1 + x[0]x[0] + alphax[1]x[1] + betat’,

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/function/expression.py”, line 400, in init
self._cpp_object = jit.compile_expression(cpp_code, params)

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/function/jit.py”, line 158, in compile_expression
expression = compile_class(cpp_data, mpi_comm=mpi_comm)

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/jit/jit.py”, line 170, in compile_class
raise RuntimeError(“Unable to compile C++ code with dijitso”)

RuntimeError: Unable to compile C++ code with dijitso



ft_04_heat_gaussian.py. Fails to compile.
runfile(’/opt/anaconda3/envs/fenicsproject/ft04_heat_gaussian.py’, wdir=’/opt/anaconda3/envs/fenicsproject’)
------------------- Start compiler output ------------------------
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

------------------- End compiler output ------------------------
Compilation failed! Sources, command, and errors have been written to: /opt/anaconda3/envs/fenicsproject/jitfailure-dolfin_expression_6cc907875187e5605a7b7ac57ea3828c
Traceback (most recent call last):

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/jit/jit.py”, line 165, in compile_class
module, signature = dijitso_jit(cpp_data, module_name, params,

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/jit/jit.py”, line 47, in mpi_jit
return local_jit(*args, **kwargs)

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/jit/jit.py”, line 103, in dijitso_jit
return dijitso.jit(*args, **kwargs)

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dijitso/jit.py”, line 216, in jit
raise DijitsoError(“Dijitso JIT compilation failed, see ‘%s’ for details”

DijitsoError: Dijitso JIT compilation failed, see ‘/opt/anaconda3/envs/fenicsproject/jitfailure-dolfin_expression_6cc907875187e5605a7b7ac57ea3828c’ for details

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “/opt/anaconda3/envs/fenicsproject/ft04_heat_gaussian.py”, line 20, in
u_0 = Expression(‘exp(-apow(x[0], 2) - apow(x[1], 2))’,

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/function/expression.py”, line 400, in init
self._cpp_object = jit.compile_expression(cpp_code, params)

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/function/jit.py”, line 158, in compile_expression
expression = compile_class(cpp_data, mpi_comm=mpi_comm)

File “/opt/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/jit/jit.py”, line 170, in compile_class
raise RuntimeError(“Unable to compile C++ code with dijitso”)

RuntimeError: Unable to compile C++ code with dijitso



It would be great to have your advice about how to acquire working and deep knowledge of Fenics. I am reading “Numerical Python” by Johansson and liking it. Still, as he said his chapter is only an overview of what Fenics can do. I also just dowloaded the free version of vol1 of FEniCS tutorial, yet this one is a 2017 version.

I look forward to hearing back from you!
Saar

PS-I did not continue after ft_04 as obviously something is wrong.

To fix the mshr import issue, see: Anaconda Installation of Fenics and Mshr

The codes, as I said, was written and tested with the 2016.2.0 version, which can be found on conda forge (https://anaconda.org/conda-forge/fenics/labels)

The recommended way of using old versions of dolfin is by using docker.

If you want to have an overview of the capabilities of the latest version of fenics, i suggest having a look at https://fenicsproject.org/docs/dolfin/latest/python/demos.html

1 Like

Great many thanks-
I followed your suggested steps and things look promising!

Running this morning through all the examples in the latest version you suggested, still have me fail/wonder about the following points.

1-All the figures that I am getting are flat. None of these is like the figures in the demo official page (the one you sent me) in which the figures are showing with the solution as a height function. Can I make both forms work for me?

2-Perhaps related to this is the most serious problem I has in which (see below) demo_eigenvalues.py yields an empty box. and compilation
ending with “NotImplementedError: Axes3D currently only supports the aspect argument ‘auto’. You passed in ‘equal’.”

3-Finally, in the demo_elastodynamics, I get two figures but no animation as presented on the demo official page.

Here is the data.
demo_poisson.py - Why is the figure that I am getting flat vs. the demo page which shows the solution in 3d, taking (i assume) the solution as a height function?

A lot has happened in visualization over the last few years:

  1. The default visualization in dolfin of 2D meshes are now rendered in 2D with matplotlib.
    For more advanced interactive visualization, it is suggested to use vedo which has a lot of examples for plotting with dolfin.
  2. Was due to an update in matplotlib, and has been fixed in the latest version of dolfin (ref NotImplementedError: Axes3D currently only supports the aspect argument 'auto'. You passed in 'equal')
  3. The animation can be recreated by using for instance Paraview. In this problem, the data is written to file (XDMF) format, which can be visualized with Paraview
1 Like

Hey Jorgen,

Thanks so much! As I am working on your suggestions blow, I just want to make sure that the envi. created, fenicstest, from your previous reply is functioning.

  1. Item 1 below uses Jupter notebooks. Mysteriously, launching Jupyter Notebook from Anaconda Navigator does not work for me. It does work from terminal in the (fenicstest) envi. simply by typing jupeter notebook.

Interestingly enough, Jupyterlab does work from the GUI. Known issue?

  1. For 2, I see that you contributed the fix and I am assuming that I need to get into the actual mentioned file and make the changes myself. Correct?

Best regards,
Saar

  1. I am not a user of Anaconda. So I cannot comment on related issues.
  2. It is in the latest version of dolfin (the master branch), but it hasn’t made its way to conda, so you would have to edit that file yourself (the error message should show you where the file is located).

Hello!

I am very grateful!

Saar

Hello Jorgen,

I have repeated all the previous step that led to success (mod the Axes issue) on my office’s Mac. However, on my laptop which
is Mac Catalina 10.15.7, things fail.

Here is the data from running the first demo example demo_poisson.py from the page with updated demos.

I am not sure what is going on (other than the change to Catalina 10.15.7). I even tried to
create an additional envi. fenicstest typing

conda create -n fenicstest1 -c conda-forge mshr=2019.1.0=py38h8c59516_3

where the mshr version is the last present on my list

conda search mshr -c conda-forge

The previous version mshr 2019.1.0 py38h2af9582_2
worked for my office computer and did not work on the laptop as well.

Best of wishes,
Saar

in your first error in ft_03_heat.py you can see the cause
“missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun”
as you are using an old mac probably xcode is not installed. Just open a terminal and install it
by typing xcode-select --install
(after that restart your kernel if you are using jupyter )