CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > ParaView

Defining Groups of Cells which Share Data

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   April 29, 2014, 08:38
Default Defining Groups of Cells which Share Data
  #1
New Member
 
Alessandro
Join Date: Apr 2014
Location: Italy
Posts: 11
Rep Power: 4
ronwelty is on a distinguished road
These questions are somehow related to my previous thread but I thought creating a new one will help new users experiencing similar problems.
Questions are:
1) Is it possible to define a certain number of triangular cells altogether in one row? "Triangle Strip" could be an option?
2) Is it possible to define groups of triangular cells and let them share some information as displacement? This would save a lot of computation time and reduce files sizes.

Thanks!
ronwelty is offline   Reply With Quote

Old   May 1, 2014, 11:17
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,636
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Alessandro,

One of the tricks to figuring out what formats you can work with is to use ParaView to apply filters that change your original data to something else and then using "File -> Save Data".
The following examples are based on the sample data you provided on the other thread and I used ParaView 3.12.0 (I'm more familiar with this version).

My first example comes from using the "Extract Surface" filter, which extracts the surface mesh and stores it as polygonal data:
Code:
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
POINTS 6 float
0 0 0 1 1 0 0 1 0 
1 0 0 2 1 0 2 0 0 

POLYGONS 4 16
3 0 1 2 
3 0 3 1 
3 3 4 1 
3 3 5 4 

CELL_DATA 4
VECTORS disp float
-1 0 0 -1 0 0 1 0 0 
1 0 0
Essentially it saves you from having to define an array for "CELL_TYPES", as polygons are more generic.


The second example is from using the filters in the following order:
  • "Extract Surface"
    • "Triangle Strips"
      • 1st selection "Append Attributes"
    • 2nd selection "Append Attributes"
  • resulting "Append Attributes"
The result of "Append Attributes" filter is achieved by selecting (use Ctrl+left mouse click) the result from "Triangle Strips" and the result from "Extract Surface", then choose the filter "Append Attributes". This will map the data from the "Extract Surface" to the special polygonal data "Triangle Strips".
This is because the filter "Triangle Strips" won't transfer the cell data.

The resulting file was only achieved with ParaView 3.12.0 and was partially broken. The fixed file is as shown below:
Code:
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
POINTS 6 float
0 0 0 1 1 0 0 1 0 
1 0 0 2 1 0 2 0 0 

TRIANGLE_STRIPS 1 7
6 2 0 1 3 4 5 

CELL_DATA 1
FIELD FieldData 1
disp 3 1 float
-1 0 0
As you can see, the problem with the strips is that a single strip is as good as a single cell.


Now, since in your example case you have 2 strips, of 2 triangles each with the same displacement, then the working example would be this:
Code:
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
POINTS 8 float
-1 0 0 0 1 0 -1 1 0 
0 0 0 2 0 0 3 1 0 
2 1 0 3 0 0 
TRIANGLE_STRIPS 2 10
4 2 0 1 3 
4 6 4 5 7 

CELL_DATA 2
FIELD FieldData 1
disp 3 2 float
-1 0 0 1 0 0
And there you go, the 2 questions answered
But keep in mind that the strips are made up of contiguous triangles!


Then there is an additional detail: you might want to look into doing binary encoding. Attached is an example of the last file, in both ASCII and binary formats. In this example, the file in binary format is worse, but only because the ASCII file only have single digit values and the binary format is using float precision (4 bytes, 32 bits). As soon as you go to at least a textual precision of 4-8 characters (4 or 3 digits or 8-7 digits, depending on the float/double precision), you reach the turning point between binary and ASCII format.

Best regards,
Bruno
Attached Files
File Type: zip test4_with_binary.zip (552 Bytes, 1 views)
wyldckat is offline   Reply With Quote

Old   May 5, 2014, 04:48
Default
  #3
New Member
 
Alessandro
Join Date: Apr 2014
Location: Italy
Posts: 11
Rep Power: 4
ronwelty is on a distinguished road
Wow Bruno, both examples look amazingly easy yet very powerful in terms of reducing file data. Talking about Triangle_strips, do the vertices need to be defined in some specific order (i.e. clockwise) or can i just list all the vertices the strip connects?

Thanks.
ronwelty is offline   Reply With Quote

Old   May 5, 2014, 14:54
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,636
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Alessandro,

Sorry, but I don't know for certain My guess is that the orientation should be consistent, i.e. the direction over which the triangles are recorded.

But I do suggest that you test with these simple examples! Swapping vertices manually should be pretty easy

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   May 22, 2014, 05:52
Default
  #5
New Member
 
Alessandro
Join Date: Apr 2014
Location: Italy
Posts: 11
Rep Power: 4
ronwelty is on a distinguished road
Dear Bruno,

I have been struggling with TRIANGLE_STRIPS polygons. This looks like the only efficient solution for my studies (I can reduce file sizes and calculation times by 1/10 or more). Using this kind of cells/polygons I have around 4,000 entries in the CELL_DATA instead of 80,000 ~ 100,000. Also the displacement vector reduces accordingly.
Main problem is the declaration of the nodes. It has, of course, to be consistent with a certain rule (I think it is something like clock-wise order), but I can't find any example over the internet. Also, dealing with 3D strangely-shaped polygons, I am not sure about the correct order to use.
I am attaching an example showing a single complex shape of those i am using.

This is obtained with my "usual" 600 triangles:


This is obtained with a single triangle_strip:


It is evident that the shape is correct but the triangles are not properly connected (since I did not use any particular order to create the strip). Any idea? This is the code I am using.

Code:
# vtk DataFile Version 4.0 
Unstructured grid legacy vtk file with point scalar data 
ASCII 
DATASET UNSTRUCTURED_GRID 
POINTS 238 float 
410.55 50.46 10.25
398.99 53.10 9.70
401.52 54.79 8.21
405.62 45.13 12.46
402.44 47.41 17.85
398.81 51.00 14.18
402.16 45.47 13.87
404.48 49.61 18.87
410.39 51.96 14.67
401.99 49.92 6.24
408.76 53.99 9.18
402.80 53.25 6.59
407.42 49.64 6.23
404.35 56.27 11.20
398.44 50.20 8.92
408.96 46.58 14.06
409.33 48.40 8.08
404.91 45.51 9.58
411.03 49.01 13.05
406.28 53.22 6.65
399.74 46.23 11.35
398.40 48.32 11.60
408.31 55.23 11.93
400.91 46.08 8.87
400.15 48.85 7.18
405.25 47.79 6.17
406.89 46.45 8.00
401.56 52.07 17.03
402.76 50.26 18.80
399.02 53.83 12.37
402.62 55.84 13.69
404.40 55.08 16.88
408.89 52.47 16.90
407.80 49.16 17.06
399.09 51.00 12.00
405.00 46.36 14.65
399.09 51.00 12.00
402.63 45.67 11.41
405.00 46.36 14.65
399.78 48.10 9.10
402.63 45.67 11.41
400.83 48.02 14.38
400.83 53.98 14.38
403.30 49.86 19.38
399.09 51.00 12.00
407.64 54.95 14.64
407.64 54.95 14.64
401.10 54.90 10.70
409.00 47.67 11.33
400.83 48.02 14.38
405.00 46.36 14.65
399.09 51.00 12.00
403.22 47.44 7.84
400.83 48.02 14.38
399.09 51.00 12.00
403.22 47.44 7.84
400.87 52.18 7.87
400.83 48.02 14.38
400.83 53.98 14.38
408.63 52.21 8.37
400.87 52.18 7.87
400.87 52.18 7.87
400.83 53.98 14.38
400.83 48.02 14.38
409.88 52.22 12.61
404.34 51.00 6.70
408.63 52.21 8.37
400.87 52.18 7.87
407.52 47.22 7.59
401.10 54.90 10.70
400.87 52.18 7.87
409.00 47.67 11.33
407.52 47.22 7.59
409.00 47.67 11.33
405.00 55.01 8.66
399.78 48.10 9.10
399.78 48.10 9.10
405.00 55.01 8.66
403.22 47.44 7.84
403.22 47.44 7.84
405.58 53.34 17.84
401.10 54.90 10.70
410.27 48.66 14.34
410.27 48.66 14.34
405.00 46.36 14.65
400.83 48.02 14.38
403.30 49.86 19.38
409.00 47.67 11.33
402.63 45.67 11.41
403.22 47.44 7.84
400.83 48.02 14.38
400.83 53.98 14.38
405.58 53.34 17.84
409.00 47.67 11.33
405.00 55.01 8.66
403.30 49.86 19.38
405.58 53.34 17.84
410.27 48.66 14.34
400.87 52.18 7.87
409.88 52.22 12.61
404.34 51.00 6.70
408.63 52.21 8.37
405.00 55.01 8.66
405.00 46.36 14.65
409.00 47.67 11.33
410.27 48.66 14.34
404.34 51.00 6.70
409.88 52.22 12.61
407.52 47.22 7.59
409.00 47.67 11.33
405.58 53.34 17.84
401.10 54.90 10.70
400.83 53.98 14.38
405.58 53.34 17.84
405.00 46.36 14.65
409.88 52.22 12.61
401.10 54.90 10.70
402.63 45.67 11.41
407.64 54.95 14.64
403.22 47.44 7.84
405.00 55.01 8.66
405.00 55.01 8.66
404.34 51.00 6.70
407.64 54.95 14.64
410.27 48.66 14.34
408.63 52.21 8.37
402.63 45.67 11.41
409.88 52.22 12.61
408.63 52.21 8.37
407.64 54.95 14.64
399.78 48.10 9.10
399.78 48.10 9.10
404.34 51.00 6.70
407.52 47.22 7.59
407.64 54.95 14.64
405.58 53.34 17.84
399.09 53.29 11.24
407.44 46.01 13.28
402.36 46.43 15.04
399.03 49.33 13.33
403.48 45.08 13.04
403.77 47.84 18.65
398.60 49.16 10.16
406.14 46.50 8.68
401.20 46.06 12.99
399.03 49.33 13.33
402.60 45.85 9.30
401.28 49.59 6.84
399.62 51.00 15.07
401.60 48.63 18.50
399.03 52.67 13.33
403.85 55.50 15.27
406.74 54.58 17.22
409.89 49.61 9.27
398.96 51.72 9.49
402.17 54.01 7.34
403.77 47.84 18.65
399.03 52.67 13.33
401.20 46.06 12.99
405.42 50.03 17.77
410.97 49.75 14.01
401.98 51.77 6.60
410.28 52.52 9.91
401.98 51.77 6.60
408.66 48.92 7.00
402.43 55.73 9.34
399.45 49.79 7.92
407.44 46.01 13.28
408.64 46.80 8.61
410.37 47.93 13.32
404.58 53.35 6.71
400.37 46.30 9.81
399.13 47.37 11.35
408.19 54.65 10.02
405.68 46.68 6.96
406.14 46.50 8.68
402.94 54.33 17.35
404.19 51.46 19.82
399.09 53.29 11.24
404.00 56.09 12.76
403.85 55.50 15.27
408.78 51.02 17.33
408.62 46.80 15.09
410.28 52.52 9.91
400.34 53.89 8.79
400.34 53.89 8.79
405.69 45.28 11.19
399.62 51.00 15.07
402.36 46.43 15.04
409.31 54.37 14.14
403.52 48.75 6.52
407.24 54.25 7.68
402.17 54.01 7.34
406.37 48.42 6.24
404.00 56.09 12.76
398.96 51.72 9.49
410.37 47.93 13.32
408.66 48.92 7.00
402.60 45.85 9.30
410.59 49.43 11.90
407.24 54.25 7.68
399.13 47.37 11.35
398.60 49.16 10.16
406.77 56.11 11.73
400.84 47.47 8.19
399.45 49.79 7.92
403.52 48.75 6.52
405.68 46.68 6.96
402.80 50.78 17.61
400.36 54.97 12.58
410.19 51.68 15.16
408.78 51.02 17.33
410.59 49.43 11.90
402.43 55.73 9.34
403.48 45.08 13.04
401.60 48.63 18.50
404.19 51.46 19.82
410.19 51.68 15.16
401.28 49.59 6.84
408.19 54.65 10.02
404.58 53.35 6.71
406.74 51.72 6.41
406.77 56.11 11.73
408.62 46.80 15.09
409.89 49.61 9.27
405.69 45.28 11.19
410.97 49.75 14.01
406.74 51.72 6.41
409.31 54.37 14.14
400.37 46.30 9.81
400.84 47.47 8.19
406.37 48.42 6.24
408.64 46.80 8.61
402.80 50.78 17.61
400.36 54.97 12.58
402.94 54.33 17.35
406.74 54.58 17.22
405.42 50.03 17.77

CELLS 1 239 
238 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237

CELL_TYPES 1
6

CELL_DATA 1 
VECTORS disp float 
0 0 0
ronwelty is offline   Reply With Quote

Old   May 31, 2014, 15:35
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,636
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Alessandro,

It took me a long while to look into this.
The example file you've provided is the one that is already damaged. I have a few questions:
  1. Is this the one that you're getting from your own application?
  2. Or is it the one created by ParaView, after using the "Triangle Strips" filter?
Because if it's the one gotten from ParaView, then I suggest that you get ParaView 3.12 or 4.1.0 to help you with creating some working examples, because the versions in between might have some issues generating proper VTK files.

I say this because the example file you provided is for an unstructured mesh, which uses cells and not just faces per-se. This means that it will try to close the cells by following a particular point+face order for creating each cell.

While for using triangle strips, you strictly need to use the nomenclature shown in the examples I gave in post #2.

As for the order of the points in the triangles, the description given here should be self-explanatory: http://www.vtk.org/doc/release/5.10/...p.html#details
So, in other words, it's not the orientation in which you defined the points for the triangles that matters, what matters is that the last two points in the previous triangle make up the 2 points in the next triangle, so that only one more point has to be indicated. Keep in mind that this list is the one at "TRIANGLE_STRIPS", which is the list of indexes for the points that make up each triangle.

If you want a source code example on how to reduce a list of polygonal triangles to a triangle strip list, have a look into VTK's own source code, for example here: https://github.com/Kitware/VTK/blob/...ngleFilter.cxx

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 datas on one plot Akuji ParaView 46 December 1, 2013 15:06
studying a valve case mina.basta OpenFOAM 33 August 30, 2013 04:46
defining cells where connecting to one node Asghari FLUENT 0 July 11, 2006 09:36
physical boundary error!! kris CD-adapco 2 August 3, 2005 00:32
Ignore cells on partition boundary Karl FLUENT 7 May 11, 2002 22:12


All times are GMT -4. The time now is 01:29.