Error when plotting mesh with viskex

Good afternoon,
I am trying to run the tutorial Tutorial 06, case 5: Stokes problem with distributed control , everything works fine except for the plots with viskex. Indeed, after defining the mesh, when i run the following cell:

viskex.dolfinx.plot_mesh(mesh)

I get the following error:

INFO:wslink.backends.aiohttp:awaiting runner setup
INFO:wslink.backends.aiohttp:awaiting site startup
INFO:wslink.backends.aiohttp:Print WSLINK_READY_MSG
INFO:wslink.backends.aiohttp:Schedule auto shutdown with timout 0
INFO:wslink.backends.aiohttp:awaiting running future
INFO:trame_client.widgets.core:js_key = id
INFO:trame_client.widgets.core:js_key = id
INFO:trame_client.widgets.core:js_key = class
INFO:trame_client.widgets.core:js_key = fluid
INFO:trame_client.widgets.core:js_key = class
INFO:trame_client.widgets.core:before: class = { 'rounded-circle': !P_0x7f481870d4f0_0_show_ui }
ERROR:trame_client.widgets.core:'NoneType' object has no attribute 'translate_js_expression'

Could you help me understand why?
Thank you.

The issue is surely in pyvista.

Does

import pyvista

mesh = pyvista.examples.download_st_helens().warp_by_scalar()

plotter = pyvista.Plotter(notebook=True)
plotter.add_mesh(mesh)
plotter.show(jupyter_backend="client", return_viewer=True)

work? What if you change "client" to "server" or "html"?

Everytime I try to use pyvista, the kernel of my jupyter notebook dies. I get the message:

Kernel Restarting
The kernel for tutorial_7a_stokes_dirichlet_control.ipynb appears to have died. It will restart automatically.

Also had this problem before, indeed I never use pyvista but usually export files and visualize them in Paraview, but would be very useful for me to solve this issue.

After downloading some libraries I managed not to make the kernel dies, now with the previous code I get a blank plot with a colorbar “Elevation”.
However, if I try to plot the mesh of the problem with pyvista, I get:

NotImplementedError: Unable to wrap (<class 'dolfinx.mesh.Mesh'>) into a pyvista type.

There is no point in keep trying with dolfinx / viskex. I’ve given you a simpler code to run. If you can’t get that to run correctly in your notebook, then there is no way you’ll be able to display a dolfinx mesh.

Thank you for your answer. I saw online that other people had the same problem if importing dolfinx before pyvista, indeed adding at the beginning of the notebook

import pyvista
pyvista.start_xvfb()

fixed the issue. However with your simpler code I get a blank plot with just a colorbar, I dont know it is the expected result, and then when I try to plot the dolfinx mesh I get the error I reported above.

We need more info on you are running pyvista at this point. Which OS? Is it through docker or installed directly on the OS? How was pyvista installed?

I have a Windows 11 OS, therefore I installed Ubuntu with WSL2, then I installed anaconda on Ubuntu and created a fenicsx-env there, not through Docker. Then just installed pyvista on Ubuntu with

pip install pyvista

If you are using chrome, try to do a right click on the jupyter lab page and open the console with the “Inspect” menu. Do you see any javascript error, or other issues on the console?

I have the following errors in the console:
Screenshot 2024-02-07 161746
and several warnings:



Screenshot 2024-02-07 161422

Anything helpful here Error displaying widget: model not found -- how to fix this? - #3 by wonderful_world - Widgets - Jupyter Community Forum?

Anyways, try to search with a keyword like “widget model not found” in a search engine, and see if there is anything helpful. The issue is so specific of your installation that it’s very hard to give any guidance without being in front of your screen.

I finally managed to solve the widget issue, uninstalling and re-installing some libraries that were causing a conflict. Now I can correctly see the plot for the simpler code that you provided earlier.
Now, I can also visualize correctly the plots with viskex, I still get this error:

ERROR:trame_client.widgets.core:'NoneType' object has no attribute 'translate_js_expression'

So I guess there is still something wrong with widgets but I correctly see the plots now.
Thank you very much.

I have a similar problem my kernel dies when I tried to execute the tutorial for channel flow

https://jsdokken.com/dolfinx-tutorial/chapter2/ns_code1.html

In specific when I run the command line

if not pyvista.OFF_SCREEN:
    plotter.show()

Checked your post and executed it in the terminal, and it works with “html.”

import pyvista
mesh = pyvista.examples.download_st_helens().warp_by_scalar()
plotter = pyvista.Plotter(notebook=True)
plotter.add_mesh(mesh)
plotter.show(jupyter_backend="html", return_viewer=True)

Do you know what’s happening with my installation or my computer? I am using dolfinx 0.7.3, thanks for your help

Are you running inside a notebook? Could you check what the pyvista jupyter backend is?

No, I am running in conda navigator (spyder)

you may want to double check with the pyvista team if that is actually supported or not.

1 Like