How to get a vector graphic (like SVG) in dealii?

86 views
Skip to first unread message

Masoud Ahmadi

unread,
Dec 12, 2023, 8:39:31 AM12/12/23
to deal.II User Group
Hello everyone,

I save my results as VTK files using write_vtk.
I have been trying to get a vector graphic (like SVG) to display smooth and nice results.
I tried ParaView, but I think they do not support vector graphics in recent versions.
I also tried to write a Python code for this purpose using vtk and matplotlib libraries. It works almost fine, but when I want to plot the mesh too, there are problems.
I used Triangulation from matplotlib.tri, but it only supports triangles mesh, while my mesh type is quadrilaterals.
So, the question is, what is the best way to get SVG image of a VTK file?

Thanks,
Masoud

Wolfgang Bangerth

unread,
Dec 12, 2023, 7:04:11 PM12/12/23
to dea...@googlegroups.com
Are you asking how to generate a SVG of the solution, or of a mesh? For the
latter, you can use GridOut. For the former, I do not know whether any of the
usual visualization tools support this, but I doubt that it would be useful:
If you have a lot of cells, *any* scalable representation would have an
enormous number of triangles that would not be fun to work with. Just export
things as a PNG with sufficient resolution.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/


Marc Fehling

unread,
Dec 13, 2023, 4:39:05 PM12/13/23
to deal.II User Group
On Tuesday, December 12, 2023 at 6:39:31 AM UTC-7 masou...@gmail.com wrote:
I also tried to write a Python code for this purpose using vtk and matplotlib libraries. It works almost fine, but when I want to plot the mesh too, there are problems.
A while ago I used matplotlib to create vector graphics out of VTK files. As a reference I used this resource:
 
I used Triangulation from matplotlib.tri, but it only supports triangles mesh, while my mesh type is quadrilaterals.

Masoud Ahmadi

unread,
Dec 13, 2023, 7:36:06 PM12/13/23
to deal.II User Group
@WB

Thanks for the reply.
I meant the mesh with the results. Yes, GridOut works perfectly for just mesh, but I want to show the solution too.
Yes, I have already tried and can confirm that it is not fun work as you said.

@Marc
Thanks for the links, I will give them a try.
I had seen the second link, but the problem was with the higher-order nodes.

Regards,
Masoud

Laryssa Abdala

unread,
Dec 14, 2023, 2:08:26 PM12/14/23
to deal.II User Group
Hey Masoud, 

You can open vtk and vtu files using Paraview and export them using "Export Scene". You can find more information here: https://www.paraview.org/Wiki/ParaView/Vector_Graphics_Export

I hope this helps, 
Laryssa

Masoud Ahmadi

unread,
Dec 15, 2023, 7:12:48 AM12/15/23
to deal.II User Group
Hi Laryssa,

Thanks for your reply.
Yes, I use Paraview for postprocessing.
However, apparently It does not support the Vector-graphic images in the recent versions.

Bests,
Masoud
Reply all
Reply to author
Forward
0 new messages