pyvista / tetgen

A Python interface to the C++ TetGen library to generate tetrahedral meshes of any 3D polyhedral domains
http://tetgen.pyvista.org
Other
219 stars 32 forks source link

Add background mesh support #62

Closed angela-ko closed 6 months ago

angela-ko commented 6 months ago

Adds the support for sizing func as mentioned in issue #59

angela-ko commented 6 months ago

@akaszynski Hi Alex! I see you've already noticed the PR but I just linked the relevant issue it's associated with + fixed a minor pydoc linter issue. Would you mind taking a look at it again?

Also, we added support for both passing in a bgmeshfilename and the bgmesh directly through a pyvista mesh but we weren't certain whether or not the bgmeshfilename feature would be necessary. Let me know if there's any changes we should make!

angela-ko commented 6 months ago

cc: @dionhaefner

akaszynski commented 6 months ago

Will do. Will be reviewed by this evening.

akaszynski commented 6 months ago

Will do. Will be reviewed by this evening.

Apologizes for the delay. Build was failing and bumping cibuildwheel fixed that, but discovered a few other minor issues while updating the build in #63, including the need for Python 3.12 wheels for pymeshfix.

Made a handful of changes and commented out what appears to be debugging code and plotter setup, which reduced the test time.

One note, it's a bit less verbose to generate a subgrid with:

cell_center = grid.cell_centers().points
subgrid = grid.extract_cells(cell_center[:, 2] < 0)

extract_cells supports boolean masks, and using cell_centers means you don't have to access the cells attribute and manually compute cell centers.

akaszynski commented 6 months ago

Another note:

We can use cell_connectivity, avoiding the need for a loop and a temporary list within _process_bgmesh since we guarentee that the UnstructuredGrid is composed of only tetrahedra. This greatly improves performance. Implemented in 69b064cf63413472f2d1a39af8d030ef1dd556b2.

angela-ko commented 6 months ago

LGTM! Thanks for the speedy review / edits.

Glad to learn that cell connectivity could be used to get the tets instead as well.

tkoyama010 commented 6 months ago

Awesome job!

dionhaefner commented 6 months ago

Wow, that was fast - thanks everyone!