multiphenics / multiphenicsx

multiphenicsx - easy prototyping of multiphysics problems in FEniCSx
https://multiphenics.github.io/
GNU Lesser General Public License v3.0
45 stars 9 forks source link

Error execution Tutorial 03: weak imposition of Dirichlet BCs by a Lagrange multiplier (interface problem) #32

Closed davidcasasnovas closed 1 month ago

davidcasasnovas commented 1 month ago

When I execute the tutorial, rise the following error (installation with dolfinx 0.8):

TypeError Traceback (most recent call last) Cell In[13], line 4 2 dofs_V = np.arange(0, V.dofmap.index_map.size_local + V.dofmap.index_map.num_ghosts) 3 dofs_M_Gamma = dolfinx.fem.locate_dofs_topological(M, boundaries.dim, facets_Gamma) ----> 4 restriction_V = multiphenicsx.fem.DofMapRestriction(V.dofmap, dofs_V) 5 restriction_M_Gamma = multiphenicsx.fem.DofMapRestriction(M.dofmap, dofs_M_Gamma) 6 restriction = [restriction_V, restriction_M_Gamma]

File ~/miniforge3/envs/fenicsx-env/lib/python3.12/site-packages/multiphenicsx/fem/dofmap_restriction.py:31, in DofMapRestriction.init(self, dofmap, restriction) 29 except AttributeError: # pragma: no cover 30 _dofmap = dofmap ---> 31 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

francesco-ballarin commented 1 month ago

Make sure to following the instructions at https://multiphenics.github.io/installing.html , concerning in particular Installation against DOLFINx development version vs Installation against DOLFINx releases.

My suspicion is that you are either installing the development of version of multiphenicsx against a dolfinx release, or that you did install everything correctly but are running the tutorials of the other verison.

davidcasasnovas commented 1 month ago

Thank you Francesco. I've followed the instructons for Installation against DOLFINx releases, but it seems to install dev version. I've the following commands for installation:

cd multiphenicsx DOLFINX_VERSION=$(python3 -c 'import dolfinx; print(dolfinx.version)') git checkout dolfinx-v${DOLFINX_VERSION} if [ -f setup.cfg ]; then python3 -m pip install '.[tutorials]' else python3 -m pip install --check-build-dependencies --no-build-isolation '.[tutorials]' fi

I've also attached the installation's output (log file). Thanks in advance log_install.log

francesco-ballarin commented 1 month ago

Can you tell me which version of nanobind you have installed, and how you did install it? Or even better, prepare a dockerfile that shows how you installed fenicsx with miniforge?

Please make sure to use "```" when posting the code, otherwise it may be difficult to read or format wrongly.

A simple attempt could be to change

restriction_V = multiphenicsx.fem.DofMapRestriction(V.dofmap, dofs_V)

in

restriction_V = multiphenicsx.fem.DofMapRestriction(V.dofmap, dofs_V).tolist()

to force the output type to be a list, since there seems to be a mismatch between the last type (list vs array). I'd be very surprised if that is the issue, considering that it doesn't show up on our CI.

I think it's much more likely that the issue is that somehow you upgraded nanobind. For it to work properly you must have the same nanobind as it was used to build dolfinx on miniforge3. This typically means that if for whatever reason you pip installed a nanobind you'll probably need to uninstall that.

EDIT: the same goes for the compiler. If dolfinx was built on conda with a gcc version and suddenly some other package that you have on your miniforge env force an upgrade of gcc that will typically break nanobind wrapped objects.

francesco-ballarin commented 1 month ago

You may also want to track answers to https://fenicsproject.discourse.group/t/typeerror-init-incompatible-function-arguments/15889 , because it seems like a question with roughly the same issue,, with both questions being asked suspiciously close in time.

davidcasasnovas commented 1 month ago

Hi Francesco,

many thanks for your replies, it's solved the problem. I've done the following:

And now all works! Many thanks

francesco-ballarin commented 1 month ago

Great! The incompatibility with gxx=13 with be fixed soon in conda. Marking this as fixed.