Add commands to install FEniCSs on Windows on the home website

https://fenicsproject.org/download/

Please help add commands to install on Windows, otherwise, people would try those commands for MacOS which does not work for Windows.

According to Github README, the latest commands to install on Windows are:

conda create -n fenicsx-env
conda activate fenicsx-env
conda install -c minrk/label/fenics-windows -c conda-forge fenics-dolfinx=0.9.0.dev

Once the 0.9 release is out, where windows is supported (without PETSc), the instructions will be added to the webpage.

Hi community !

I see the availability of FEniCSx on windows machine is very close to be completely accomplished !
In few weeks, at the ASSA autumn school in Eindhoven, some professors (including myself) from KTH Sweden will present FEniCSx implementations for very simple case of FE method applications. And next, there is the desire to bring FEniCSx in our lectures and tutorial at KTH university. So I’m in charge of building a procedure for the student to download FEniCSx according to their system (MacOS, Linux, Windows…). This whole procedure might involve non FEniCSx things like Docker for instance. I think the most general procedure will involve conda installation, so my question is the following : Do you think 0.9 version will be released before the end of October ?

All the best,
Pierre.

Yes, I do believe so.
Note that Dolfinx on windows will not have PETSC support, so for teaching you would rely on scipy for solving the problems in Python (and thus mainly serial problems).

Everything in dolfinx itself will work in parallel, but there is a lack of MPI compatible solvers on windows…

1 Like

That’s what I understood yup… But as it will be very easy case, I think it might be enough. Thanks for the quick reply!

Pierre.

Shameless off-topic self-advertising: for my teaching needs, and for the teaching needs of several colleagues, I use https://fem-on-colab.github.io/ . Using Colab is definitely not the perfect solution, but for us is a good compromise, especially for its ease of usability/installation.

2 Likes

I think this is exactly what I need, thank you very much. However, I’m facing a simple problem. That is not realted to this topic anymore, I can create a new topic on the discourse and copy paste the following :

I’ve implemented a simple 1D helmholtz problem with the fem on collab strategy, with boundary condition. Even if I’ve installed the Dolfinx version from the complex branch, I have a message error saying :

---------------------------------------------------------------------------
ArityMismatch                             Traceback (most recent call last)
<ipython-input-6-9c15c347e209> in <cell line: 46>()
     44 
     45 # Solving the linear system
---> 46 problem = LinearProblem(a, L, petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
     47 p_solution = problem.solve()
     48 

14 frames
/usr/local/lib/python3.10/dist-packages/ufl/algorithms/check_arities.py in check_integrand_arity(expr, arguments, complex_mode)
    203         for arg, conj in arg_tuples:
    204             if arg.number() == 0 and not conj:
--> 205                 raise ArityMismatch("Failure to conjugate test function in complex Form")
    206             elif arg.number() > 0 and conj:
    207                 raise ArityMismatch(f"Argument {arg} is spuriously conjugated in complex Form")

ArityMismatch: Failure to conjugate test function in complex Form

Here it’s my code, I don’t think my FE code is the problem but more probably from installation. So I give here the first notebook collab cell that might donwload the complex dolfinx branch, and then my FE code:
[1]

import os
arch = os.getenv("ARGS", "complex")

try:
    import google.colab  # noqa: F401
except ImportError:
    import ufl
    import dolfinx
else:
    try:
        import ufl
        import dolfinx
    except ImportError:
        if arch != "complex":
            !wget "https://fem-on-colab.github.io/releases/fenicsx-install-real.sh" -O "/tmp/fenicsx-install.sh" && bash "/tmp/fenicsx-install.sh"
        else:
            !wget "https://fem-on-colab.github.io/releases/fenicsx-install-complex.sh" -O "/tmp/fenicsx-install.sh" && bash "/tmp/fenicsx-install.sh"
        import ufl
        import dolfinx

[2]

import numpy as np
import dolfinx
from mpi4py import MPI
from petsc4py import PETSc
from ufl import TrialFunction, TestFunction, dx, grad, inner, div, ds, as_vector, Measure
from basix.ufl import element
from dolfinx.fem import Function, FunctionSpace, assemble_scalar, form, functionspace
from dolfinx.fem.petsc import LinearProblem
from dolfinx.mesh import create_interval
from dolfinx.io import XDMFFile

# Problem parameters
Lf = 1.0  # Domain length (1 meter)
rho_0 = 1.21  # Volumic masse of air (kg/m^3)
c = 343.0  # Speed of sound in the air (m/s)
omega = 2 * np.pi * 1000  # Angular frequency 
k = omega / c  # Wave number
Z_n = rho_0 * c # Acoustic impedance

# 1D mesh
mesh = create_interval(MPI.COMM_WORLD, 100, [0, Lf])

# Space function
Ve = element("Lagrange", mesh.basix_cell(), 2)
V = functionspace(mesh, ("Lagrange", 2))

# Test and Trial functions
p = TrialFunction(V)
v = TestFunction(V)

# Variational formulation
a = inner(grad(p), grad(v)) * dx - k**2 * inner(p, v) * dx

# Source term
f = Function(V)
L = inner(f, v) * dx

# Boundary condition : Impedance x = Lf Neuman condition x = 0
ds_boundary = Measure("ds", domain=mesh, subdomain_data=None)
n = as_vector((1,))  

a += (1j * omega * rho_0 / Z_n) * p * v * ds_boundary(1)  
L += omega**2 * rho_0 * 1.0 * v * ds_boundary(0)  

# Solving the linear system
problem = LinearProblem(a, L, petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
p_solution = problem.solve()

# Save + Visualization
with XDMFFile(MPI.COMM_WORLD, "solution_helmholtz.xdmf", "w") as xdmf:
    xdmf.write_mesh(mesh)
    xdmf.write_function(p_solution)

try:
    import pyvista
    from dolfinx.plot import create_vtk_mesh
    topology, cell_types, x = create_vtk_mesh(mesh)
    grid = pyvista.UnstructuredGrid(topology, cell_types, x)
    grid["Solution"] = p_solution.x.array.real
    plotter = pyvista.Plotter()
    plotter.add_mesh(grid, show_edges=True)
    plotter.show()
except ImportError:
    pass

Thanks a lot,
Pierre

When working in complex mode, one has to pay particular attention to the inner products, as UFL expects that the test function is always conjugated (this happens automatically when using inner, as inner(a, b)=ufl.dot(a, ufl.conj(b)).

See for instance: The Poisson problem with complex numbers — FEniCSx tutorial

You’re right I’ve been a bit fast and didn’t use the inner product in the boundary term, here it is:

a += inner((1j * omega * rho_0 / Z_n) * p,  v) * ds_boundary(1)  
L += inner(omega**2 * rho_0 * 1.0, v) * ds_boundary(0) 

My code then presents new errors, but I’ll work on it on my own and open a new topic if it’s needed.

Thanks a lot for the help, once again