Error in Fenicsx Tutorial?

Dear Mr. Dokken,

for my thesis I want to develop a script based on your example for hyperelasticity. Before modifying, I just wanted to make sure that everything works properly and copied all the elements of the example notebook without any manipulation into a .py file and ran this. Thereby, I got the error message

$ /usr/bin/python3 hyperelasticity.py
Traceback (most recent call last):
  File "/home/marco/Schreibtisch/Code
/Kernproblem/hyperelasticity.py", line 29, in <module>
    left_dofs = fem.locate_dofs_topological(V, facet_tag.dim, facet_tag.find(1))
AttributeError: 'MeshTagsMetaClass' object has no attribute 'find'

That means that I cannot run your script as given on your example page. Could that depend on something I did not consider?

Some further information:

$ /usr/bin/python3 --version
Python 3.10.4

$ fenics-version 
2019.2.0.dev0

$ dolfin-version 
2019.2.0.dev0

Unfortunately, I could only request the versions of dolfin and fenics, not dolfinx and fenicsx as there exists no such command to request their versions.

In the hope that you can help me understand the problem
Best regards
Marco

Note: I wasn’t allowed to post the link to your example in that post. So, I send it here:

https://jorgensd.github.io/dolfinx-tutorial/chapter2/hyperelasticity.html

To Get the dolfinx version run the following:

python3 -c "import dolfinx;print(dolfinx.__version__, dolfinx.git_commit_hash)"

The result of the dolfinx version is:

$ /usr/bin/python3 -c "import dolfinx;print(dolfinx.__version__, dolfinx.git_commit_hash)"
0.4.1 unknown

Are you able to see a problem there?

The tutorial is almost up to date with main, which is at 0.4.2.0. If you want to use the stable release, consider the notebooks at: GitHub - jorgensd/dolfinx-tutorial at v0.4.0

I tried that one, with the same error. My dolfin doesn’t know the facet_tag.find(1) command. I searched for a dolfinx update on apt, but to no avail. I can’t update it. How am I able to get that working?

The find command was exposed to the Python layer after the 0.4.1 release. As indicated in my link, you would have to use: facet_tag.indices[facet_tag.values==1]
as shown in: dolfinx-tutorial/hyperelasticity.ipynb at v0.4.0 · jorgensd/dolfinx-tutorial · GitHub

That helps! I am sorry I thought you mean that the .py-file and the notebook in said directory are equal and since I cannot use jupyter with dolfinx, I tend to use the .py files. I am sorry for that misunderstanding on my part.

Thank you so much for helping!

I have a similar problem with gmshio, once a tutorial case is run.
The gmsh-api & gmsh are properly (I assume) installed. Both can be imported without any error.
Despite the following error is received;

NameError: name 'gmshio' is not defined. Did you mean: 'gmsh'?

On my laptop a relatively recent release of dolfinx is installed.

python3 -c "import dolfinx;print(dolfinx.__version__, dolfinx.git_commit_hash)"
0.6.0 ubuntu

It seems to work once it is imported directly from dolfinx, my bad

import dolfinx
import gmsh
import gmsh_api
from dolfinx.io import gmshio