Skip to main content

James Brind

PyFR installation hints

The official documentation of PyFR is somewhat sparse, so crucial parts of the installation process that were not obvious to me are given in this post.

PyFR is a Python-based framework for solving advection-diffusion equation systems over unstructured grids. The main application is high-order accurate, unsteady computational fluid dynamics simulations. What is particularly neat is the ability to run in parallel on a heterogeneous mix of architectures, e.g. GPUs and CPUs together, and that unlike most CFD codes it is open-source. Technical details at the reference below.

PyFR: An Open Source Framework for Solving Advection-Diffusion Type Problems on Streaming Architectures using the Flux Reconstruction Approach. F. D. Witherden, A. M. Farrington, P. E. Vincent. Computer Physics Communications, Volume 185, Pages 3028-3040, 2014.

Prerequisites are git and a build environment including a C compiler. A functional OpenMPI environment is also required. These instructions were tested on Debian 7.11.

Pre-built packages

First install the pre-built software packages using your favourite package manager. We need cmake to generate a configure file later on, and metis to perform load balancing. The HDF5 and OpenMPI libraries, with development headers, are needed to install their respective Python interfaces. Finally, the libraries for GNU Readline, OpenSSL, SQLite3 and bzip2 are needed to build Python from source.

sudo apt-get install cmake metis
sudo apt-get install libhdf5-openmpi-dev libopenmpi-dev 
sudo apt-get install libreadline-dev libssl-dev libsqlite3-dev libbz2-dev

Python environment

Configuring multiple Python installations can be quite an involved process. Fortunately, there is a small utility called pyenv which simplifies this and allows many independent versions to peacefully coexist. The facility to start from scratch with a clean Python installation is also useful. First download the installation script,

wget https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer

By default pyenv will be installed to ~/.pyenv/. If you want to change this, set PYENV_ROOT in the installer, and after installation in your .bashrc. Run the installation script. We can now download and build a fresh copy of Python 3.4.7 using,

pyenv install 3.4.7

and create a new virtual environment based on this for our PyFR install using,

pyenv virtualenv 3.4.7 pyfr
pyenv activate pyfr

When finished with PyFR, you can exit the virtual environment and restore your shell to the pre-existing Python environment using,

pyenv deactivate pyfr

but don’t do that yet! Now we install the Python modules we need using,

pip install appdirs gimmik h5py mako mpi4py numpy pytools 

and if all is well, install PyFR itself,

pip install pyfr

Backend

PyFR interfaces with a particular compute architecture through a ‘backend’. For example, to run on multi-core CPUs, the OpenMP backend is needed. This requires a BLAS library,

sudo apt-get install libopenblas-dev libopenblas-base

Other backends are available; see the PyFR documentation for further information.

Compiling CGNS

The ability to read CGNS files increases the usability of PyFR. Because my distribution repository only has CGNS 3.1, and PyFR requires >=3.3, I built the CGNS library from the latest source,

git clone -b master https://github.com/CGNS/CGNS.git
cd CGNS/
cmake .
make
sudo make install

Anecdotally, PyFR seems to be unsuccessful at locating the libcgns.so file even if it is correctly installed. To work around this, we can manually point PyFR at the correct path by setting,

export PYFR_LIBRARY_PATH=/path/to/cgns/lib

Testing

You should now be able to run the example cases in the PyFR User Guide. To test the CGNS reader, try one of the official CGNS example files.