Skip to content

Adds DomainMesh improvements, docs, and bugfixes#1558

Open
peterdsharpe wants to merge 27 commits intoNVIDIA:mainfrom
peterdsharpe:psharpe/domainmesh-improvements-and-docs
Open

Adds DomainMesh improvements, docs, and bugfixes#1558
peterdsharpe wants to merge 27 commits intoNVIDIA:mainfrom
peterdsharpe:psharpe/domainmesh-improvements-and-docs

Conversation

@peterdsharpe
Copy link
Copy Markdown
Collaborator

PhysicsNeMo Pull Request

Description

Contains a bunch of small improvements to DomainMesh, such as:

  • Adding DomainMesh.draw() to mirror Mesh.draw() with multi-mesh support.
  • Allows multi-mesh plotting capabilities with PyVista visualization backend.
  • Fixes a bug in DomainMesh.n_boundaries, where we were incorrectly returning the `TensorDict
  • DomainMesh.check_boundary_watertight() bugfix by deduplicating vertices before watertightness check

Checklist

Dependencies

Review Process

All PRs are reviewed by the PhysicsNeMo team before merging.

Depending on which files are changed, GitHub may automatically assign a maintainer for review.

We are also testing AI-based code review tools (e.g., Greptile), which may add automated comments with a confidence score.
This score reflects the AI’s assessment of merge readiness and is not a qualitative judgment of your work, nor is
it an indication that the PR will be accepted / rejected.

AI-generated feedback should be reviewed critically for usefulness.
You are not required to respond to every AI comment, but they are intended to help both authors and reviewers.
Please react to Greptile comments with 👍 or 👎 to provide feedback on their accuracy.

…at allows selective application of functions to interior and boundary meshes. Update related tests to validate the new functionality and ensure proper behavior with global data preservation.
…ing existing plotters. This allows overlaying multiple meshes on the same scene.
…ns to support both matplotlib and PyVista backends, allowing for overlaying multiple meshes on the same scene.
…uce geometry-only meshes, improving check_boundary_watertight to include a cleaning step. Documentation for these methods has also been added or updated.
…streamline boundary mesh representation, enhancing readability and consistency in displayed mesh information.
…t sets

This new function utilizes KNN to find and return matched indices of source and target points within a specified tolerance, enhancing the sampling capabilities of the mesh module.
@peterdsharpe peterdsharpe requested a review from coreyjadams April 9, 2026 22:40
@peterdsharpe peterdsharpe marked this pull request as ready for review April 9, 2026 22:41
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 9, 2026

Greptile Summary

This PR adds DomainMesh.draw() for multi-mesh visualization (with PyVista overlay support), correctly fixes n_boundaries (was returning a TensorDict instead of an int), and fixes is_boundary_watertight() by calling .clean() before the watertightness check to deduplicate shared vertices across independently-meshed patches. It also exports find_nearest_cells and match_points from the sampling __init__.py, and ships a comprehensive test suite for DomainMesh transforms. The one minor inconsistency is that show_edges is forwarded to the interior draw but not to boundary draws in DomainMesh.draw().

Important Files Changed

Filename Overview
physicsnemo/mesh/domain_mesh.py Adds DomainMesh.draw(), fixes n_boundaries (was returning TensorDict), and fixes is_boundary_watertight() with .clean() dedup; one minor inconsistency with show_edges not forwarded to boundary draws.
physicsnemo/mesh/visualization/_pyvista_impl.py Adds plotter parameter to draw_mesh_pyvista to enable multi-mesh overlay on a shared PyVista Plotter; the module-level pv import is safe since this module is only imported lazily after pyvista availability is confirmed.
physicsnemo/mesh/visualization/draw_mesh.py No functional changes visible; forwards plotter via ax parameter to pyvista backend, enabling DomainMesh.draw() overlay pattern.
physicsnemo/mesh/sampling/init.py Adds find_nearest_cells and match_points to public exports; both functions were already implemented in sample_data.py.
test/mesh/test_domain_mesh_transforms.py Comprehensive new test file covering apply, translate, rotate, scale, transform, clean, strip_caches, subdivide, data operations, validation, chaining, and domain-level global_data transformation.

Reviews (1): Last reviewed commit: "formatting" | Re-trigger Greptile

Comment thread physicsnemo/mesh/domain_mesh.py
… and improve formatting of mesh data representation, enhancing clarity and consistency in the tutorial outputs.
This commit introduces a new test to ensure that passing a PyVista Plotter to the mesh draw method with the matplotlib backend raises the appropriate ValueError. This enhances the robustness of the visualization module by validating error handling for unsupported backends.
This commit adds validation checks to ensure that the 'ax' parameter in the draw_mesh_matplotlib function is a valid matplotlib Axes object, and the 'plotter' parameter in the draw_mesh_pyvista function is a valid PyVista Plotter object. Appropriate ValueErrors are raised for invalid types, improving robustness in backend handling.
…a backends

This commit enhances the docstrings for the draw_mesh_matplotlib and draw_mesh_pyvista functions, clarifying the purpose of the 'ax' and 'plotter' parameters, respectively. The updates specify that these parameters can be used to overlay multiple meshes on the same axes or scene, improving the usability and understanding of the functions.
@peterdsharpe
Copy link
Copy Markdown
Collaborator Author

/blossom-ci

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

Successfully merging this pull request may close these issues.

1 participant