tre95
tre95

Reputation: 443

What is the simplest way to convert a VTK file from point_data to cell_data?

I have a (valid) VTK file that contains 3D point data from a CFD simulation. The general structure is:

# vtk DataFile Version 2.0
grid, time      12.50000000
ASCII
DATASET STRUCTURED_GRID
DIMENSIONS    33   25   25
POINTS             20625 double
   0.31250E-01   0.31250E-01   0.31250E-01
   0.93750E-01   0.31250E-01   0.31250E-01
   0.15625E+00   0.31250E-01   0.31250E-01
   0.21875E+00   0.31250E-01   0.31250E-01
   0.28125E+00   0.31250E-01   0.31250E-01
   0.34375E+00   0.31250E-01   0.31250E-01
   0.40625E+00   0.31250E-01   0.31250E-01
   0.46875E+00   0.31250E-01   0.31250E-01
   0.53125E+00   0.31250E-01   0.31250E-01
   0.59375E+00   0.31250E-01   0.31250E-01
   0.65625E+00   0.31250E-01   0.31250E-01
   0.71875E+00   0.31250E-01   0.31250E-01
   0.78125E+00   0.31250E-01   0.31250E-01
   0.84375E+00   0.31250E-01   0.31250E-01
   […]
   0.19062E+01   0.15312E+01   0.15312E+01
   0.19688E+01   0.15312E+01   0.15312E+01
   0.20312E+01   0.15312E+01   0.15312E+01
POINT_DATA             20625
SCALARS                  VOF float 1
LOOKUP_TABLE default
   0.00000E+00
   0.00000E+00
   0.00000E+00
   0.00000E+00
   0.00000E+00
   […]
   0.00000E+00
   0.00000E+00
   0.00000E+00
   0.00000E+00
   0.00000E+00

The respective variable is actually computed at the listed points in the simulation. Therefore, my visualization programs (Paraview or VisIt, respectively) interpolate the values between these points. Physically speaken, however, the respective variable values are not valid for one point, but for one cubic cell that has a side length of 0.0625. That means the points listed are in the center of these cells. I do not want to visualize the values as these points, but instead the value belonging to a point shall be shown non-interpolated in the respective cell when I visualize the data.

My question: is there a convenient and simple way (when creating the VTK files) to change the formatting from POINT_DATA to CELL_DATA?

Upvotes: 0

Views: 427

Answers (1)

tre95
tre95

Reputation: 443

Ok I found out that it is best to change the dataset type. This seems to be the easiest modification:

# vtk DataFile Version 2.0
Title
ASCII
DATASET RECTILINEAR_GRID
DIMENSIONS 33 25 25
X_COORDINATES 33 float
0.00000000 0.06250000 0.12500000 0.18750000 0.25000000 0.31250000 0.37500000 0.43750000 0.50000000 0.56250000 0.62500000 0.68750000 0.75000000 0.81250000 0.87500000 0.93750000 1.00000000 1.06250000 1.12500000 1.18750000 1.25000000 1.31250000 1.37500000 1.43750000 1.50000000 1.56250000 1.62500000 1.68750000 1.75000000 1.81250000 1.87500000 1.93750000 2.00000000 
Y_COORDINATES 25 float
1.50000000 1.56250000 1.62500000 1.68750000 1.75000000 1.81250000 1.87500000 1.93750000 2.00000000 2.06250000 2.12500000 2.18750000 2.25000000 2.31250000 2.37500000 2.43750000 2.50000000 2.56250000 2.62500000 2.68750000 2.75000000 2.81250000 2.87500000 2.93750000 3.00000000 
Z_COORDINATES 25 float
3.00000000 3.06250000 3.12500000 3.18750000 3.25000000 3.31250000 3.37500000 3.43750000 3.50000000 3.56250000 3.62500000 3.68750000 3.75000000 3.81250000 3.87500000 3.93750000 4.00000000 4.06250000 4.12500000 4.18750000 4.25000000 4.31250000 4.37500000 4.43750000 4.50000000 
CELL_DATA 18432
SCALARS VOF float 1
LOOKUP_TABLE default
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
[...]
0.00000000

with the respective values forming a vector of 18432 entries.

Upvotes: 1

Related Questions