Plotting data with Paraview
Boovysa, Milano, 2020.
This page is in the Junk directory! Make sure to check some better material on the MAIN PAGE!
That's a very trivial page, but I wish I knew this trick before.
Do you ever need to plot 3D data fields, extract stuff, do contours etc?
ParaView is a great option for that. And the best thing is: you don't need to use VTK!
Indeed, the simplest way is producing a CSV file containing a bunch of points and the fields that you wish to plot
at these points.
We'll consider here two options:
- Structured data;
- Unstructured data.
The simplest option is using a set of equally spaced points, in 3 dimensions.
Write them in a CSV file with the following syntax (in the example, the first line is made by labels, then you have x,y,z,
coordinates and then the data fields that you need):
Then you do the following:
This strategy is pretty fast and you can load 1GB of data in a matter of a couple minutes (as of 2020, on an average laptop).
Check out an example result here, of a contour from a data field:
- Open the CSV file with ParaView;
- Go to filters and select Table to Structured Grid;
- Select for X,Y,Z the relevant columns, sorted by label;
- Fill the "Whole Extent" fields: if your x,y,z vectors will be 100 elements long, say for the Whole Extent "0" to "99". Click Apply;
- Now you need to plot the result (it may not plot automatically): split the screen with the small icon at the top right, create a Render view and then
enable the "eye" in the TableToStructuredGrid object, in the left menu.
It is possible to do similar operations using non-structured meshes, aka a bunch of kind of random points in space.
To do that, again you can feed the points in CSV format and then you ask ParaView to run a 3D Delaunay triangulation algorithm.
This will take a bit of time if the dataset is very large and you need to create many points.
You can click here to download an example file.
The operations are:
Here's a plot for the field in the example.
- Open the CSV file with ParaView, and click Apply.
- Go to filters and select (check under "alphabetical order") TableToPoints. Set the X,Y,Z point coordinates to the proper columns. Then click Apply.
- Finally, go to filters again and run Delaunay3D. Click Apply.
- Enjoy the dataset.
-Stefano -> BACK TO THE HOMEPAGE <-