CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   ParaView (http://www.cfd-online.com/Forums/paraview/)
-   -   Ordering XYZ data in Paraview (http://www.cfd-online.com/Forums/paraview/125628-ordering-xyz-data-paraview.html)

ellenvdveer October 28, 2013 06:46

Ordering XYZ data in Paraview
 
Hi all,

I am pretty new to paraview and have a problem in converting my actual structured data into a structured grid. I have a pressure file showing X,Y,Z,P but the X,Y,Z data are not in structured order. I found out how to re-order one column, e.g. X data, but attached to that I need to have my Y and Z data to be sorted from low to high along with the sortedX data.

Does any of you know if Paraview can re-order the Y and Z data for the fixed order of X data? And if yes, how? Would be of great help!

Best,

Ellen

wyldckat November 3, 2013 07:08

Greetings Ellen and welcome to the forum!

If you could provide a small example, it would allow us to try to do some trial-and-error as well and to achieve the same you're trying to do.

Best regards,
Bruno

ellenvdveer November 4, 2013 04:21

Thanks a lot. I just give a very straightforward example. E.g., you load a dataset representing X,Y,Z coordinates in PV which looks like this:

X Y Z
1 2 1
2 3 3
3 2 3
1 3 2
2 1 1
3 1 2
1 1 3
2 2 2
3 3 1

Now, I want it to sort in a structured way so I can convert it into a structured grid, i.e. it should look like this:

X Y Z
1 1 1
1 2 2
1 3 3
2 1 1
2 2 2
2 3 3
3 1 1
3 2 2
3 3 3

meaning that the X coordinates are sorted AND the Y,Z data are sorted within the block of the corresponding X-coordinate.

However, as far as I found out, I am only able to sort one column in Paraview, in this case the X-coordinate, which makes my result look like this:

X Y Z
1 2 1
1 3 2
1 1 3
2 3 3
2 1 1
2 2 2
3 2 3
3 1 2
3 3 1

Problem is that Paraview is not able to translate this into a structured grid. Very sorry if this all sounds a bit vague; it's just pretty hard to explain in words :). Really hope you can help me on this!

Thanks :)

Gaetano November 5, 2013 07:30

How about pre-processing your input file? I'm thinking about multiple sorting:
sort(z) -> sort(y) -> sort(x)

Before pre-processing (your example):
Code:

X        Y        Z
1        2        1
2        3        3
3        2        3
1        3        2
2        1        1
3        1        2
1        1        3
2        2        2
3        3        1

After sort(z):
Code:

X        Y        Z
1        2        1
2        1        1
3        3        1
1        3        2
3        1        2
2        2        2
2        3        3
3        2        3
1        1        3

After sort(y):
Code:

X        Y        Z
2        1        1
3        1        2
1        1        3
1        2        1
2        2        2
3        2        3
3        3        1
1        3        2
2        3        3

After sort(x):
Code:

X        Y        Z
1        1        3
1        2        1
1        3        2
2        1        1
2        2        2
2        3        3
3        1        2
3        2        3
3        3        1

I did this with m$ excel, but it should be straightforward with any software.

Another suggestion would be to create another field by merging the X, Y and Z and order by means of that. With decimal coordinates:
Code:

X        Y        Z
0.704        0.835        0.161
0.202        0.33        0.018
0.466        0.139        0.539
0.438        0.024        0.043
0.057        0.392        0.792
0.189        0.733        0.635
0.127        0.656        0.426
0.32        0.325        0.234
0.783        0.845        0.46

Here the new field is calculated as x*1000^3+y*1000^2+z*1000:
Code:

X        Y        Z        FIELD
0.704        0.835        0.161        704835161
0.202        0.33        0.018        202330018
0.466        0.139        0.539        466139539
0.438        0.024        0.043        438024043
0.057        0.392        0.792        57392792
0.189        0.733        0.635        189733635
0.127        0.656        0.426        127656426
0.32        0.325        0.234        320325234
0.783        0.845        0.46        783845460

After sorting:
Code:

X        Y        Z        FIELD
0.057        0.392        0.792        57392792
0.127        0.656        0.426        127656426
0.189        0.733        0.635        189733635
0.202        0.33        0.018        202330018
0.32        0.325        0.234        320325234
0.438        0.024        0.043        438024043
0.466        0.139        0.539        466139539
0.704        0.835        0.161        704835161
0.783        0.845        0.46        783845460

Which is the same result as sort(z) -> sort(y) -> sort(x)

Hope it helps.

Regards,
Gaetano

ellenvdveer November 5, 2013 08:40

Hi Gaetano,

Thanks for your response. I see what you mean with the pre-processing, but for certain reasons I really want to do the sorting within Paraview if possible.

I tried the sorting sequence you propose but Paraview seems to overwrite previous sorting actions, so the result of sort(z) -> sort(y) -> sort(x) is exactly the same as sort(x) only.

About your second suggestion; I'm not sure if this is a really easy thing to do in Paraview. I will give it a try with programmable Phyton filters, but really hope there is actually an easier way to do so in Paraview. > I tried this using the Calculator filter in Paraview, but this is tricky as there were minor errors in the sorting, leading to a messed up structured grid. I think my values are just to high to use this method (PV cannot handle the 100^3 factor with my numbers).

Thanks, anyway :-)

Ellen

ellenvdveer November 6, 2013 06:20

I'm still not sure how to solve this problem and I'm actually running out of ideas. Hope someone could help me out another moment. Thanks anyways for your comments :).

Gaetano November 7, 2013 19:28

I still think that pre-processing would be the best option. A small script will easily do the work, but you might also get it thanks to a programmable filter as first entry in the pipeline, I guess.
I'm not very experienced in that: let's wait for answers from more skilled users :)

wyldckat November 9, 2013 17:41

Greetings to all!

@Ellen: Gaetano is right. As someone once said: http://en.wikipedia.org/wiki/Perfect..._enemy_of_good
Quote:

perfect is the enemy of the good
It's a looooooooot easier to pre-process the data first and then import it to ParaView.
I've spent over 1h trying to learn how to do this in ParaView with the "Programmable Filter" and it's too much trouble to be bothered by it. It requires so many layers of converting data-types, just to get it sorted...


The simplest is to simply load the CSV data onto a numpy table and then use it to sort the table: http://stackoverflow.com/questions/2...umpy-by-column
Then use the numpy converter and send the data to the vtkTable: http://www.paraview.org/Wiki/ParaVie...ammable_Filter - search for "Mixing VTK and NumPy APIs"
All of this would probably have to be done with a "Programmable Source" instead of a "Programmable Filter". But I'm too tired to spend any more time on this :(

Good luck! Best regards,
Bruno


All times are GMT -4. The time now is 04:47.