Add regular-lattice point deformation functional#1810
Conversation
|
Hey Oliver, this is great! We were just chatting with Peter about this. I’m wondering whether it would be better to wait until the morph is merged, and whether this PR can adapt the API exposed to users under transformations.deform (we can discuss the details). Could you maybe start by pulling that PR and applying the API exposure in a similar way? |
Greptile SummaryThis PR introduces
Important Files Changed
Reviews (1): Last reviewed commit: "Add regular-lattice point deformation fu..." | Re-trigger Greptile |
| zero = control_displacements.sum() * 0 | ||
| if point_weights is not None and point_weights.is_floating_point(): | ||
| zero = zero + point_weights.sum() * 0 |
There was a problem hiding this comment.
Gradient edge via
sum() * 0 is NaN-unsafe for Inf inputs. If any value in control_displacements is ±Inf, then sum() is Inf and Inf * 0 = NaN under IEEE 754. The empty-output tensor itself carries no elements, but NaN propagates through the autograd graph so control_displacements.grad becomes all-NaN on backward instead of all-zero. The idiomatic alternative is to form the scalar through a zero-valued linear combination that stays finite.
| zero = control_displacements.sum() * 0 | |
| if point_weights is not None and point_weights.is_floating_point(): | |
| zero = zero + point_weights.sum() * 0 | |
| zero = (control_displacements.reshape(-1)[:1] * 0.0).sum() | |
| if point_weights is not None and point_weights.is_floating_point(): | |
| zero = zero + (point_weights.reshape(-1)[:1] * 0.0).sum() |
a51d6f6 to
26ac4c6
Compare
PhysicsNeMo Pull Request
Description
Adds
physicsnemo.nn.functional.lattice_deform_points, a differentiable functional that deforms unbatched 1D, 2D, or 3D points from displacement controls stored on a regular lattice.The public functional provides:
FunctionSpec;The implementation composes
grid_to_point_interpolationrather than adding another raw Warp kernel surface. A separate lattice functional is intentional: its dense regular-grid and bounds contract is distinct from the sparse control-point/radius contract ofmorph_points.The functional documentation follows the existing geometry-page pattern:
autofunction, a short visualization description, and the image. It contains no Python example block and no checked-in image-generation script.Validation
77 passedintest_lattice_deform_points.py47 passedin the prerequisite interpolation suite167 passed, 16 skippedacross geometry functionals and grid-to-point interpolationChecklist
Dependencies
physicsnemo.mesh.transformations.deform.lattice_deform,Mesh.lattice_deform, andDomainMesh.lattice_deformexposure. This PR remains draft until that API layer can be rebased onto the merged deformation namespace.