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

Generate a PyVista grid directly without meshio as intermediate step #451

Merged
merged 8 commits into from
Mar 3, 2025

Conversation

keurfonluu
Copy link
Contributor

Overview

Conversion from gmsh API to PyVista grid is straightforward. There is no need to use meshio.Mesh as intermediate mesh. Bonus, pygmsh is no longer required as dependency.

Details

  • Add function generate_mesh.
  • Clean and finalize gmsh instance if error is raised by gmsh.

Copy link

welcome bot commented Feb 28, 2025

Thanks for opening this pull request! Please check out our contributing guidelines.

element_types, element_tags, element_node_tags = gmsh.model.mesh.getElements()

# Points
assert (np.diff(node_tags) > 0).all()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is ever False. pygmsh is checking whether tags are sorted, so I left it.

cells = {}

for type_, tags, node_tags in zip(element_types, element_tags, element_node_tags):
assert (np.diff(tags) > 0).all()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here (seems to be always True).

@tkoyama010 tkoyama010 self-requested a review March 3, 2025 21:42
Copy link
Member

@tkoyama010 tkoyama010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm really impressed with this improvement!

@tkoyama010 tkoyama010 merged commit 3ec8687 into pyvista:main Mar 3, 2025
6 checks passed
Copy link

welcome bot commented Mar 3, 2025

Congrats on merging your first pull request! We here at behaviorbot are proud of you!

@tkoyama010
Copy link
Member

@all-contributors please add @keurfonluu for code

Copy link
Contributor

@tkoyama010

I've put up a pull request to add @keurfonluu! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants