Skip to content

Add sliding-elastic contact between two deformable bodies - #115

Merged
mattjolley merged 3 commits into
mainfrom
mattjolley/sliding-elastic-deformable
Dec 3, 2026
Merged

mattjolley merged 3 commits into
mainfrom
mattjolley/sliding-elastic-deformable

Conversation

@mattjolley

Copy link
Copy Markdown
Contributor

This pull request sits on #114 and is to be merged after it. Until that one is merged, the diff here also shows its commits; the one commit of this pull request is the last.

What does this change, and why?

The sliding-elastic term on main covers the case shape enforcement uses: a fixed rigid target, one pass, tension 1. Devices against tissue, and twelve inputs of FEBio's suite, need the interface between two bodies that both deform. This adds a term for that, contact/sliding_pair.py, in FEBio's penalty form without friction (FESlidingElasticInterface at e4df3f8): forces on the secondary nodes, FEBio's stiffness coupling the two surfaces, two passes, auto_penalty, an offset, and the release of a point in tension when tension is 0. The term for a fixed target is unchanged and keeps that case; sliding_elastic.term chooses by the secondary surface. Design note: docs/design/contact.md, section "Sliding-elastic between two deformable bodies".

Two things in FEBio's source decide whether the suite's stored values are met. Both are followed, and both are questions for Steve:

  • The auto penalty is not E A / V for an oblique facet (question 28). FEContactInterface::AutoPenalty takes "the normal component of the compliance" from tens4ds::inverse, which inverts the 6 x 6 matrix of the tangent's components without the factors of the shear rows. The number is the modulus for a facet normal along an axis and smaller for an oblique one (0.34 E at 45 degrees for v = 0.3). With E A / V, co41, whose contact faces are curved, ends 9e-4 from FEBio; with FEBio's number, 2e-12.
  • A symmetric solver keeps one triangle of the interface's stiffness (question 29). The stiffness of sliding-elastic is not symmetric. A step's solver with symmetric_stiffness "symmetric", FEBio's default, assembles into a symmetric matrix format, which keeps the entries with row >= column in CompactSymmMatrix (MKL Pardiso). The converged state is the same; the iterations are not. co07: 182 iterations with the lower triangle mirrored, which is the suite's stored value; 185 with the whole matrix; 188 with the upper triangle, which is what FEBio's skyline solver takes on the same commit and input. Here the term mirrors the lower triangle of its own blocks in such a step (febio_symmetric_storage, a flag on the term). The general place for this would be the system's matrix; that is outside contact/ and is left as a decision.

What is refused, and why: friction and knmult 1 (the next pull request); augmented Lagrangian; seg_up; node_reloc; shell bottoms and auto_penalty on shells, which suite co51 needs; facets other than quad4; auto_penalty on a material other than neo-Hookean, isotropic elastic and rigid body. Gradients: the term sets adjoint_ready False, because FEBio's stiffness is not the derivative of the force and the exact one is not built for this case.

One existing test is changed, in tests/test_sliding_elastic.py: test_a_deformable_secondary_surface_is_refused asserted the refusal this pull request lifts. It is now test_a_deformable_secondary_surface_is_read_by_the_pair_term. No other shape-enforcement or sticky test is changed.

What a sliding pair costs the linear solve, measured on co07 on one Tesla P100 (before the rebase, Warp 1.19.0): the pattern of the tangent changes in 263 of 349 updates; plain cuDSS analyses 174 times in 182 factorizations (7.4 s of a 16.8 s run), the growing pattern ("cudss-padded") 120 times (17.3 s). FEBio with MKL Pardiso on four threads takes 11 s. The projection tries every secondary facet for every point without one; a search structure for a secondary surface that moves is not built.

Validation

All of the following with Warp 1.20.0, on CPU and on a Tesla P100 (cuDSS; the versions of the gpu extra), at this branch's tip b314ba7.

  • Tests added or changed:

    • tests/test_sliding_pair.py, new: agreement with FEBio on three suite inputs and three small inputs, forces, the stiffness and its stored triangle, the auto penalty written out, the facets kept and restored, coverage and refusals.
    • tests/test_sliding_elastic.py: the one test named above.
    • tests/test_febio_suite.py: co07, co41, sh28 added to FEBIO_STRATEGY (full tier).
  • FEBio reference (input file, quantity compared, tolerance, FEBio version), or N/A: FEBio 4.13.0 at e4df3f8, with the preset FEBIO_4_13 for the suite inputs.

    Input What it is Agreement
    Suite co41 Two interfaces of one pass, auto_penalty, a non-symmetric solver The stored 10 steps and 46 iterations; norm to 1.7e-12
    Suite co07 Two passes, auto_penalty, a symmetric solver (1,980 nodes) The stored 40 steps and 182 iterations; norm to 2.7e-13
    Suite sh28 Quad4 shells against a rigid body that the input moves, two passes The stored 10 steps and 32 iterations; norm to 2.6e-13
    sd_blocks_one_pass A block with a convex face pressed onto a flat one and slid along it Displacement 5.3e-13, FEBio's iterations in all 20 time steps
    sd_blocks_two_pass The same with two passes and auto_penalty, under a symmetric solver 5.3e-13, FEBio's iterations
    sd_blocks_tension tension 1 and an offset 2.5e-13, FEBio's iterations

    The three small inputs are written by references/small_problems/generate_sliding.py. Their references are from the build of the same commit with MKL Pardiso, not from the pinned skyline build: the skyline solver does not take a non-symmetric matrix, and for a symmetric one the two solvers keep different triangles (above). The suite inputs need FEBIO_TEST_SUITE and are skipped without it, so CI does not run them; they ran here.

  • Devices the full tier ran on (CPU, and the GPU model if CUDA; say so clearly if no GPU was used):

    • At this tip: test_sliding_pair.py and test_sliding_elastic.py in the full tier (31 tests, with co07, co41, sh28) and the documentation links, on CPU: none failed (1 skipped). At the tip of segment C, row 14 (bce0a0b), which holds this change: quick tier of the whole repository, CPU 1,246 tests, none failed (95 skipped); Tesla P100 (cuda:5) 1,246 tests, one failure (86 skipped), the known one on main named below. Full tier of test_tied, test_sticky, test_sliding_pair, test_sliding_elastic, test_tied_elastic and test_febio_suite: CPU 104 tests, none failed; Tesla P100 (cuda:4) 104 tests, none failed.
    • The same change one base earlier, on main df58f1e (tip 27e8a9f), Warp 1.20.0: the full tier of the whole repository, CPU 1,076 tests, none failed (26 skipped); Tesla P100 1,076 tests, none failed (13 skipped).
    • Known failure on main at 25b5aac on a P100, not of this pull request: tests/test_history_adjoint.py, ForwardSweep.test_the_jacobian_of_a_static_run_goes_through_the_steps. It showed in the quick tier at the tip of segment C on the P100 (cuda:5), as the only failure, and in no run on CPU.
    • Not run at this tip: the full tier of the whole repository, on either device.

Checklist

  • I have read the contributing guide.
  • uvx pre-commit run --all-files passes. (Run on the files of this change: passes.)
  • The full tier passes: FEBIO_WARP_TEST_LEVEL=full uv run -m unittest discover -s tests, and with FEBIO_WARP_TEST_DEVICE=cuda:0 for code that runs on the device. (Not run in full at this tip; see Validation.)
  • If this changes what a design note says, the note is updated; open design questions are in its decision points, not only in this pull request.
  • The change is focused, and every commit is signed off (git commit -s).

🤖 Generated with Claude Code

mattjolley and others added 3 commits December 2, 2026 19:00
A body with unknowns was refused in a dynamic step. This adds its mass
and inertia from the density, FEBio's update of the angular velocity
and acceleration, the inertial force and moment, the rotational mass
block, a body force on a rigid part and the initial accelerations.

Three things of FEBio's rigid solver are followed because its
iterations depend on them: the stiffness of a time step is formed
before its first residual, with the angular momentum of the last
state; a symmetric stiffness keeps the upper triangle of the
rotational mass block, which is not symmetric; and the initial angular
acceleration is scaled by beta dt^2.

Two generated cases of a body spun up by moments agree with FEBio
4.13.0 to 3e-12 with its iterations in every time step, and suite
input dy05 takes FEBio's counts, on CPU and on a Tesla P100. A dynamic
step after a static one, and initial velocities, are refused.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
FEBio's sticky, tied-node-on-facet, tied-elastic and the stick state of
sliding-elastic are one force: a spring of stiffness penalty times area
between a point of the primary surface and a material point of the
secondary surface that is held once chosen (valve_workflow.md, decision
W3). Sticky was that term with its settings fixed in its code.

The kernels and the attachment state of sticky move to
contact/anchored.py unchanged, with what was constant as arguments, and
FEBio's tied-node-on-facet in its penalty form is a second setting of it
(contact/tied.py): anchors chosen at activation and never released,
max_distance, special, offset_shells, a penalty on a load curve, also
declared in a step.

No behavior of sticky changes: on CPU its seven small cases and co42
with held components give the same numbers bit for bit, with the same
iterations.

co26 of FEBio's test suite takes the stored 10 steps and 30 iterations
and the norm to 2.6e-13, on CPU and on a Tesla P100, and six generated
cases agree with FEBio 4.13.0 to 3e-12 with FEBio's iterations.

node_reloc 1 is refused: FEBio moves the reference position of the tied
nodes after its solid elements have stored their reference gradients, so
its result is that of the mesh as written (question 27).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
The sliding-elastic term on main covers a fixed rigid target. A new
term, contact/sliding_pair.py, reads the interface where the secondary
surface can move, in its penalty form without friction: forces on the
secondary nodes, FEBio's stiffness coupling the two surfaces, two
passes, auto_penalty, an offset, and the release of a point in tension
when tension is 0. The term for a fixed target is unchanged;
sliding_elastic.term chooses by the secondary surface.

Two things in FEBio's source decide whether the suite's stored values
are met, and both are followed:

The auto penalty uses a compliance from tens4ds::inverse, which has no
factors for the shear rows, so it is the modulus only for a facet
normal along an axis. With E A / V co41 ends 9e-4 from FEBio; with
FEBio's number, 2e-12 (question 28).

A solver that asks for a symmetric stiffness stores one triangle of the
interface's stiffness, which is not symmetric. co07 takes the stored
182 iterations with the lower triangle mirrored, as FEBio with MKL
Pardiso; 185 with the whole matrix; 188 with the upper triangle, as
FEBio's skyline solver does on the same commit (question 29).

co07, co41 and sh28 (shells against a rigid body the input moves) take
the suite's stored steps and iterations and the norm to 3e-13, 2e-12
and 3e-13, on CPU and on a Tesla P100, and three generated cases agree
with FEBio 4.13.0 to 5e-13 with FEBio's iterations.

The adjoint refuses the term: FEBio's stiffness is not the derivative
of the force. contact.md has what a sliding pair costs the linear
solve. co51 waits on shell bottoms and auto_penalty on shells.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
@mattjolley
mattjolley merged commit 39f080b into main Dec 3, 2026
2 checks passed
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