Repository navigation
feat(assemble): pass per-quadrature-point data to the element and node assemblers - #70
Merged
Merged
Conversation
…e assemblers
ElementAssembler.__call__, ElementAssembler.energy and
NodeAssembler.__call__ take `quadrature_data`: tensors of shape
[n_element, n_quadrature, ...] (or {element_type: tensor} on mixed
meshes) whose value at the current point reaches `forward` by name.
This is what a consistent tangent or a stress of a history-dependent
material needs; until now only energy() could see per-point data, by
guessing the layout of element_data from shape[1] == n_quadrature.
Shapes and key clashes with other data are checked up front, the data
is split together with the quadrature points when batch_size > 0, and
a compiled NodeAssembler falls back to the vmap path for such calls.
energy() also slices per-point element_data along quadrature batches
now; with batch_size > 0 it was handed whole and the call failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dst8zhPLnxVpZMBhR4Pvfs
Signed-off-by: Shizheng Wen <wenshizheng0710@gmail.com>
Shizheng-Wen
added a commit
that referenced
this pull request
Oct 20, 2026
…#71) A thick-walled cylinder under internal pressure (Hill 1950), in plane strain, with J2 plasticity and linear isotropic hardening (perfect plasticity by default). Every load step is solved by Newton's method with the consistent tangent of the radial return, so the iterations converge quadratically: three to five per plastic load step. The plastic state lives at the quadrature points. The stress and the tangent moduli reach an internal-force NodeAssembler and a tangent ElementAssembler as quadrature_data (#70), and the pressure is a FacetAssembler load along the outward normal n (#69). Displacement control follows the collapse plateau; pressure control is an option. The quarter ring of six-node triangles is built with NumPy, so the example needs no gmsh. Tests check the return map and its tangent against forward-mode autodiff, the assembled stiffness against finite differences, the Lame elastic response, first yield at the inner wall, the limit pressure (2 / sqrt 3) sigma_y ln(b / a) of perfect plasticity (within 1 %), and CUDA against CPU. Docs: gallery page and solid-mechanics index entry, with zh_CN translations. Claude-Session: https://claude.ai/code/session_01Dst8zhPLnxVpZMBhR4Pvfs Signed-off-by: Shizheng Wen <wenshizheng0710@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
ElementAssembler.__call__,ElementAssembler.energyandNodeAssembler.__call__now takequadrature_data. Its tensors have shape[n_element, n_quadrature, ...], or{element_type: tensor}on meshes with several element types. Their value at the current quadrature point reachesforwardby name, like any other data key:History-dependent materials need this for a Newton solve. Plasticity with a consistent tangent and a stress that depends on internal variables stored at the quadrature points is the case at hand. So far only
energy()could see per-point data: it guessed the layout ofelement_datafromshape[1] == n_quadrature, which is ambiguous when a per-element dimension equals the number of points.__call__handed the whole[n_quadrature, ...]slice toforward, andNodeAssemblertook no element data at all.Details
point_data,element_dataorscalar_data, or that is a built-in name (u,v,x, …), is rejected.batch_size > 0.NodeAssemblerfalls back to the vmap path for calls with quadrature data.energy()now slices per-pointelement_dataalong quadrature batches too. Before,batch_size > 0with per-point history failed with a shape error.Tests
tests/assemble/test_quadrature_data.py(new) checks:einsumassembly fromTransformation.shape_grad/JxW;LinearElasticityElementAssembler;energy()withquadrature_dataand with per-pointelement_datain batches, including its gradient with respect to the data;Full suite on Clariden (aarch64) in a CPU conda env with gmsh: 548 passed, 18 skipped, 0 failed. Main gives 539 passed, 17 skipped; the extra skip is the CUDA test. The new tests also pass on a GH200 node, CUDA test included. The docs build adds no warnings (EN and zh: 21 → 21).
🤖 Generated with Claude Code
https://claude.ai/code/session_01Dst8zhPLnxVpZMBhR4Pvfs