CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [General] Warping Cells by Vectors? (https://www.cfd-online.com/Forums/paraview/134080-warping-cells-vectors.html)

ronwelty April 24, 2014 05:37

Warping Cells by Vectors?
 
I am correctly using and displaying a large number of triangular cells, which constitute a 3D tessellation. I import the data from .vtk files and I also know the displacement of every group of cells (which is made of n triangles). The issue i found in displaying the deformed shape of the thing is: a lot of cells share edges and vertices, so it's impossible to define a point-based vector field to correctly represent the displacement. So i tried to define the disp vector as CELL_DATA but applying the "Warp By Vector" Filter on the so-defined vector is not giving correct results.
Any ideas?

wyldckat April 24, 2014 16:40

Greetings Alessandro,

Sorry, I'm having trouble mentally visualizing the problem you're seeing.
Any chance you can share images of what you're seeing or a small test case we can load in ParaView to check this ourselves?

Best regards,
Bruno

ronwelty April 25, 2014 04:53

Sorry if it was not clear enough. Basically I wanna do this:
imagine I have 2 triangles which share an edge (and so, 2 points). The total number of points in my model will be 4. Now, I want to move triangle 1 to the left, and triangle 2 to the right. The result I want obviously involves the creation of 2 extra-points since the two triangles will not share the edge anymore.
I would imagine I could do this by defining a CELL_DATA vector and applying it to the triangles, but this doesn't look to be working properly.

wyldckat April 25, 2014 14:15

Hi Alessandro,

Ah, then what you're looking for is essentially what's been discussed recently on this thread: http://www.cfd-online.com/Forums/par...ng-stress.html

If you scroll down to post #6, you'll see the solution I figured out today, which is to use an unstructured grid and to repeat the necessary points.

In addition, a way to split the triangles apart, is to apply the filter "Shrink" with a factor of 1.0, which will make sure to duplicate your points and separate the triangles.
The problem is that if you only use the "Shrink" filter, the damage is already done, in the sense that if you had repeated data for the coincident points in the data files, only 1 data value/group will be assigned to each point, therefore the other data value/group for the overlapping point will not be present in ParaView's loaded data.

Best regards,
Bruno

ronwelty April 26, 2014 09:37

Hello Bruno, thanks for the support.
Anyways, duplicating point, at least for me, is not an option. In my analyses I have something like 75,000 points in the mesh and the connectivity is so dense I would need to duplicate every point at least 50 times, which makes it impossible to realize. Also, the size of the files would become just too big (I am working with 5-8 GB of files for a 200 time steps analysis).
Any other idea?
I tried using shrink, but at that point how can I tell ParaView I need to pass the cell_data to the points connecting the cell? The filter "Cell Data to Point Data" isn't doing that properly!

wyldckat April 26, 2014 10:17

Hi Alessandro,

Quote:

Originally Posted by ronwelty (Post 488369)
Anyways, duplicating point, at least for me, is not an option. In my analyses I have something like 75,000 points in the mesh and the connectivity is so dense I would need to duplicate every point at least 50 times, which makes it impossible to realize. Also, the size of the files would become just too big (I am working with 5-8 GB of files for a 200 time steps analysis).

:confused: Welcome to the world of big data!? :D
Because the way I see it, the size of the files should not increase all that much, because technically you're already repeating points in your structured mesh, in the files you already have. The difference is that you're not getting a representation of the repeated data, because it's being discarded during the loading process.


Quote:

Originally Posted by ronwelty (Post 488369)
I tried using shrink, but at that point how can I tell ParaView I need to pass the cell_data to the points connecting the cell?

As I wrote in the previous post, once the data is loaded from the structured data, it's already too late. The VTK library (which ParaView uses) will already have loaded all of the data and discarded the repeated data.

Quote:

Originally Posted by ronwelty (Post 488369)
The filter "Cell Data to Point Data" isn't doing that properly!

In ParaView and for your case of triangle-shaped faces, the "cell data" means that the data is present at the centre of each triangle. If the triangles do actually make up cells, then it's even worse, as the "cell data" is only for the centre of the cells.

Quote:

Originally Posted by ronwelty (Post 488369)
Any other idea?

Yes, but you probably won't like it ;)
If you do use "cell data" to store data at the centre of the cells, where each cell is composed by N triangles... oh, wait this is what you have!...
OK, as I was describing, the "cell data" will actually need to store a massive amount of data to be later redistributed to each point. Essentially, each cell centre would have to store all points of the cell and their respective values. Then you would have to use the "Shrink" filter, followed by the "Programmable Filter" filter in ParaView for coding a Python algorithm that reassigns the data at each centre to each point. In other words, it would sort-of uncompress the data.

Therefore, the way I see it, either you have 5-8GB in data and take 2-5 minutes to uncompress the data for each iteration, or you have 8-11GB in data and take 1 minute to load each iteration.

Best regards,
Bruno

ronwelty April 26, 2014 10:55

Hmmm I do not have any repeated point in the data I load. Why should I? If a node is connected to more than 1 cell I just create 1 point and join all the needed cell. So no, my files are 3GB and contain zero repeated data.
Repeating 50-100 times every node for this reason means a 100ish GB file, which not only takes a little more than 1 minute to be loaded, but also means I can store 8-10 simulations in a TB hard drive and then it's over.
Last, but certainly not least, in some cases it would be very long to compute how many times I should repeat a certain point, and then duplicate it and change ALL my connectivity matrix along. Also, defining displacement as POINT_FATA instead of CELL_DATA would increase file size even more (cell numbers are approx 100 times more than point numbers), so that would probably lead to 200ish GB files?.?

PS: I am not using any structured mesh!!

wyldckat April 26, 2014 13:39

Hi Alessandro,

Sorry about that. I got confused between the topics of this thread and the other thread I mentioned above. Since the issue seemed so similar, I wrongly assumed you were also using a structured mesh :(. And usually on weekends I tend to be a bit more slow... long week, need the rest, so my brain turns off a few features :D

Having a simple test case for opening in ParaView would help, so that I could think a bit better by looking at the data and to deduce a few ideas... and to not loose track of the topic being discussed.

Let me see if I can imagine/visualize this... your mesh is composed of polyhedral cells, all of which are composed by triangle faces. You're storing the displacement data in "cell data" mode. I've re-read your posts and I can't tell for certain how exactly the data is stored for each cell. You've mentioned a connectivity matrix and displacement vectors you need to impose on each point... for moving those points, to reflect the displacement.

OK, there are two ways you might be storing your data:
  • Polygonal data, perhaps using stripped triangles for performance. The cell data in this case would be stored in the faces of the triangles.
  • Unstructured mesh, which would mean that the cell data would be stored in the centre of the cells.
From your description, I believe it's polygonal data.

Now, the connectivity matrix for the 2 triangles example would indicate that the displacement (X1_2, Y1_2, Z1_2) in a particular triangle ID1 refers to another triangle face ID2; since the triangles are connected by 2 points, this would mean that those two points would be equally displaced.
The problem with this scenario, is that... :eek: this seems a pretty hectic problem: by moving 2 points, all other triangles would feel this displacement, unless either:
  1. you somehow make the motion to be in a shrink direction only, i.e. preserve the location of the centre and normal of the triangle and displace the now duplicate points towards the centre of their own triangle... or
  2. the centre stays, but the points move along the displacement vector, 50% of the length of the vector for each pair of duplicate points.
Wow, this feels like a pretty amazing representation of displacement!


The wrap cells by vectors won't work for this, because it was designed for the vertexes to remain attached.
What you need is to, after loading the data in ParaView, first apply the "Shrink" filter with a factor of 1, so that the points are cloned for each triangle. Then you've have to use the "Programmable Filter" for:
  1. Iterating over each and every triangle;
  2. correlate the displacement with in the other connected triangle;
  3. and apply the displacement to each pair of pairs of points... in other words, apply the displacement to the 2 point-pairs of duplicate points, e.g. a1+a2 and b1+b2, where c1 and c2 are unrelated points between the the two triangles.
The examples that you can follow for ideas on how to implement this:
  1. The very first example from this page: http://www.paraview.org/Wiki/Python_Programmable_Filter - gives an example on how to manipulate the point locations.
  2. The examples "Tetrahedra Volume (Filter)" and "Tetrahedra Radius (Filter)" on this page http://www.paraview.org/Wiki/ParaVie...Python_Filters - give an example on how to iterate over each cell. Although it's for unstructured grids, the only detail that changes is the class type of the "pdi" variable, which isn't even addressed directly in the Python code in the filter.
For me to able to help you beyond this, I really need a simple test case, otherwise (assuming I find the time) I'll probably go off in a tangent with some convoluted data format :).

Best regards,
Bruno

ronwelty April 28, 2014 04:52

Dear Bruno, first of all I want to thank you for your support.
My script is structured like this: I have a very large number of triangles, and they are subdivided into groups, every group must move altogether. To do so, I define a cell_data vector (same size as number of triangles) in which I define the displacement for every triangle (it means that I forcedly repeat the displacement values for all the triangles that must move together). I am using Unstructured grids and 3-point cells in Paraview.
A little example could be like this:

Code:

# vtk DataFile Version 4.0
Unstructured grid legacy vtk file with point scalar data
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 6 float
0 0 0
1 0 0
2 0 0
2 1 0
1 1 0
0 1 0

CELLS 4 16
3 0 4 5
3 0 1 4
3 1 3 4
3 1 2 3

CELL_TYPES 4
5
5
5
5


CELL_DATA 4
VECTORS disp float
-1.0 0.0 0.0
-1.0 0.0 0.0
1.0 0.0 0.0
1.0 0.0 0.0

So basically, I want to warp the first 2 triangles in -X dir and the remaining 2 in +X dir. I thought this kind of syntax could do it?
Thanks again.


EDIT: applying the Shrink filter with a factor of 1 and THEN the warp by vector filter seems to work.
This is the results I obtain before warping:

http://i58.servimg.com/u/f58/18/02/17/91/shrink10.jpg

and this is after warping:

http://i58.servimg.com/u/f58/18/02/17/91/shrink11.jpg

Do you think this can be a permanent solution to the problem? :confused:

wyldckat April 28, 2014 14:47

Quote:

Originally Posted by ronwelty (Post 488615)
Do you think this can be a permanent solution to the problem? :confused:

:eek: This makes everything a lot more clear!
OK, then if you only care about the displacement made to the centres of the triangles, then yes, this should do the trick!
The steps seem to be:
  1. Apply the "Shrink" filter with a factor of 1.
  2. Apply the "Cell Data to Point Data" filter.
  3. And finally apply the "Warp by Vector" filter.
If you do step #2 before #1, then you risk getting interpolated values for the triangle vertices.

My question is: is the displacement of each triangle already globally calculated or is it relative to each other?
Because these steps assume the displacement is global, if I'm not mistaken.

ronwelty April 29, 2014 05:52

Quote:

Originally Posted by wyldckat (Post 488735)
:eek: This makes everything a lot more clear!
OK, then if you only care about the displacement made to the centres of the triangles, then yes, this should do the trick!
The steps seem to be:
  1. Apply the "Shrink" filter with a factor of 1.
  2. Apply the "Cell Data to Point Data" filter.
  3. And finally apply the "Warp by Vector" filter.
If you do step #2 before #1, then you risk getting interpolated values for the triangle vertices.

My question is: is the displacement of each triangle already globally calculated or is it relative to each other?
Because these steps assume the displacement is global, if I'm not mistaken.

Dear Bruno,

as you can see from the screenshots I posted, the "Cell Data to Point Data" filter is not even needed. This means ParaView understands the CELL_DATA vector is applied to the triangles and not to the points. The only step needed is the "Shrink" filter, otherwise the displacement gets interpolated and the triangles don't split!
And yes, you're right, the displacement is calculated in the global reference system.


All times are GMT -4. The time now is 21:07.