Skip to content

Aero recipe: document sampled forces and preserve exported quadrature - #1971

Open
peterdsharpe wants to merge 13 commits into
NVIDIA:mainfrom
peterdsharpe:pr/recipe-ht-forces
Open

peterdsharpe wants to merge 13 commits into
NVIDIA:mainfrom
peterdsharpe:pr/recipe-ht-forces

Conversation

@peterdsharpe

@peterdsharpe peterdsharpe commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #1970. Its current head (e2ff58109108d67da4bb26eb8bb35a47b6cb045e) is merged into this branch. Relative to #1970, this PR changes only the force/inference documentation and warning, their regression tests, and the changelog.

The aero recipe's force documentation and inference warning said subsampled coefficients shrink by the retained-area fraction. Mesh integration already uses complete effective measures, including sampling corrections. This PR documents that behavior and verifies that exported query measures remain usable in physical coordinates.

  • Describe force quadrature using cell_measures(mesh). Exact Horvitz–Thompson unbiasedness requires correct inclusion probabilities, fixed field values, and a fixed physical moment origin. Approximate sampling, predictions depending on the sampled geometry, and sample-dependent centering can introduce bias; check convergence with surface resolution.
  • Preserve explicit query measures in saved inference outputs. The shared measure API scales them with geometry and retains their represented dimension, so exported fields can still be integrated. No separate query-measure stripping is needed.
  • Verify sampled constant-traction forces at both training and physical geometry scales, and verify exported point measures, integrals, dimension metadata and source immutability through serialization.

No force-computation or sampling algorithm changes are included. These recipe contracts apply to all supported surface models.

Validation: all 33 force/inference tests and all applicable pre-commit hooks passed. The broader recipe suite had 185 passes, one skip and one failure in test_sdf_normals_near_wall_use_face_normal. The identical signed-distance assertion failure reproduces on the pre-update #1971 head (22219d40) and #1970, independently of this change.

MeshToDomainMesh in cell_centroids mode turns each source cell into an
interior query point and discards the cells. Any integral over those
points (forces, area-weighted losses or metrics) then has no measure to
weight by, and after SubsampleMesh the retained cells' measure weights
are lost as well.

Record cell_measures(mesh) (area times composed measure weights) on the
interior under the reserved point_data key TARGET_QUADRATURE_MEASURE_KEY,
aligned one-for-one with the centroids. Reject the key as a user target
or as a pre-existing input field so it cannot be silently shadowed.

Also validate the shape of the reserved per-cell measure-weights field
and of tensor factors passed to compose_measure_weights: TensorDict only
checks the leading dimension, so a (n_cells, 1) tensor was storable but
broadcast wrongly against cell_areas.
…, drop query measure from saved outputs

forces.py and infer.py said that force/moment coefficients from a
subsampled vehicle surface "cover only the kept cells" and shrink by the
kept-area fraction. That is no longer true: SubsampleMesh records each
kept cell's inverse inclusion probability as a measure weight and
Mesh.integrate multiplies by it, so the coefficients are unbiased (if
noisy) estimates of the full-surface integrals. Correct the module
docstring and the once-per-run warning, and pin the behaviour with a
test on a subsampled closed surface.

MeshToDomainMesh now records the query measure on the interior. It is in
training-geometry units and would be stale after rescale_geometry, so
attach_and_save drops it alongside the training-space targets.
@copy-pr-bot

copy-pr-bot Bot commented Sep 8, 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

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS review map

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

⏳ @coreyjadams — 8 file(s)
  • examples/cfd/external_aerodynamics/unified_external_aero_recipe/src/forces.py
  • examples/cfd/external_aerodynamics/unified_external_aero_recipe/src/infer.py
  • examples/cfd/external_aerodynamics/unified_external_aero_recipe/tests/test_forces.py
  • examples/cfd/external_aerodynamics/unified_external_aero_recipe/tests/test_infer.py
  • physicsnemo/datapipes/transforms/mesh/init.py
  • physicsnemo/datapipes/transforms/mesh/transforms.py
  • test/datapipes/transforms/test_mesh_to_domain_mesh.py
  • test/datapipes/transforms/test_nested_fields.py
⏳ @negin513 — 4 file(s)
  • physicsnemo/datapipes/transforms/mesh/init.py
  • physicsnemo/datapipes/transforms/mesh/transforms.py
  • test/datapipes/transforms/test_mesh_to_domain_mesh.py
  • test/datapipes/transforms/test_nested_fields.py
⏳ @peterdsharpe — 6 file(s)
  • examples/cfd/external_aerodynamics/unified_external_aero_recipe/src/forces.py
  • examples/cfd/external_aerodynamics/unified_external_aero_recipe/src/infer.py
  • examples/cfd/external_aerodynamics/unified_external_aero_recipe/tests/test_forces.py
  • examples/cfd/external_aerodynamics/unified_external_aero_recipe/tests/test_infer.py
  • physicsnemo/mesh/calculus/measure.py
  • test/mesh/calculus/test_measure.py

No CODEOWNER

  • CHANGELOG.md

Comment /codeowners-info to refresh.

@peterdsharpe

Copy link
Copy Markdown
Collaborator Author

/ok to test e39cd39

…dit-fix-1971-sept9

Signed-off-by: Peter Sharpe <peterdsharpe@gmail.com>
Signed-off-by: Peter Sharpe <peterdsharpe@gmail.com>
@peterdsharpe peterdsharpe changed the title Aero recipe: subsampled-surface force coefficients are unbiased estimates; drop query measure from saved outputs Aero recipe: document sampled-force weighting and clean saved query measures Sep 9, 2026
@peterdsharpe

Copy link
Copy Markdown
Collaborator Author

/ok to test a71c242

@peterdsharpe peterdsharpe changed the title Aero recipe: document sampled-force weighting and clean saved query measures Aero recipe: document sampled forces and preserve exported quadrature Sep 19, 2026
@peterdsharpe

Copy link
Copy Markdown
Collaborator Author

/ok to test fc52b33

@peterdsharpe
peterdsharpe marked this pull request as ready for review September 19, 2026 20:57
@greptile-apps

greptile-apps Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Retrigger

The PR is not safe to merge until the GLOBE visualization force integration preserves and consumes the corrected measure on subsampled prediction surfaces.

Findings

  1. P1 Subsampling Correction Is Discarded ▶

Summary

This PR replaces multiplier-style mesh weights with complete cell and point measures, propagates those measures through sampling and geometry operations, introduces explicit point-sample integration, and updates the external-aero documentation and inference contracts.

  • Adds _effective_measure and represented-dimension metadata with lifecycle helpers.
  • Transfers cell quadrature to centroid query points and preserves it through inference export.
  • Updates readers, transforms, subdivision, remeshing safeguards, GLOBE inputs, and regression coverage.
  • One GLOBE visualization force path still discards the newly stored correction and reports incorrectly scaled coefficients after subsampling.

Reviews (1) · Last reviewed commit: "Merge unified measures into aero force d..."

Comment on lines +301 to +302
total_area = cell_measures(mesh).sum()
scale_measures(boundary, total_area / cell_measures(boundary).sum())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Subsampling Correction Is Discarded

The visualization path subsamples prediction_mesh and stores the represented-area correction in cell_data["_effective_measure"]. Postprocessing then rebuilds pred_surface with empty cell data, and compute_surface_force_coefficients weights forces using geometric cell_areas. This discards the correction, so the reported predicted Cd/Cl/Cs shrink with the retained surface fraction. Preserve the effective measure on pred_surface and use cell_measures(surface_mesh) for integration.

@peterdsharpe

Copy link
Copy Markdown
Collaborator Author

/ok to test f4475b3

This branch has not been deployed

No deployments
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