Viskex available options, saving screenshot - labeling meshtags

I am using viskex to plot my mesh and was wondering what options are available. First of all, viskex makes plotting mesh tags much easier than using PyVista natively. However, I am unclear how to do what PyVista supports such as:

  • saving screenshot of visualization
  • labeling points in certain region for example adding a label to center of mass of a given mesh tag

Hi @leshinka,
thanks for your interest in viskex.

The tutorials show the usage of viskex.dolfinx.plot_* functions. Those functions create a pyvista plotter, and automatically call show() on it.

If you would like to postprocess the plotter in any way, then use the internal viskex.DolfinxPlotter.plot_mesh(mesh). This returns a pyvista plotter, but does not call show() on it, hence you can process it any way you want.

Small snippet

# assuming the mesh is defined beforehand
# assuming each line of code to be in a separate cell of the notebook

# Cell 1
output1 = viskex.dolfinx.plot_mesh(mesh)
# show the trame widget

# Cell 2
type(output1)
# prints NoneType

# Cell 3
output2 = viskex.DolfinxPlotter.plot_mesh(mesh)
# no trame widget is displayed

# Cell 4
type(output2)
# prints pyvista.plotting.plotter.Plotter
1 Like

This solves my problem. Is there a way to visualize a scalar field obtained from reading an adios2 file obtained in fenicsx?

Once you read it in in dolfinx.fem.Function, you will be able to plot it regardless of where the actual data store in the function comes from.

1 Like