Dolfinx and FEniCSx installation

OK I am going to go ahead and make a fool of myself by asking this very trivial question, hopefully you guys would forgive me :slightly_smiling_face:
I installed FEniCS by running the following commands on my Ubuntu 20.04 Focal Fossa:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt-get update
sudo apt-get install fenics

The above commands come from this page.
I checked my installation and it works fine, I also ran the ft01_poisson.py found on this page and again it works very fine.

Eventually I bumped up on this page which seems to address a whole new version of things.
For instance I tried to run the demo_poisson.py and this time I got an error saying that module dolfinx doesn't exist.
Could somebody help me out here, what am I missing?
Here are the questions that may help you understand my confusion:

  1. Is the process of installing FEniCSx different from the installation commands I pointed out above?
  2. Should dolfinx be installed separately or it comes with FEniCSx installation?
  3. The tutorial on this page claims to be an adaptation of this Tutorial but the scripts are quite different. Should I just forget this and move along with this?

Thanks a bunch

Hi Sou-Ren, it’s not a dumb question. You’ve installed fenics, which is the legacy version of FEniCS. It provides dolfin, not dolfinx. What you want (if you want dolfinx, not dolfin), is the fenicsx package.

sudo apt-get install fenicsx
1 Like

Thank you dparsons,
I just ran sudo apt install fenicsx then python3 -c "import dolfinx" (given here) and I didn’t get any error message which I believe means the installation is fine. Which I suppose means I don’t need to go through the whole docker installation of dolfinx as explained here right?

Apart from above question when I run python3 demo_poisson.py (given here) it complains as follows

 Traceback (most recent call last):
   File "demo_poisson.py", line 84, in <module>
     from dolfinx.mesh import CellType, GhostMode, locate_entities_boundary
 ImportError: cannot import name 'CellType' from 'dolfinx.mesh' (/usr/lib/petsc/lib/python3/dist-packages/dolfinx/mesh.py)

docker is an alternative means for getting access to the package, maintained inside a container (a virtual machine). You might use it if you don’t have sudo access to install ubuntu packages. If you have sudo access, then you don’t need docker, since you already have the package installed.

dolfinx (fenicsx) is the new version of the package. It’s been developed rapidly over the past year and is still in development. That’s why the lastest release is v0.3 not v1.0 (check that you do have 0.3.0 installed). Your error message probably means the demo doesn’t match the installed version. Likely it got updated for the latest development version and has already lost compatibility with 0.3.0. Try dolfinx/python/demo/poisson at v0.3.0 · FEniCS/dolfinx · GitHub

Thanks again dparsons
It suns smoothly :slightly_smiling_face:
Just another quick question though.
Before going through all modifications you suggested I had FEniCS installed using the following commands

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt-get update
sudo apt-get install fenics

and to get fenicsx and dolfinx I simply ran sudo apt install fenicsx meaning I only changed the last line of the above command and I got dolfinx. But what about the second line where we have ppa:fenics-packages/fenics I didn’t change fenics to fenicsx in this line and it seems not having any impact.
Why is that? any idea?

The PPA is the FEniCS repository for ubuntu packages for the latest release. It’s packages that we (I) prepare ourselves, since the official ubuntu packages don’t get updated and will be stuck at the version available at the time of the ubuntu release. The PPA address is https://launchpad.net/~fenics-packages/+archive/ubuntu/fenics, it provides both the old dolfin and new dolfinx versions.

You can compare the ubuntu versions available to you with apt-cache show fenics fenicsx, you’ll see older versions listed there (the official ubuntu packages).

2 Likes

Hi Dear @dparsons
would you please share the code for installing dolfinx (fenicsx) on Mac?
I am using anaconda

Hi @arash_goli , you can find download (installation) instructions linked from the project home page at https://fenicsproject.org/

1 Like

Thanks for response @dparsons
Unfortunately I could not install it on my MacPro by the following coomand :
conda install -c conda-forge fenicsx

Is there any other way to install it?

Ah, right. It’s dolfinx you’re after, not dolfin. As you found, conda does not officially provide fenicx yet.

You might want to try accessing it via docker instead.

@dparsons
Ah, I did not know that.
Actually I have created an environment by conda and then installed brew in the same directory.
Then I tried to install all requirements (Boost, cmake, xtensor , …) on that environment by brew and conda both. Is it possible that i install fenicsx by docker on that environment?
Or I need to create a new environment by docker and install all requirements by docker and brew?

I recommend following the instructions on the installation page for using docker.

docker is a separate installation method from conda. Don’t mix them.

1 Like