I want to create .vtk file with my mesh data, so I can view it in paraview.
Below is what I have been able to work out so far. It is 2 quadrilateral elements, and works in Paraview.
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET STRUCTURED_GRID
DIMENSIONS 2 3 1
POINTS 6 float
0 0 0
1 0 0
0 1 0
1 1 0
0 2 1
1 2 1
POINT_DATA 6
But I can't seem to work out how to color the 2 cells / areas of the mesh with different float values. I.e. I want the centre of the one panel/cell to show the value 0.123, and the other 0.456.
How do modify my .vtk file so that I can do this?
You just need to add a CELL_DATA
section to the bottom of the file. Here is your previous example with the values 0.123 and 0.456 assigned to the respective elements.
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET STRUCTURED_GRID
DIMENSIONS 2 3 1
POINTS 6 float
0 0 0
1 0 0
0 1 0
1 1 0
0 2 1
1 2 1
CELL_DATA 2
SCALARS cellData float 1
LOOKUP_TABLE default
0.123 0.456