Skip to content

Mesh: support integer and boolean fields in point_data_to_cell_data - #1880

Draft
peterdsharpe wants to merge 1 commit into
NVIDIA:mainfrom
peterdsharpe:pr/mesh-point-data-mean-dtypes
Draft

Mesh: support integer and boolean fields in point_data_to_cell_data#1880
peterdsharpe wants to merge 1 commit into
NVIDIA:mainfrom
peterdsharpe:pr/mesh-point-data-mean-dtypes

Conversation

@peterdsharpe

@peterdsharpe peterdsharpe commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

PhysicsNeMo Pull Request

Description

Mesh.point_data_to_cell_data() calls torch.mean on each point field, which raises for integer and boolean tensors. These dtypes commonly arrive from VTK arrays such as node IDs, region tags, and wall markers, so ordinary imported meshes can fail during point-to-cell conversion.

This PR:

  • Gathers each cell's vertex values, promotes integer and boolean values to float64, and then computes the mean.
  • Preserves the dtype and values of floating-point and complex fields.
  • Matches the existing discrete-field behavior of cell_data_to_point_data() and facet aggregation.
  • Adds regression coverage for integer, boolean, floating-point, and complex fields.

Verification

  • pytest test/mesh: 2350 passed, 701 skipped.
  • ruff check, ruff format --check, and the pre-commit checks pass.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.
  • The CHANGELOG.md is up to date with these changes.
  • An issue is linked to this pull request.
  • Model implementation standards are not applicable; no model code is changed.

Dependencies

None.

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 the work or an indication that the PR will be accepted or 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.

point_data_to_cell_data called torch.mean directly on the gathered vertex
values, which raises for integer and boolean point fields. Those dtypes are
common after importing VTK IDs and markers. Integer and boolean values are
now promoted to float64 before averaging, matching cell_data_to_point_data;
floating-point and complex fields keep their dtype.
@copy-pr-bot

copy-pr-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown
Contributor

CODEOWNERS review map

Current for commit b9507c14b997. An approval covers every file listed for that owner; one owner is sufficient for shared files.

@peterdsharpe — 2 file(s)
  • physicsnemo/mesh/mesh.py
  • test/mesh/mesh/test_data_conversion.py

No CODEOWNER

  • CHANGELOG.md

Comment /codeowners-info to refresh.

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