Search code examples
vtkparaview

Define data at cell centers using VTK format


I would like to write a post-processor in order to open some flow field data in paraview (using vtk legacy format). I am fine with the mesh loading, but I have a question on the variables arrangement.

I need to put a value in every cell center and not in the cell nodes. Thus, I have one value for each cell and no way to have a value for each node. Do you know a way to fix this problem?

Thank you very much for your kind help


Solution

  • Sure, you can specify cell data in the legacy ASCII VTK file format. Here's a simple example of a rectilinear grid with two cell data arrays with vector elements:

    # vtk DataFile Version 2.0
    
    ASCII
    DATASET RECTILINEAR_GRID
    DIMENSIONS 4 2 2
    X_COORDINATES 4 double
    0.0 10.0 20.0 30.0
    Y_COORDINATES 2 double
    0.0 10.0
    Z_COORDINATES 2 double
    0.0 10.0
    CELL_DATA 3
    VECTORS first_array double
    -1.0 0.0 0.0
    0.0 1.0 0.0
    1.0 0.0 0.0
    VECTORS second_array double
    -1.0 0.0 0.0
    0.0 1.0 0.0
    1.0 0.0 0.0