feat(datapipes): add ComputeUnitGlobalVector transform#1825
Draft
peterdsharpe wants to merge 3 commits into
Draft
feat(datapipes): add ComputeUnitGlobalVector transform#1825peterdsharpe wants to merge 3 commits into
peterdsharpe wants to merge 3 commits into
Conversation
Computes the unit direction of a global_data vector field and stores it under a new key, leaving the source vector unchanged. Lets pipelines condition models on a flow direction while keeping the physical vector available for converting predictions back to physical units.
- Reject integer vectors, batched (B, 3) vectors, and
output_field == vector_field with clear errors instead of silently
producing wrong output.
- Normalize in the promoted dtype so float64 sources keep full
precision (previously downcast to float32).
- Re-export ComputeUnitGlobalVector from physicsnemo.datapipes and
physicsnemo.datapipes.transforms, matching sibling transforms.
- Document that an existing output_field is overwritten.
- Tests: error paths, sub-mesh global_data untouched on DomainMesh,
${dp:...} registry resolution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A small opt-in transform,
ComputeUnitGlobalVector:v / |v|of a vector stored inglobal_data.Meshand, at the domain level, onDomainMesh.(B, 3)input, andoutput_field == vector_fieldall raise clear errors.Why
global_datain physical units, because the physical values are needed later to convert predictions back (e.g. force coefficients).transform_global_data: true, it rotates together with the source vector and the geometry.Why a draft
This is new API rather than a bug fix (the bug fix it was originally bundled with is #1820), so a few design questions are worth settling first:
DomainMesh, should the direction also be broadcast to sub-meshglobal_data(asSetGlobalFielddoes), or stay domain-level only as implemented?|v| / v_ref), so speed information is not silently dropped?(B, 3)vectors be normalized per row? (Currently rejected with an error; transforms run per-sample, where vectors are(3,).)Tests
New
test/datapipes/transforms/test_compute_unit_global_vector.py(10 tests):MeshandDomainMeshglobal_dataunchanged${dp:...}config resolverFull transforms suite passes (287); ruff check/format clean.