Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Importing data into ParaView may be done using several different file types. This page will show you how to use comma separated value files (commonly known as CSV-files).

The main motivation behind this choice is that they can easily be opened and read in either notebook or Excel, making debugging very fast and easy. However, this choice comes with a negative side as well. The main downside is the cumulative size of the data and thus the computational time required to import data into ParaView. Another disadvantage is that all data-processing has to been done inside ParaView, where as by using e.g. VTK-files (Visualization ToolKit files) several operations may be included directly into file from the beginning. Such an operation may be the use and display of ghost cells.


Panel
borderColor#dfe1e5
bgColor#eff9ff
borderWidth2
titlePage content

Table of Contents


Setup

Before beginning, keep in mind that the setup I am about so show you are only one of many possibilities. I will aim to explain my decisions, but I encourage you to play around with it yourself as well.

The CSV-format we will look into is shown below. The example is given for a domain consisting of M x N elements. As the domain size must be specified in ParaView to make the grid, I have included the values of N and M when describing each column. We will later come back to why this is benefitial.

Code Block
languagetext
xN,     yM,     z1,     P,      U,      V       // Strings to described column
x_1,    y_1,    z_1,    P_1,    U_1,    V_1     // Number values
x_2,    y_2,    z_2,    P_2,    U_2,    V_2
.       .       .       .       .       .
.       .       .       .       .       .
x_NM,   y_NM,   z_NM,   P_NM,   U_NM,   V_NM


First of all, the most essential columns are the three first, defining the domain using a 3D coordinate system. The next columns consist of the obtained results, all as scalar values. To include vector results, e.g. velocity, we therefore have to include the velocity components as separate values. In the case above, U and V represents a velocity vector. An important parameter when writing the coordinates is that the x-values has to change faster than the y-values. Otherwise, we will get an error when creating our structured grid. Following is a demostration of how avoid this error.

Code Block
languagetext
  -- Correct --                -- Wrong --
x,      y,      z           x,      y,      z
1,      1,      0           1,      1,      0
2,      1,      0           1,      2,      0
1,      2,      0           2,      1,      0
2,      2,      0           2,      2,      0

Examples

Simple box

Based on my own experience, the fastest way to get known to the setup is to try it out yourself. Let's start with defining the geometry for a 2D-box consisting of 3 x 3 nodes.

Code Block
languagetext
titleexample_1.csv
x3,	y3,	z1
0,	0,	0
1,	0,	0
2,	0,	0
0,	1,	0
1,	1,	0
2,	1,	0
0,	2,	0
1,	2,	0
2,	2,	0

Although our chosen domain is in 2D, the function in ParaView that converts our table to a structured grid requires three coordinates. Effectively, z = 0 is defined for all points. As already mentioned, note that the x-values are the ones changing the fastest. This is to not get any errors when importing into ParaView.

The top row in the example; "x3 y3 z1" is in ParaView only used to describe the column, thus the values below. So, when we later get into ParaView, we will not have to remember which column represented what, but rather just look at the descriptor. The numbers behind the x, y and z is something I picked up from Bailey's great tutorial on ParaView (see ParaView). They simply describe how many points there are in the current direction, thus for our box geometry of 3 x 3 x 1 nodes we get as shown above. This is helpful knowledge when we later are to convert the points to a structured grid.

Lastly, if we have some results we wish to add, simply insert them as an additional column. 

Code Block
languagetext
titleexample_1.csv
x3,	y3,	z1,	P
0,	0,	0,	1
1,	0,	0,	1
2,	0,	0,	1
0,	1,	0,	2
1,	1,	0,	2
2,	1,	0,	2
0,	2,	0,	1.5
1,	2,	0,	1.5
2,	2,	0,	1.5

Exampel file: example_1.csv

More advanced

Although we will now look at a more complex visualization, observe how the setup is pretty much just as simple as in the last example. The task is to visualize the flow around a square cylinder. The domain is 2D and consisting of 256 x 176 nodes. As we obviously don't expect you to calculated this now, we have provided you with some data to work with.

Info

If you like the image below and would like to learn how to make some yourself (hopefully even better), check out our page on Inkscape.

Code Block
languagetext
titleexample_2.csv
x256,	y176,	z1,	P,				U,			V
0,		0,		0,	-0.0112616,		1,			-0.00108238,
1,		0,		0,	-0.0112616,		1,			-0.00216817,
2,		0,		0,	-0.0112615,		1,			-0.00325722,
3,		0,		0,	-0.0112613,		1,			-0.00434934,
4,		0,		0,	-0.0112611,		1,			-0.00544435,
5,		0,		0,	-0.0112607,		1,			-0.00654205,
.		.		.	.				.			.
.		.		.	.				.			.
253,	175,	0,	-7.42356e-05,	1.00768,	0.0270307,
254,	175,	0,	-0.000123269,	1.00802,	0.0272095,
255,	175,	0,	-0.000215282,	1.00844,	0.0272388,

Example file: example_2.csv

Import into ParaView

To import a file into ParaView, click Open or CTRL + O and located your file. To make it a bit more interesting, we will use example_2.csv which is attached in the section above. Then, click Apply, and a table should pop up. Make sure the table is correct, i.e. that the x-values are actually listed in the column named x256, z-coordinates in the column named z1 etc. If your file is not separated by commas, but by e.g. semi-colons, simply change the Field Delimiter Character under Properites (lower left in image below). 

Make points

The easiest way to 



BibTeX Display Table