Making FEniCSx more available on Windows machines

Currently Windows users can only access FEniCSx by installing a program WSL2 to create a linux subsystem on Windows. I am a new user who has finally gotten this up and running, but there are some significant difficulties from what I am seeing. More details on this can be found in my thread “Installing FEniCSx on Windows 11” in the Installation category. When I asked why FEniCSx can’t run on Windows, I received the following information:

“It is not available on Windows due to the usage of PETSc for linear algebra.

There is a medium term goal of having petsc as an optional dependency, meaning that one could build directly on Windows
Make PETSc an optional dependency · Issue #2472 · FEniCS/dolfinx · GitHub 1

I realize that all work on FEniCSx must be prioritized, and I would like to supply some information here that might be considered in setting these priorities. As background, I am a mathematician who spent most of his life building PDE-based models of electrochemical systems. Recently I came upon the following article: Application of Open-Source, Python-Based Tools for the Simulation of Electrochemical Systems, by Molel and Fuller

This is how I learned about the existence of FEniCSx. Here is a quote from this article

“The best environment to install and use FEniCSx is the Linux environment, for example Ubuntu, where FEniCSx can be installed via the Personal Package Archives (PPA), via Spack and via Anaconda. We do not have experience working with FEniCSx in macOS, which is Unix-based, and the github repository does not list any challenges. One may therefore assume that Anaconda distribution would work in macOS. The shortcomings in installing FEniCSx in Windows could limit usability of FEniCSx because the Linux environment can have a learning curve, and that macOS requires use of a Mac computer.”

I believe that making FEniCSx directly accessible on Windows could greatly increase the number of potential users. At this point in time research in the area of lithium-ion batteries is exploding throughout the world, and I believe that FEniCSx could play a significant role in solving these problems.


We appreciate the feedback, and we agree that it would be desirable to have a simpler way of installing FEniCSx on Windows.

Concerning making PETSc optional, there has been recent progress at Make PETSc optional by chrisrichardson · Pull Request #3123 · FEniCS/dolfinx · GitHub

However, overall, we don’t have an ETA to be announced.

I am only now learning how to use FEniCSx, but if I can be of assistance in this goal I would be happy to help work on it. In particular, if you would like to try different proposed solutions and need someone with Windows to try them out, that might be something that I could do.

That is a nice feedback. However, FEniCS project should not work like a company IMO, as if trying to maximize its potential users (customers in company).

I honestly struggled when I first exposed to FEniCSx, it requires lots of effort but it does worth. It should not be forgotten that It is an open-source project and many contributions are done by volunteers.

Whereas many policies of Windows and its products seems contradicting with the open-source philosophy.

Removing PETSc backend from FEniCSx and making it optional should also require lots of effort. Instead, I would spend that effort to push the core of the FEniCSx further.

If you really want to contribute, you can prepare tutorials for WSL usage of FEniCSx which could still address Windows users.

We are not that far away from having it optional for conda builds. There are a few kinks to iron out, but we’ll get there eventually.

1 Like

In the thread “Installing FEniCSx on Windows 11” I have tried to document my experience in doing this so that others might get the job done more easily. That said, I am not an expert on Windows software, and my advice is more in the spirit of “this didn’t work for me, but this did”.

1 Like

My experience with running FEniCSx on Windows 11 with WSL2 is rather nightmarish. The only platform I was able to find that runs is VS Code. Spyder would be preferred but it is too buggy in WSL2. That said, even VS Code seems to be having problems. There are several options to run python programs
Each one produces different results when running the same python program. Some of them won’t show plots, but others do show plots. Some of them won’t write to external files but others do. I have spent massive amounts of time trying to set correct options in VS Code without success.

If anyone has expertise in this, I would be most grateful if you could help me. I realize this is not FEniCSx related, but then again, it is. On the other hand, apparently we are close to having a version of FEniCSx that runs on Windows. I would like to try it. I have FEniCSx codes up and running, but dream of running them in a stable environment, in contrast to what I have now.

We are getting much closer to a native windows build, see for instance Windows build by jhale · Pull Request #819 · FEniCS/basix · GitHub and Port DOLFINx to Windows by jhale · Pull Request #3198 · FEniCS/dolfinx · GitHub . No ETA yet on when they will be included in a release.

From your links I note
“Note that PETSc and petsc4py are not available on Windows.”
Is this going to be the case for the initial release?

Yes. PETSc is not easily supported on native, windows: Installing PETSc On Microsoft Windows — PETSc v3.21.2-236-g0062f871983 documentation
so providing binaries for it (for instance through conda), will be very hard (if not impossible). Maybe @minrk can provide some more context as to the feasibility.

I presume that dolfinx.fem.petsc will be available on windows. Is that correct? The other libraries (if I understand correctly) come from PETscpy (PETsc for python), and these are the ones that will not be on Windows. Since I am new to all of this, can you explain to me the circumstances in which I might need PETscpy in addition to the routines from dolfinx.fem.petsc?

I am not yet in a position where parallelizability is important for me, but that may change. Here are my laptop specs

Are there things I might like to do to parallelize my computations using PETscpy that I would lose on Windows?

dolfinx.fem.petsc is a convenience wrapper around PETSc4py objects, so it will not be present at an initial release.

For now parallelization with PETSc is not something we can support on windows, mainly due to how hard it is to package PETSc for a windows system.

This might change in the future.

Please note that there are other alternatives for running on windows, for instance with Windows Subsystem for Linux as the backend of a docker image (that easily integrates into vscode).

If you connect vscode to the docker container, you should not see multiple options for what python to execute code with.

“Please note that there are other alternatives for running on windows, for instance with Windows Subsystem for Linux as the backend of a docker image (that easily integrates into vscode).”

As I have noted above on this thread, my experience with WSL and vscode is very unsatisfactory. This is why I hope to change directly to Windows. I wish I had contact to someone who has succeeded in using FEniCSx with these tools who has overcome the problems I outlined above. I am starting to suspect that such people may not exist.

I currently use the procedures NonlinearProblem and NewtonSolver in dolfinx.fem.petsc. If these are not available, are there alternatives that will be useable in Windows?

Have you tried with docker and attaching the kernel to the vscode instance?

This has worked for me on Windows before (it has been a while since I did this though).

Not at the time of introduction of dolfinx to Windows. I do not think the idea is to find a petsc replacement for Windows, but rather have an alternative for those who want to use Windows for teaching etc.

Note that there is no open source mpi implementation with modern features (ie all mpi 3 features), which makes it hard to guarantee long term support for Windows.

1 Like

I am a Win 11 user and use the conda installation of FEniCSx in WSL2 on a daily basis. I wish I could use pycharm but vscode works fine for me in this arrangement. I don’t use the menu choices though - ipython REPL for running python scripts or the notebooks directly. All normal plot features work for me. For advanced ones (for instance copying figures directly with Ctrl+C), I never tried installing better backends to avoid bloating my wsl installation.

Since this is not a FEniCS issue, I am unsure if further conversation will be encouraged here. If you think that my way of working could be acceptable then feel free to follow up in messages.

We now have a highly experimental native Windows build using conda:

It does not include PETSc, as PETSc does not support Windows. We are currently experimenting with using pyamg for serial preconditioning and will look at interfacing a sparse LU solver directly in the future.

You can test the beta version with Windows, as described in:

I am somewhat confused about how to solve problems without PETsc or MPI. Could someone perhaps post examples of the tutorials for solving, e.g., the potential problem and a nonlinear potential problem without these routines?

There is MPI support (through Intel MPI, which is closed source).

For non-linear problems, you would have to write your own newton solver, similar to:
Custom Newton solvers — FEniCSx tutorial but using dolfinx.fem.assemble_* instead of dolfinx.fem.petsc.assemble_*, and fetch the matrix into a csr format, and use for instance scipy to solve the arrising linear system.
See for instance: dolfinx/python/demo/ at 37e078cf0d6a3a1f691968eb42e4042496a2a6d5 · FEniCS/dolfinx · GitHub

Note that the native Windows is experimental.