I have a pvtu file with associated vtu files from which I want to display some data. If I load the pvtu in Paraview (5.6+), I get the following image when I choose Solid Color (White) and Surface With Edges:
The mesh is clearly anisotropic close to the top boundary with almost flattened triangles; this is the expected behaviour.
If I now load the same pvtu in Python and display the mesh in the following manner,
import numpy
import matplotlib.pyplot as plt
import vtk
gridreader = vtk.vtkXMLPUnstructuredGridReader()
gridreader.SetFileName('whatever.pvtu')
gridreader.Update()
vtkOut = gridreader.GetOutput()
vtkData = vtkOut.GetPoints().GetData()
coords = numpy.array([vtkData.GetTuple3(x)
for x in range(vtkData.GetNumberOfTuples())])
plt.triplot(coords[:, 0], coords[:, 1])
plt.gcf().set_size_inches(16, 8)
plt.gca().set_aspect('equal')
plt.savefig('meshPython1.png', bbox_inches='tight')
plt.gca().set_xlim((5e5, 3e6))
plt.gca().set_ylim((6e5, 1e6))
plt.savefig('meshPython2.png', bbox_inches='tight')
I get that:
where you can readily see that the anisotropy is not present. Therefore, my naive question is: how do I reproduce the mesh displayed in Paraview with Python? However, there is probably a more accurate question. I am fully aware that the triangulation library of matplotlib accepts triangles as an argument, but I am unable to find a command to extract them from the pvtu. So maybe a better question would be how to obtain the triangles from a pvtu file?
Any help appreciated.