-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vtkConvexPointSet cell type in pyvista/meshio? #108
Comments
I think this might indeed have something to do with the cell type which is 41. Is there a way to overwrite cell type after the grid has been created in pyvista? A temporary solution might be to assign a similar cell type to the |
The As for the blank rendering scene in PyVista... I'd need more details on the actual object being passed from import vtk
to_wrap = mesh.VTKCellDataSet._vtk_obj
assert isinstance(to_wrap, vtk.vtkUnstructuredGrid) if so, maybe use VTK to write that data object to a VTK format, zip it, and post that here: writer = vtk.vtkUnstructuredGridWriter()
writer.SetFileName("test.vtk")
writer.SetInputData(to_wrap)
writer.Write() |
Actually, I managed to get The mesh they pass back is indeed an instance of a Is there any library or software that you can pass that object to with success? |
And to confirm, PyVista does support the import pyvista as pv
def sample_convex_cell():
import vtk
points = vtk.vtkPoints()
points.InsertNextPoint( 0, 0, 0);
points.InsertNextPoint( 1, 0, 0);
points.InsertNextPoint( 1, 1, 0);
points.InsertNextPoint( 0, 1, 0);
points.InsertNextPoint( 0, 0, 1);
points.InsertNextPoint( 1, 0, 1);
points.InsertNextPoint( 1, 1, 1);
points.InsertNextPoint( 0, 1, 1);
points.InsertNextPoint( 0.5, 0, 0);
points.InsertNextPoint( 1, 0.5, 0);
points.InsertNextPoint( 0.5, 1, 0);
points.InsertNextPoint( 0, 0.5, 0);
points.InsertNextPoint( 0.5, 0.5, 0);
cps = vtk.vtkConvexPointSet()
for i in range(13):
cps.GetPointIds().InsertId(i,i);
ug = vtk.vtkUnstructuredGrid()
ug.Allocate(1,1)
ug.InsertNextCell(cps.GetCellType(), cps.GetPointIds())
ug.SetPoints(points)
assert isinstance (ug.GetCell(0), vtk.vtkConvexPointSet)
return ug
pv.UnstructuredGrid(sample_convex_cell()).plot(show_edges=True) As for |
The problem seems to be due to You can plot a grid generated with Note that you do not need |
Thanks, @keurfonluu! ah yep, I missed that @awa5114, was trying to save as a VTK file. This is totally doable without |
@keurfonluu I was not able to plot
Do you have a working example with @banesullivan that's good to hear that
Though I have raised it with Finally, you mention the following:
I guess adding a try/except would be nice, but wouldn't it make more sense to catch it at the source and have |
I think it's perfectly fine for any library that uses meshio to handle it's exceptions. meshio probably gives a If you think that meshio throws needlessly, you can always file a issue against meshio, for example for the support of VTK_CONVEX_POINT_SETs. |
@nschloe fair enough. In that case we should consider adding it to |
@banesullivan: "and some editing of their source code". Can you share? |
@awa5114, i think pyvista/pyvista#559 should have handled this! Sent with GitHawk |
@guyer, sure! I’ll see if I can retrace my steps and make a PR/contribute to usnistgov/fipy#693. I was feeling particularly hacky when I did this and did a few random things just to make the script work, nothing serious. Sent with GitHawk |
@banesullivan pyvista/pyvista#559 handles only the KeyError stemming from meshio. It does not handle the fipy plotting issue right? That would require something to be done at thè fipy level? |
@awa5114, that’s correct. There’s nothing we can do on PyVista side about the problematic mesh being passed from fipy. Sent with GitHawk |
My bad, the function name starts with an uppercase so it should rather be import numpy
import pyvista
from fipy.meshes.cylindricalNonUniformGrid2D import CylindricalNonUniformGrid2D
mesh = CylindricalNonUniformGrid2D(
dx = numpy.logspace(1., 2., 20),
dy = numpy.full(20, 10.),
)
ugrid = pyvista.UnstructuredGrid(mesh.VTKCellDataSet._vtk_obj)
ugrid.plot(show_edges = True, notebook = False)
|
I tried to use
pyvista
'sPlotter
object andsave_meshio
method to plot and write an unstructured grid into a vtk file. I usedfipy
to generate the grid, retrieved the underlying vtk object, instantiated apyvista
unstructured grid from the low level vtk object and then tried to plot and save into a file.Unfortunately, the plot was blank, and writing the file threw an error:
Here is the original code:
I'm suspecting the
KeyError
might be related to the fact that these cylindrical grids appear to containVTK_CONVEX_POINT_SET
cell types. What's the status of these cell types in pyvista? Can they be plotted and written out to files?The text was updated successfully, but these errors were encountered: