1
$\begingroup$

I have a usual vtk file with a mesh of triangles and a scalar velocity.

I want to obtain this type of plots:

enter image description here

something like an "elevation", but in paraview I just had obtained plane plots like

enter image description here

How can I obtain plots like the first one?

I Edited my message with an example of my vtk file. Note that the points of the mesh are in the plane XY (for that reason its third coordinate is zero) and I want to plot the first and second component of the velocity and pressuse, each one like an "elevation" (as the first image).

# vtk DataFile Version 2.0
Stokes Solution 2D
ASCII

DATASET UNSTRUCTURED_GRID
POINTS           13  DOUBLE
0.000000000000000E+000   0.000000000000000E+000  0.000000000000000E+000
1.00000000000000         0.000000000000000E+000  0.000000000000000E+000
1.00000000000000         1.00000000000000        0.000000000000000E+000
0.000000000000000E+000   1.00000000000000        0.000000000000000E+000
0.500000000000000        0.500000000000000       0.000000000000000E+000
0.000000000000000E+000   0.500000000000000       0.000000000000000E+000
0.500000000000000        0.000000000000000E+000  0.000000000000000E+000
1.00000000000000         0.500000000000000       0.000000000000000E+000
0.500000000000000        1.00000000000000        0.000000000000000E+000
0.250000000000000        0.250000000000000       0.000000000000000E+000
0.250000000000000        0.750000000000000       0.000000000000000E+000
0.750000000000000        0.250000000000000       0.000000000000000E+000
0.750000000000000        0.750000000000000       0.000000000000000E+000

CELLS           16          64
   3       7      12       4
   3       5       9       4
   3      10       8       3
   3      10       3       5
   3       4       9       6
   3       6      11       4
   3       4      11       7
   3       4      12       8
   3       0       6       9
   3       5       0       9
   3       4       8      10
   3       5       4      10
   3       1       7      11
   3       6       1      11
   3       2       8      12
   3       7       2      12

 CELL_TYPES           16
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5

POINT_DATA           13
SCALARS presion double
LOOKUP_TABLE default
-4.59703889304213     
 3.82888363610970     
 3.81756522383386     
-4.60835730531561     
 0.197145644934616     
-4.59535605348466     
 0.195500198716605     
 3.82752829972580     
 0.187138058219474     
-2.12293352900423     
-2.12078991814064     
 2.21724715421349     
 2.21939076507648     

VECTORS velocidad double
0.000000000000000E+000   0.000000000000000E+000  0.000000000000000E+000
8.41470984807897         0.000000000000000E+000  0.000000000000000E+000
4.54648713412841        -4.54648713412841        0.000000000000000E+000
0.000000000000000E+000  -8.41470984807897        0.000000000000000E+000
4.20725870743923        -4.20725889966961        0.000000000000000E+000
0.000000000000000E+000  -4.79425538604203        0.000000000000000E+000
4.79425538604203         0.000000000000000E+000  0.000000000000000E+000
7.38460262604129        -2.59034723999926        0.000000000000000E+000
2.59034723999926        -7.38460262604129        0.000000000000000E+000
2.39717406023838        -2.39717405652409        0.000000000000000E+000
1.81026401191967        -6.60460085064085        0.000000000000000E+000
6.60460083608821        -1.81026405008086        0.000000000000000E+000
4.98756220389105        -4.98756217656822        0.000000000000000E+000
$\endgroup$

2 Answers 2

5
$\begingroup$

A good way to achieve this is to use the Warp By Vector filter to warp your field in the Z direction using the value of your scalar.

Just to give a brief overview, The warp by vector warps your field in a direction using a vector. If you wish to warp your field in the Z direction perpendicular to your XY plane, then you need to create a warp vector in the Z direction. This is very easy to achieve using the calculator and the kHat vector. Then you can rescale the value of the vector to obtain a warping that is pleasant to the eye.

This is the easiest way to achieve this type of graph using your (X Y 0) type of vtk files as far as I know.

$\endgroup$
2
$\begingroup$

We can use the UNSTRUCTURED_GRID dataset attribute format in VTK. Here I'm going to provide you a very simple example. Suppose that you had a set of vertices of the triangle mesh and a scalar field valued at the vertices. For example, we firstly generate vertices like this: $(x_0, y_0) = (0,0)$ and $$ (x_{j+1}, ~ y_{j+1}) = \Big( \cos(\frac{j\pi}{4}), ~ \sin(\frac{j\pi}{4}) \Big), ~~ j=\overline{0,7}, $$ which can be done by the following:

perl -le '$pi = 3.14159265358979323846 ; for ( $i=0; $i<8 ; $i++ ){ print cos($pi*$i/4)."\t". sin($pi*$i/4)}'

Secondly, adding values of $z_j=z(x_j,y_j)$, for instance, $z_0 = 1$ and $z_j = 0$ for $j \not = 0$, we now had the set of 9 points in 3D, where $z(x,y)$ is the scalar that we want to plot, and the mesh now is with 8 trianlges surrounding $(0,0)$. Lastly, make a file, say triangle_surf.vtk, with the following contents:

# vtk DataFile Version 2.0
Simple surface on a triangle mesh with vertices (xj,yj,zj) for j=0,8.
ASCII
DATASET UNSTRUCTURED_GRID
POINTS   9  double 
   0                             0                       1.0
   1                             0                       0.0
   0.707106781186548             0.707106781186547       0.0
   6.12323399573677e-17          1                       0.0
   -0.707106781186547            0.707106781186548       0.0
   -1                            1.22464679914735e-16    0.0
   -0.707106781186548            -0.707106781186547      0.0
   -1.83697019872103e-16         -1                      0.0
   0.707106781186547             -0.707106781186548      0.0

CELLS 8 32
   3  0  1  2
   3  0  2  3
   3  0  3  4
   3  0  4  5
   3  0  5  6
   3  0  6  7
   3  0  7  8
   3  0  8  1

CELL_TYPES 8
   5 
   5 
   5 
   5 
   5 
   5 
   5
   5

POINT_DATA 9
SCALARS z_values double
LOOKUP_TABLE default
   1.0
   0.0
   0.0
   0.0
   0.0
   0.0
   0.0
   0.0
   0.0

Now openning the vtk file by paraview, you will get something like this enter image description here

Since I am quite lazy to explain as well as I do not know what you had in hand and want to perform, any discussion in details is welcomed.

@yemino: sure. you just simply replace the 3rd column of coordinates, i.e. the z components, by the scalar values. For instance, to plot your presion data (presure?), we make this file

# vtk DataFile Version 2.0
Stokes Solution 2D
ASCII

DATASET UNSTRUCTURED_GRID
POINTS           13  DOUBLE
0.000000000000000E+000   0.000000000000000E+000  -4.59703889304213     
1.00000000000000         0.000000000000000E+000   3.82888363610970     
1.00000000000000         1.00000000000000         3.81756522383386     
0.000000000000000E+000   1.00000000000000        -4.60835730531561     
0.500000000000000        0.500000000000000        0.197145644934616     
0.000000000000000E+000   0.500000000000000       -4.59535605348466     
0.500000000000000        0.000000000000000E+000   0.195500198716605     
1.00000000000000         0.500000000000000        3.82752829972580     
0.500000000000000        1.00000000000000         0.187138058219474     
0.250000000000000        0.250000000000000       -2.12293352900423     
0.250000000000000        0.750000000000000       -2.12078991814064     
0.750000000000000        0.250000000000000        2.21724715421349     
0.750000000000000        0.750000000000000        2.21939076507648     

CELLS           16          64
   3       7      12       4
   3       5       9       4
   3      10       8       3
   3      10       3       5
   3       4       9       6
   3       6      11       4
   3       4      11       7
   3       4      12       8
   3       0       6       9
   3       5       0       9
   3       4       8      10
   3       5       4      10
   3       1       7      11
   3       6       1      11
   3       2       8      12
   3       7       2      12

 CELL_TYPES           16
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5
       5

POINT_DATA           13
SCALARS presion double
LOOKUP_TABLE default
-4.59703889304213     
 3.82888363610970     
 3.81756522383386     
-4.60835730531561     
 0.197145644934616     
-4.59535605348466     
 0.195500198716605     
 3.82752829972580     
 0.187138058219474     
-2.12293352900423     
-2.12078991814064     
 2.21724715421349     
 2.21939076507648 

Then you will get something like a 3D surface, here is it: enter image description here

Treat other scalar fields as the same way above.

$\endgroup$
1
  • $\begingroup$ thanks @tqviet for your answerd. I added a vtk file to my original question. Note that all points have its third component cero (because live in the plane XY): $(x,y,0)$. And that's why the plot its only a plane. Can you obtein a similar plot (similar to your plot) with my vtk file? $\endgroup$
    – yemino
    Oct 27, 2016 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.