Skip to content
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

Write vtk file directly from vtk/pyvista object #640

Closed
amine-aboufirass opened this issue Jan 22, 2020 · 5 comments
Closed

Write vtk file directly from vtk/pyvista object #640

amine-aboufirass opened this issue Jan 22, 2020 · 5 comments

Comments

@amine-aboufirass
Copy link

amine-aboufirass commented Jan 22, 2020

I am trying to figure out why a mesh generated using fipy will not plot using pyvista. To do this I would like to write it out into a vtk ASCII file, inspect the file and see whether it renders in Paraview. I could not however find an efficient way of getting meshio to write out the vtk file. Here 's some code which can replicate the mesh:

from fipy import CylindricalGrid2D
import pyvista
import meshio

mesh = CylindricalGrid2D(dr=0.1, dz=0.25, nr=3, nz=0.1)
ugrid= pyvista.UnstructuredGrid(mesh.VTKCellDataSet._vtk_obj)

I tried implementing pyvistas save_meshio method but got a KeyError (pyvista/pyvista-support#108). Is there a more direct way using meshio to write out the file? Perhaps without using pyvista alltogether?

@nschloe
Copy link
Owner

nschloe commented Jan 22, 2020

You can build a meshio mesh from the point coordinates and the cell connectivity, e.g.,

meshio.write_points_cells(point_coords, {"tetra": conn})

It seems that the point coordinates are in mesh.vertexCoords. Not sure about the connectivity.

@amine-aboufirass
Copy link
Author

will this work for cell type 41

@nschloe
Copy link
Owner

nschloe commented Jan 22, 2020 via email

@amine-aboufirass
Copy link
Author

correct

@nschloe
Copy link
Owner

nschloe commented Jan 23, 2020

No, there is no support for this in meshio.

@nschloe nschloe closed this as completed Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants