Multiphenicsx DofMapRestriction not behaving as previously

I just updated dolfinx and multiphenicsx today and it seems multiphenicsx.fem.DofMapRestriction no longer works for me as it used to. I use the same construction as in the Lagrange multiplier interface tutorial. In fact, I get the same error running the above tutorial on my installation (I ommitted the viskex lines as I don’t have OpenGL on the cluster where dolfinx is installed). It is as follows

Traceback (most recent call last):
  File "/tmp_user/sator/hmmak/fenicsx-scripts/reordered_3D/test_mphx.py", line 60, in <module>
    restriction_V1_Omega1 = multiphenicsx.fem.DofMapRestriction(V1.dofmap, dofs_V1_Omega1)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp_user/sator/hmmak/spack/var/spack/environments/rlfx/.spack-env/view/lib/python3.11/site-packages/multiphenicsx/fem/dofmap_restriction.py", line 31, in __init__
    super().__init__(_dofmap, restriction)
TypeError: __init__(): incompatible function arguments. The following argument types are supported:
    1. __init__(self, dofmap: dolfinx::fem::DofMap, restriction: list[int]) -> None

Invoked with types: multiphenicsx.fem.dofmap_restriction.DofMapRestriction, dolfinx.cpp.fem.DofMap, ndarray

Did the use of DofMapRestriction change completely without an edit of this tutorial? If so, how do I achieve what this tutorial does?

Which version of dolfinx are you using? Since you installed via spack, it’s probably to the development version. Please double check that you are using a compatible multiphenicsx version, see Installation — multiphenicsx

The errors is complaining about a list vs np.array, which is one of the changes that were required when dolfinx (and thus multiphenicsx) moved from pybind11 to nanobind. If you installed a 0.7.x dolfinx release but are using multiphenicsx from main, errors like that one would probably pop up in serveral places.

As you mentioned I installed via spack with dolfinx@main. I followed the instructions here for the development version of multiphenicsx. I even tried explicitly making the second input into a list as multiphenicsx.fem.DofMapRestriction(V1.dofmap, list(dofs_V1_Omega1)) which gave the same error except now with

Invoked with types: multiphenicsx.fem.dofmap_restriction.DofMapRestriction, dolfinx.cpp.fem.DofMap, list

Nonetheless I uninstalled multiphenicsx and re-cloned a fresh multiphenicsx. I then re-installed as you suggested here, and it seems all is well. It seems the fact that I used different compilers to install dolfinx and multiphenicsx messed with the compatibility perhaps of dolfinx.cpp.fem.DofMap.

Oh yeah, that is risky business, especially when wrapping with pybind11 or nanobind :wink:

1 Like