pyvista / pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
https://github.com/pyvista/pyvista/discussions
60 stars 4 forks source link

Indices of simplices (tetrahedral elements in tetgen) that contain a set of user defined points #228

Open souvikmeister opened 4 years ago

souvikmeister commented 4 years ago

Hi Everyone, Following @banesullivan 's reply to my request on slack, I am suggesting the addition of the new feature in tetgen. This feature is commonly available in the scipy.spatial.Delaunay as well as in Matlab's delaunaytriangulation. I am posting the scipy.spatial.Delaunay example here: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.Delaunay.find_simplex.html#scipy.spatial.Delaunay.find_simplex essentially many Finite Element and AI applications based on Finite Elements require the ability to interpolate results on any point within a simplex. This feature above enables this and will speed up development and reduce computation time for applications developed using tetgen and pyvista. Thanks, Souvik

banesullivan commented 4 years ago

Keeping this short, but I'll try to come back to this and give some example code.

You should be able to mimic the helper we have for find_closest_point to find the cell containing a point with vtkCellLocator instead of vtkPointLocator. Then do that for all of your query points to have a list of cell IDs and pass those IDs to extract_cells to get all of the cells containing those points.

We could easily add this function (perhaps called find_closest_cell)

banesullivan commented 4 years ago

Also, here is a C++ VTK example on how to use the cell locator: https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/CellLocator/

Again, I'll try to come back to this and provide a Python helper function to do all of this that will could add to PyVista

banesullivan commented 4 years ago

Also this is very related to #248