Open pmaroneh opened 3 years ago
See contouring within pyvista for this.
Thanks @akaszynski. I also considered using matplotlib.pyplot.contour. I'll give it a shot later this week.
matplotlib
is great for 2D data. pyvista
& VTK is better suited for 3D data.
See https://github.com/pyansys/DPF-Core/issues/59 for further info
Hi @pmaroneh, as mentioned in #59 , one can get the UnstructuredGrid vtk object from a field by using:
vtk_UnstructuredGrid = field.meshed_region.grid
I thus got a sort of working example:
from ansys.dpf import core as dpf from ansys.dpf.core import examples import pyvista as pv
model = dpf.Model(examples.multishells_rst) disp = model.results.displacement() x_disp = disp.Z() fc = x_disp.outputs.fields_container() field = fc[0] vtk_UnstructuredGrid = field.meshed_region.grid vtk_UnstructuredGrid.point_data["disp"] = field.data
contours = vtk_UnstructuredGrid.contour(scalars="disp")
pl = pv.Plotter() pl.add_mesh(vtk_UnstructuredGrid, color="w", opacity=0.1) pl.add_mesh(contours) pl.show()
We can then start an enhancement PR to implement a helper for this.
It would be convenient to easily be able to extract and plot isolines from a dataset. Plotting of isolines can be done natively in Mechanical but the data of the isolines (coordinate, value) cannot be exported: