I want to assign the result of the calculation to the grid element,

I can assign the result of the calculation to the grid node and then generate a VTK file; However, I want to assign the result of the calculation to the grid element, but I don’t know how to do that. Asking for help. Thank you

The question is not very clear, but you can assign info to a cell like the example below (ASCII Unstructured Grid). The scalar will be assigned to the grid element, not to the point.

CELL_DATA 6
SCALARS cell_scalars int 1
LOOKUP_TABLE default
0
1
2
3
4
5

If you want to assign data to points, you can do something like this:

POINT_DATA 27
SCALARS scalars float 1
LOOKUP_TABLE default
0.0 1.0 2.0 3.0 4.0 5.0
6.0 7.0 8.0 9.0 10.0 11.0
12.0 13.0 14.0 15.0 16.0 17.0
18.0 19.0 20.0 21.0 22.0 23.0
24.0 25.0 26.0
VECTORS vectors float
1 0 0 1 1 0 0 2 0 1 0 0 1 1 0 0 2 0
1 0 0 1 1 0 0 2 0 1 0 0 1 1 0 0 2 0
0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1
0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1
0 0 1 0 0 1 0 0 1

For more info refer to:
“File Formats for VTK Version 4.2 (Taken from The VTK User’s Guide)”