VTK in IJulia / Visualizing Ferrite Results

I am looking for a way to open/visualize VTK files generated by Ferrite.jl, ideally in a Jupyter notebook but any other suggestions will be welcome. VTKView seems abandoned and DashVTK just seems to have vanished. Is there any way to do this reasonably conveniently?

I just want to visualize some basic finite element solutions for a course. I don’t need sophisticated visualization capabilities. If there is another way avoiding VTK I’ll be equally happy.

You are aware of Paraview?

Yes. Sorry I wasn’t precise. I hoped there would be a way to control the visualisation from the notebook and show it in the notebook. If paraview can do that then I didn’t know that.

No, it cannot display in the notebook. But it can be started from the notebook.
@j-fu at one point was working on a VTK display package. That might be an option.

Thabks. That package seems dead for many years.

Perhaps GitHub - j-fu/GridVisualize.jl?

1 Like

There’s also PyVista, I’m not sure if PyCall will be able to wrap this within a notebook, but it’s worth a shot.

1 Like

You can load the VTK file with GeoIO.jl and then visualize it with Makie.jl using the recipes provided by the GeoStats.jl framework. Check Chapter 2 of the GDSJL book:

https://juliaearth.github.io/geospatial-data-science-with-julia

4 Likes

I don’t think that’s true. Check DashVtk.jl is ready for action! - Dash Julia - Plotly Community Forum

There’s no vtk support so far, but maybe this package does the trick for you: GitHub - Ferrite-FEM/FerriteViz.jl: Plot your Ferrite.jl data

2 Likes

VTKView is what I tried to develop around vtkfig, a c++ wrapper for vtk, but at that time I was not able to get it running on non-linux - would need a full vtk (2000 files) binary build for windows and mac. It wouldn’t be notebook compatible anyway, because it opens its own window (unless one figures out how to embed X windows into Jupyter etc…)

In GridVisualize.jl I provide visualization on 1D/2D/3D grids with various backends including Makie and PlutoVista. PlutoVista is made for Pluto notebooks and uses vtk.js for 3D and provides some interactive rotating and zooming. You can use it directly, or through GridVisualize.

The Makie stuff will probably work in Jupyter, but PlutoVista defintively not.

I use Pluto a lot for teaching - it is easy to install and feedback from students is generally positive.

1 Like

I see - I was confused by the name of the repo. Thanks for pointing it out. I’ll try it.

I actually don’t care about VTK - directly visualizing Ferrite output will be great. Thanks for the suggestion.

Many thanks for the explanations. I’ll be sure to try your packages. While I like Pluto, I generally prefer Jupyter for teaching - the interactive execution of code somehow feels more natural in that context. I’m happy to learn but but it’s maybe a discussion for another thread how to correctly use Pluto for teaching.

Thanks for pointing that out. I was unaware of it. It is maybe not idea yet (plots inside a notebook??) but I will try to work with this for a while.

Sorry, I don’t understand the question. You should be able to use it inside a notebook. Either use inline plotting of the GLMakie backend or use the WGLMakie backend for interactivity. I used the latter in teaching (will be the same kind of plot windows as in the docs of FerriteViz). You can handle the returned plotting objects like any other Makie plotting objects.

  • WGLMakie will always plot in a separate browser window
  • GLMakie + inline : the plots are enourmous and after going through the Makie layout tutorial I am still unable to fix this. Nothing I do changes the size.

There may be an easy solution but I am not a Makie user and there is nothing immediate that I can find.

With WGLMakie:

┌ Warning: 
│     Makie.inline!(do_inline) was set to true, but we didn't detect a display that can show the plot,
│     so we aren't inlining the plot and try to show the plot in a window.
│     If this wasn't set on purpose, call `Makie.inline!()` to restore the default.
└ @ Makie /Users/ortner/.julia/packages/Makie/RgxaV/src/display.jl:152

EDIT: the error/warning was caused by using VSCode. If I use Jupyter notebooks directly then WGLmakie seems to work ok. Thanks for pointing to this.

1 Like

I think you can fix this by specifying

fig = Figure(size = (800, 600))

and then use the fig object to create an axis and plot into the axis in the “canonical Makie way” , i.e. by using a plotting function with bang and provide the axis as first argument, like this example: Advanced Topics · FerriteViz

I think you can also fix this within VSCode by tweaking the inline bool. At least it was possible some time ago to have a WGLMakie plot in the VSCode plot window. I’m not sure about the current status, since I don’t use VSCode.

If you encounter any problems regarding FerriteViz please let me know.

Thank you! I’ll have to try this out and will get back to you if I struggle.