Fenics install from source


I am trying to install the stable version of fenics from source using the instructions from

It appears to succeed.

[apal@L01 ~]$ pip3 install --user fenics-ffc --upgrade
Collecting fenics-ffc
  Using cached fenics_ffc-2019.1.0.post0-py3-none-any.whl (362 kB)
Collecting fenics-ufl<2019.2,>=2019.1.0
  Using cached fenics_ufl-2019.1.0-py3-none-any.whl (282 kB)
Collecting fenics-fiat<2019.2,>=2019.1.0
  Using cached fenics_fiat-2019.1.0-py3-none-any.whl (112 kB)
Collecting fenics-dijitso<2019.2,>=2019.1.0
  Using cached fenics_dijitso-2019.1.0-py3-none-any.whl (46 kB)
Collecting numpy
  Using cached numpy-1.21.2-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.8 MB)
Collecting sympy
  Using cached sympy-1.8-py3-none-any.whl (6.1 MB)
Collecting mpmath>=0.19
  Using cached mpmath-1.2.1-py3-none-any.whl (532 kB)
Installing collected packages: numpy, fenics-ufl, mpmath, sympy, fenics-fiat, fenics-dijitso, fenics-ffc
Successfully installed fenics-dijitso fenics-ffc fenics-fiat fenics-ufl mpmath numpy sympy

However, I get an import error with import fenics.

[apal@L01 ~]$ python -c "import re,numpy; print(re.compile('/__init__.py.*').sub('',numpy.__file__))"
[apal@L01 ~]$ python -c "import re,numpy,fenics; print(re.compile('/__init__.py.*').sub('',fenics.__file__))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fenics'

Here are are contents of my PYTHONPATH and the folder with the installed packages.

[apal@L01 ~]$ tr ':' '\n' <<< "$PYTHONPATH"
[apal@L01 ~]$ ls ~/.local/lib/python3.8/site-packages/
dijitso                              fenics_fiat-2019.1.0.dist-info  FIAT       mpmath-1.2.1.dist-info  numpy.libs   sympy-1.8.dist-info
fenics_dijitso-2019.1.0.dist-info    fenics_ufl-2019.1.0.dist-info   isympy.py  numpy                   __pycache__  ufl
fenics_ffc-2019.1.0.post0.dist-info  ffc                             mpmath     numpy-1.21.2.dist-info  sympy

Thank you for your attention.

What happened when you ran the cmake .. step for dolfin? Did it report a successful build for dolfin?

1 Like

Thank you. I realized my mistake and I went ahead and tried to build dolfin. The cmake seems to succeed but it cannot find SLEPC, even though SLEPC_DIR is defined. Considering it is optional, I have chosen to ignore it.

Cmake also gave an UFC not found error when I used the “git checkout master” of dolfin. However, when I switched to “git checkout 2019.1.0.post0” according to instructions, (my FENICS_VERSION is 2019.1.0.post0), cmake was able to find ufc from the penultimate pip3 install fenics-ffc step.

In summary, dolfin cmake succeeds with the following:

-- The following OPTIONAL packages have been found:

 * MPI, Message Passing Interface (MPI)
   Enables DOLFIN to run in parallel with MPI
 * PETSc (required version >= 3.7), Portable, Extensible Toolkit for Scientific Computation, <https://www.mcs.anl.gov/petsc/>
   Enables the PETSc linear algebra backend
 * BLAS, Basic Linear Algebra Subprograms, <http://netlib.org/blas/>
 * Threads
 * ZLIB, Compression library, <http://www.zlib.net>

-- The following REQUIRED packages have been found:

 * Boost, Boost C++ libraries, <http://www.boost.org>
 * Eigen3 (required version >= 3.2.90), Lightweight C++ template library for linear algebra, <http://eigen.tuxfamily.org>
 * PythonInterp (required version >= 3), Interactive high-level object-oriented language, <http://www.python.org>
 * UFC (required version >= 2019.1), Unified language for form-compilers (part of FFC), <https://bitbucket.org/fenics-project/ffc>
 * PkgConfig

-- The following features have been disabled:

 * CMAKE_USE_RELATIVE_PATHS, Use relative paths in makefiles and projects.
 * DOLFIN_ENABLE_CODE_COVERAGE, Enable code coverage.
 * DOLFIN_ENABLE_BENCHMARKS, Enable benchmark programs.
 * DOLFIN_SKIP_BUILD_TESTS, Skip build tests for testing usability of dependency packages.
 * DOLFIN_DEPRECATION_ERROR, Turn deprecation warnings into errors.
 * DOLFIN_ENABLE_GEOMETRY_DEBUGGING, Enable geometry debugging.

-- The following OPTIONAL packages have not been found:

 * SLEPc (required version >= 3.7), Scalable Library for Eigenvalue Problem Computations, <http://slepc.upv.es/>
 * SUNDIALS (required version >= 3), SUite of Nonlinear and DIfferential/ALgebraic Equation Solvers, <http://computation.llnl.gov/projects/sundials>
   Provides robust time integrators and nonlinear solvers that can easily be incorporated into existing simulation codes.
 * SCOTCH, Programs and libraries for graph, mesh and hypergraph partitioning, <https://www.labri.fr/perso/pelegrin/scotch>
   Enables parallel graph partitioning
 * UMFPACK, Sparse LU factorization library, <http://faculty.cse.tamu.edu/davis/suitesparse.html>
 * CHOLMOD, Sparse Cholesky factorization library for sparse matrices, <http://faculty.cse.tamu.edu/davis/suitesparse.html>
 * HDF5, Hierarchical Data Format 5 (HDF5), <https://www.hdfgroup.org/HDF5>

However, now, the make install step fails at the following:

[ 51%] Building CXX object dolfin/CMakeFiles/dolfin.dir/la/Amesos2LUSolver.cpp.o
In file included from /home/apal/software/fenics-marie/src/dolfin/dolfin/la/Amesos2LUSolver.cpp:27:
/home/apal/software/fenics-marie/src/dolfin/dolfin/la/TpetraMatrix.h:34:10: fatal error: Tpetra_DefaultPlatform.hpp: No such file or directory
 #include <Tpetra_DefaultPlatform.hpp>
compilation terminated.
make[2]: *** [dolfin/CMakeFiles/dolfin.dir/la/Amesos2LUSolver.cpp.o] Error 1
make[1]: *** [dolfin/CMakeFiles/dolfin.dir/all] Error 2

I was wondering if there are preferred versions of eigen, trilinos, petsc, etc that will build and install successfully with some version of dolfin. Thank you.

No “preferred” version as such. There are minimum requirements, expressed already in CMakeFiles.txt. PETSc should be >= 3.10 or 3.12.

Trilinos is not really well supported. Try building without it.

1 Like

Thank you. I was able to build and install fenics-ffc and dolfin. When I try to import dolfin, I get the following error:

>>> import fenics
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/apal/.local/lib/python3.8/site-packages/fenics/__init__.py", line 7, in <module>
    from dolfin import *
  File "/home/apal/.local/lib/python3.8/site-packages/dolfin/__init__.py", line 142, in <module>
    from .fem.assembling import (assemble, assemble_system, assemble_multimesh,
  File "/home/apal/.local/lib/python3.8/site-packages/dolfin/fem/assembling.py", line 34, in <module>
    from dolfin.fem.form import Form
  File "/home/apal/.local/lib/python3.8/site-packages/dolfin/fem/form.py", line 12, in <module>
    from dolfin.jit.jit import dolfin_pc, ffc_jit
  File "/home/apal/.local/lib/python3.8/site-packages/dolfin/jit/jit.py", line 18, in <module>
    raise RuntimeError("Could not find DOLFIN pkg-config file. Please make sure appropriate paths are set.")
RuntimeError: Could not find DOLFIN pkg-config file. Please make sure appropriate paths are set.

I am not sure which pkg-config file it is looking for and how to set the appropriate path variable.
I have found a dolfin.conf in ~/.local/share/dolfin/ and I have added that path to PATH and PYTHONPATH but the error persists. Thank you.

PATH is for executables, PYTHONPATH for python modules.

Check man pkg-config. The path for pkg-config files is PKG_CONFIG_PATH

1 Like

Thank you very much! I was able to set pkg_config_path and run fenics properly. Finally!

Next step, I tried running in parallel and it failed because scotch was missing. I changed some code lines to use parmetis instead of scotch, and it gave an error because dolpfin was not built with parmetis.

I looked at the cmake logs and found that parmetis is not found even though it is available. Cmake can find boost, eigen3, python, ufc, pkgconfig, mpi, petsc, blas, zlib but not slepc, sundials, scotch, umfpack, cholmod, hdf5, parmetis.

Thus, I have slepc and parmetis installed which cmake cannot find and I am working on getting cmake to find them. Any tips in this direction is welcome. Thank you again for your attention.

Set both SLEPC_DIR and PETSC_DIR to find SLEPc.

I’m not sure about parmetis. Inspect CMakeFiles.txt to see how it is detected. You might need to provide the path to headers files and library.