I made some more simplified diagrams. Fipy imposes the following inheritance:
[image: UML_mesh_simple.jpg] While vtk imposes the following, as per https://vtk.org/doc/nightly/html/classvtkCell.html : [image: UML_vtkobjects.jpg] In VTK, *vtkLine*, *vtkPolygon* and *vtkConvexPointSet* are specializations of *vtkCell. *In Fipy *vtkLine*, *vtkPolygon* are specializations of *vtkConvexPointSet * I wonder whether this may be the root of the problem outlined in https://github.com/usnistgov/fipy/issues/312... ---------- Forwarded message --------- From: A A <amine.aboufir...@gmail.com> Date: Sun, Feb 23, 2020 at 2:43 PM Subject: More on VTK objects and mesh plotting with 3rd party packaages To: <fipy@nist.gov> Dear All, This question is loosely related to https://github.com/usnistgov/fipy/issues/312 but might perhaps not be exactly the same. I ran some tests in which I tried to plot a "broken" mesh by resetting the cell type of the underlying tvtk object the same way fipy's VTKCellDataSet method does: *from fipy import Grid2Dimport pyvista# Create Meshmesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2)ug = mesh.VTKCellDataSet#ug.set_cells([7,7,7,7], ug.cell_locations_array.to_array(), ug.get_cells()) # overwrite tougrid= pyvista.UnstructuredGrid(ug._vtk_obj)# Plot Meshplotter = pyvista.Plotter()plotter.set_background('white')plotter.add_mesh(ugrid, style='wireframe', color='black')plotter.add_bounding_box(color='red')plotter.view_xy()plotter.show()* Uncommenting line 7 of the above code reveals that resetting the cell type from 41 to 7 of the UniformGrid2D's underlying tvtk object allows the mesh to appear in the plotter. I recall from previous discussions that failure of cell type 41 to plot was attributed to incorrect ordering of the cell vertices, but this would be in contradiction with the results of the code above. I then looked through fipy's source code and came up with the following inheritance diagram: [image: unnamed0.jpg] The _VTKCellType method in AbstractMesh returns tvtk.ConvexPointSet().cell_type while the _VTKCellType method in Mesh2D returns tvtk.Polygon().cell_type. I am quite sure that forcing AbstractMesh to return tvtk.Polygon().cell_type would cause the UniformGrid2D object to appear in pyvista/mayavi, though I am not sure whether this is a viable solution. Any thoughts? Regards, Amine
_______________________________________________ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]