I would like to visualize the displacement field data on my unstructured grid created using vtkPoints() in python. I have the displacement field data at each point. How can i create a vtu file with all these data (point data and field data) and visualize the results in paraview? Here’s the relevant part of the code:
# surf, point_array,points_traction,points_disp,X_sample_G,X_sample_u,X_sample_t = make_cube()
# colloc_points = point_array
# new_points = point_array
colloc_points = genfromtxt('colloc_points-u30.csv', delimiter=',')
displacement = genfromtxt("displacement-u30.csv", delimiter=',')
new_points = colloc_points+displacement
colors = vtkNamedColors()
# create polyhedron (cube)
# The point Ids are: [0, 1, 2, 3, 4, 5, 6, 7]
points1 = vtkPoints()
points2 = vtkPoints()
for i in range(colloc_points.shape[0]):
points1.InsertNextPoint(colloc_points[i])
for i in range(new_points.shape[0]):
points2.InsertNextPoint(new_points[i])
ugrid1 = vtkUnstructuredGrid()
ugrid1.SetPoints(points1)
ugrid2 = vtkUnstructuredGrid()
ugrid2.SetPoints(points2)
# ugrid.InsertNextCell(VTK_POLYHEDRON, faceId)
# Here we write out the cube.
writer1 = vtkXMLUnstructuredGridWriter()
writer1.SetInputData(ugrid1)
writer1.SetFileName('polyhedron1.vtu')
writer1.SetDataModeToAscii()
writer1.Update()
writer2 = vtkXMLUnstructuredGridWriter()
writer2.SetInputData(ugrid2)
writer2.SetFileName('polyhedron2.vtu')
writer2.SetDataModeToAscii()
writer2.Update()