Error while creating simple mesh

Hello there,

I’m trying to switch from fenics to fenicsx, but I’m struggling with a few things. I installed fenicsx via pip install on Ubuntu and currently I’m just trying to create a simple mesh, but even that won’t work.

A minimal code sample would be

from dolfinx import mesh as dfxmesh
from mpi4py import MPI

N = 50
domain = dfxmesh.create_unit_square(MPI.COMM_WORLD, N, N, dfxmesh.CellType.quadrilateral)

This produces the error message

(0): ERROR: stratParserParse: invalid strategy string, before "25000,sep=m{vert=10000,asc=b{bnd=(d{pass=40}|)q{strat=f}x{bal=0,025000},org=q{strat=f}x{bal=0,025000}},low=q{strat=(m{vert=80,low=h{pass=10}f{bal=0,025000,move=80},asc=b{bnd=(d{pass=40}|)f{bal=0,025000,move=80},org=f{bal=0,025000,move=80}}}|m{vert=80,low=h{pass=10}f{bal=0,025000,move=80},asc=b{bnd=(d{pass=40}|)f{bal=0,025000,move=80},org=f{bal=0,025000,move=80}}})},seq=q{strat=(m{vert=80,low=h{pass=10}f{bal=0,025000,move=80},asc=b{bnd=(d{pass=40}|)f{bal=0,025000,move=80},org=f{bal=0,025000,move=80}}}|m{vert=80,low=h{pass=10}f{bal=0,025000,move=80},asc=b{bnd=(d{pass=40}|)f{bal=0,025000,move=80},org=f{bal=0,025000,move=80}}})}},seq=r{bal=0,025000,poli=S,sep=(m{vert=80,low=h{pass=10}f{bal=0,025000,move=80},asc=b{bnd=(d{pass=40}|)f{bal=0,025000,move=80},org=f{bal=0,025000,move=80}}}|m{vert=80,low=h{pass=10}f{bal=0,025000,move=80},asc=b{bnd=(d{pass=40}|)f{bal=0,025000,move=80},org=f{bal=0,025000,move=80}}})}}"
(0): ERROR: SCOTCH_stratDgraphMap: error in parallel mapping strategy
(0): ERROR: SCOTCH_stratDgraphMapBuild: error in parallel mapping strategy
Traceback (most recent call last):

  File ~/.local/lib/python3.8/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File ~/<path>/test_fenicsx.py:28
    domain = dfxmesh.create_unit_square(MPI.COMM_WORLD, N, N, dfxmesh.CellType.quadrilateral)

  File /usr/lib/petsc/lib/python3/dist-packages/dolfinx/mesh.py:393 in create_unit_square
    return create_rectangle(comm, [np.array([0.0, 0.0]),

  File /usr/lib/petsc/lib/python3/dist-packages/dolfinx/mesh.py:369 in create_rectangle
    mesh = _cpp.mesh.create_rectangle(comm, points, n, cell_type, ghost_mode, partitioner, diagonal)

RuntimeError: Error calling SCOTCH_stratDgraphMapBuild

Do I need to maybe install something else or update something? To me, it sounds like it is a C++ problem, but unfortunately I’m not really familiar with C++.

You cannot install FEniCSx with just pip, see

Thank you for your answer. I tried all 3 suggested variants (for Ubuntu) but nothing changed. I still get the same error message.

Well, could you pick one (say conda), and show the output of conda list?
Also show the output of which python3 and after that run your Python script and add the output here?

Thanks for your help.
I somehow messed up and had to set up my computer from scratch…

This time the instructions from the github installation website worked.

Hi, I’m having the same error with a very simple script for a Linux installation using the guidelines, specifically using the command apt-get install fenicsx.

The script is

from dolfinx import fem, io, mesh, plot
from mpi4py import MPI

# Create mesh
msh = mesh.create_rectangle(comm=MPI.COMM_WORLD, points=((0.0, 0.0), (2.0, 1.0)), n=(32, 16), cell_type=mesh.CellType.triangle)

For the question of @dokken about Python i’m using the one in /usr/bin/python3 and the version is 3.11.2

If possible I’d like to avoid the installation with conda, thanks!

Try changing the order of your imports:

to

from mpi4py import MPI
from dolfinx import fem, io, mesh, plot

This is an issue that has been fixed on the main branch

Thanks for your reply, I’ve tried and unfortunately still the same error

Could you make a minimal reproducible example in a docker file? If I cannot reproduce the error, it is hard to give any guidance