You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »


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.

Page content

How to write the file

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.

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.

  -- 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

Example

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.

example_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. 

example_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




  • No labels