2.8. Installing pyoomph (with PETSc/SLEPc) on Windows via WSL

PETSc/SLEPc cannot be built natively on Windows (see Section 2.6). If you need it on Windows, the recommended route is to install pyoomph inside the Windows Subsystem for Linux (WSL). WSL2 runs a real Linux kernel, so once you are inside it, pyoomph and PETSc/SLEPc are installed exactly as on native Linux – the restrictions that apply to native Windows builds simply do not apply anymore.

Note that you no longer need this merely to get a good eigensolver: the native Windows wheel ships with the built-in Spectra eigensolver, which handles unsymmetric and singular mass matrices and can target a complex eigenvalue, so linear stability analysis including azimuthal and normal mode problems works without WSL. Take this route if you want PETSc as linear solver, MPI-parallel runs, or an eigensolve distributed over several processes.

2.8.1. Install WSL

From an elevated Windows PowerShell, run

wsl --install -d Ubuntu

Reboot if prompted, then open the “Ubuntu” app it creates and finish the first-run setup (choose a username/password). Make sure you end up with WSL2, not WSL1:

wsl -l -v

If a distribution is listed as version 1, upgrade it with

wsl --set-version Ubuntu 2

2.8.2. Install pyoomph inside WSL

Open the Ubuntu terminal and treat it exactly like a normal Linux installation (cf. Section 2.2.2):

sudo apt update
sudo apt install gcc libopenmpi-dev flex bison
python3 -m pip install --upgrade pyoomph

Or, for an editable install from source:

git clone https://www.github.com/pyoomph/pyoomph.git
cd pyoomph
bash ./build_for_develop.sh

Check that the installation works:

python -m pyoomph check all

Note

Keep the pyoomph (and later PETSc) source trees on the Linux filesystem, e.g. under ~/..., rather than under /mnt/c/.... Cross-filesystem I/O between Windows and WSL is much slower and can cause issues with some build tooling.

2.8.3. Build PETSc/SLEPc inside WSL

Since WSL is a genuine Linux environment, the normal PETSc/SLEPc build recipe from Section 2.6 applies without any changes – including the option to build both a real and a complex arch side by side if you also need normal mode eigenvalue problems (cf. Section 11.4 and Section 11.5):

cd A_FOLDER_OF_YOUR_CHOICE
git clone -b release https://gitlab.com/petsc/petsc.git petsc
cd petsc
export PETSC_DIR=$(pwd)
export PETSC_ARCH=pyoomph_petsc_arch_real

./configure --with-mpi  --with-petsc4py --with-slepc4py --download-mumps=yes --download-hypre=yes --download-parmetis=yes --download-ptscotch=yes --download-slepc=yes --download-superlu=yes --download-superlu_dist=yes --download-suitesparse=yes --download-metis=yes --download-scalapack --with-scalar-type=real

At the end, configure prints the exact make command to run next; execute it. If you also need normal mode eigenvalue problems, repeat with a complex arch:

export PETSC_ARCH=pyoomph_petsc_arch_complex
./configure --with-mpi  --with-petsc4py --with-slepc4py --download-mumps=yes --download-parmetis=yes --download-ptscotch=yes --download-slepc=yes --download-superlu=yes --download-superlu_dist=yes --download-suitesparse=yes --download-metis=yes --download-scalapack --with-scalar-type=complex

and execute the make command it prints, as before. Note that --download-hypre is dropped for the complex arch, since HYPRE only supports real-valued matrices (see Section 2.6 for details); MUMPS remains the factorization backend used via use_mumps() either way.

Afterwards, add the following to ~/.bashrc inside WSL so the variables are set in every new terminal (use the pyoomph_petsc_arch_complex arch here instead if you mainly need normal mode eigenvalue problems; only one arch can be active per process, see Section 2.6 for how to switch between them):

export PETSC_DIR=A_FOLDER_OF_YOUR_CHOICE/petsc
export PETSC_ARCH=pyoomph_petsc_arch_real
export PYTHONPATH=$PYTHONPATH:$PETSC_DIR/$PETSC_ARCH/lib

You can then select SLEPc with MUMPS as eigensolver, either in your driver script

problem.set_eigensolver("slepc").use_mumps()

or via the command line flag

python my_eigenvalue_simulation.py --slepc_mumps

2.8.4. Notes specific to WSL

  • Memory: building PETSc with MUMPS, SuperLU_dist and ScaLAPACK is memory-hungry. If make gets killed (out of memory), increase the memory available to WSL2 by creating/editing C:\Users\<you>\.wslconfig on the Windows side:

    [wsl2]
    memory=8GB
    

    and then restart WSL (wsl --shutdown from PowerShell, then reopen the Ubuntu terminal).

  • Editor integration: if you use VS Code, install the “WSL” remote extension and open the project from within WSL (code . from the Ubuntu terminal). This makes sure the Python interpreter and terminal used by the editor are the WSL ones, so the PETSC_DIR/PETSC_ARCH/PYTHONPATH variables set above are actually visible to the process running your script. Running the script from a plain Windows terminal or Windows Python installation will not see them.

  • Everything else – MKL, gcc, output via ParaView on the Windows side (WSL2 can access the Windows filesystem under /mnt/c/... if you want to write output there directly), etc. – behaves as described for native Linux in Section 2.2.2 and Section 2.1.1.