Repository navigation
Add the linear constraint boundary condition, by elimination - #119
Open
mattjolley wants to merge 3 commits into
Open
mattjolley wants to merge 3 commits into
mattjolley wants to merge 3 commits into
Conversation
The friction of FEBio's sliding-elastic interface in its penalty form, for the term between two surfaces that move: fric_coeff, slip_tol, and knmult 1, which FEBio sets itself with friction. It is the anchored-point force with a release rule: a point is held to where it was on the secondary surface at the end of the time step before while the shear part of that traction stays below fric_coeff times its pressure, and slips otherwise. contact/sliding_friction.py has the trial, stick and slip of FEBio's ContactTraction and the two branches of its stiffness, transcribed with FEBio's names. With fric_coeff 0 and knmult 0 they give the forces and the stiffness of the frictionless kernels, which stay in use there. The anchors of a time step are the projection of the last converged state, also for a point that stuck (FESolidSolver2::PrepStep updates the model before the interface takes them). With the first anchor kept instead, co47 is 1e-5 off in its third time step. co47 takes the suite's stored 51 steps and 292 iterations, FEBio's count in each step, and the norm to 2e-12, on CPU and on a Tesla P100; three generated cases agree with FEBio 4.13.0 to 6e-13. co34, which sets knmult 1 without friction, takes its stored 20 steps and 42 iterations and the norm to 1e-12. This branch is cut from mattjolley/sliding-elastic-deformable, which it needs. The suite's other friction inputs, co48 and co44, set augmented Lagrangian, which waits on an augmentation loop in the Newton solver. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
The adjoint refused a system with a tied or sticky interface: the anchors of such an interface are history, and linearizing at a stored State would have brought the term there with the anchors of whichever state it saw last. A State that a run keeps carries its anchors in its restart record (contact/anchored.py, "The anchors and the State"). The adjoint now gives them back to the term before it linearizes at that State, by the call a restart uses, and again after the term's update, which for a sticky interface tests for attachment and release anew. The reverse sweep over steps does the same per State. The anchors are read and not moved; nothing in contact/ changes, the term's own flag stays False, and a State without its record is refused as before. What the gradient is, measured on CPU and on a Tesla P100: ti_blocks (tied, anchors placed in the undeformed mesh): the adjoint agrees with central differences of the equilibrium solved again from the State and with central differences of the whole run, 1e-8. It is the derivative of the run. st_grasp_quad4 (sticky, 20 nodes attached, three time steps after the last event): 1e-8 against the equilibrium with the anchors held, and 2e-5 to 6e-5 relative against the whole run, which places the anchors where the nodes meet the surface. It is the derivative of the model with the grasp as found, not of the run. check_equilibrium_gradients is the check with the anchors held. Refused, beside a State without its record: a tied interface with offset_shells, whose stiffness leaves out the turning of the facet normal, as FEBio's does, so that there is no exact tangent; and the other terms with anchors (sliding-elastic between two deformable bodies, tied-elastic), which keep their own refusal. The anchors are those of contact/anchored.py (the tied and sticky interfaces of Handoff K, thread K2). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
FEBio's <bc type="linear constraint"> makes one degree of freedom a linear function of others and gives it no equation: its residual and stiffness go to the children. It was refused, with the three suite inputs that miss nothing else (mi04, mi05, mi37). It is built on the table of dependent entries of the rigid bodies (assembly/reduction.py), so that the two share one mechanism, as Handoff K asks. constraints/linear_constraints.py owns the table: each parent is a dependent entry whose constrained components follow, each (parent, child) pair a link with the coefficients in its 3 x 3 matrix. The parents are written after every update by the table's spread, and a coefficient on a load curve is read at the time being solved. As in FEBio, nothing of a parent's pending change goes to the first right-hand side when the offset is zero. Against the suite's stored values (FEBio 4.13.0 at e4df3f8), on CPU and on a Tesla P100 with cuDSS: mi04 10 steps and 31 iterations, mi05 10 and 50, mi37 10 and 49, all FEBio's counts, with the norm to 4e-12. Refused with the reason: a nonzero offset, a constraint declared in a step, a child at a node that is a parent in another component (FEBio rules by degree of freedom, the table by entry), a model that also has a rigid body with unknowns (a system has one table, and the two are not merged), and gradients, which a system with a table does not have yet. The table came with the rigid bodies (mattjolley/dependent-entries). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
3 of 5 tasks
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.
This pull request sits on #118 (
mattjolley/gradients-through-anchors) and is to be merged after it. Until the rows below it are merged, the diff here also shows their commits; the one commit of this pull request is the last. It needs only the table of dependent entries (mattjolley/dependent-entries, row 8) and the two constraint terms of row 3; it is at the end of the line so that the rows between did not have to be rebased again.What does this change, and why?
FEBio's
<bc type="linear constraint">(FELinearConstraint,FELinearConstraintManager) makes one degree of freedom a linear function of others and gives it no equation: its residual and stiffness go to the children. It was refused, with the three suite inputs that miss nothing else (mi04,mi05,mi37). This is the other half of K3-3 of Handoff K: the linear constraint set and the node distance, which enforce by a force, are terms (row 3); this one is by elimination.It is built on the table of dependent entries that the rigid bodies with unknowns brought (
assembly/reduction.py), so that the two share one mechanism, as the handoff asks. Design note: docs/design/constraints.md, the status of December 2 at its head and section 8.What is built (
constraints/linear_constraints.py, with the wiring incompiled.pyandanalysis/steps.py):FELinearConstraint::Activate); the other components of its node keep theirsDEPENDENTAssembleResidual,AssembleStiffness)Update)spread, from the hook of the Newton loopmi37)The table is constant in the displacement, so the reduced tangent is the derivative of the reduced residual.
What is refused, and why (each by the coverage report, with the reason):
offsetadjoint_solverefuses a system with a table, for rigid bodies and for this alikeOpen question B1 of
docs/design/open_questions.md(the route for linear constraints) is updated: both routes are built. No new numbered question.What conflicted in the rebase onto the line: the README row of loads and constraints and one status paragraph of
constraints.md, both sides adding; and inanalysis/steps.pythe place wherebuild_systemgives the system its table, which the rigid bodies now also do. Both are kept, and the model that would need both is refused as the table above says.Validation
All of the following with Warp 1.20.0, on CPU and on a Tesla P100 (cuDSS; the versions of the
gpuextra), at this branch's own tipe6d221a.Tests added or changed:
tests/test_linear_constraints_bc.py, new, five tests: the three suite problems on FEBio's steps, iterations and norm; that the parents follow their children at every state, to round-off; a coefficient on a load curve; coverage with every refusal above; that gradients are refused. No existing test is changed. The mechanism itself is checked without FEBio by K1'stests/test_reduction.py, which passes unchanged.FEBio reference (input file, quantity compared, tolerance, FEBio version), or N/A: the stored values of FEBio's test suite (FEBio 4.13.0 at
e4df3f8), with the presetFEBIO_4_13, on FEBio's quasi-Newton path.mi04mi05mi37mi04with two of the coefficients on a load curveFEBio's norm is over its equations, which the parents do not have, so it is compared with the norm over the free components. The test allows two iterations of slack, as for the other suite problems that take quasi-Newton updates, and holds the norm to 1e-6; the counts were FEBio's on CPU and on the P100. These three need a checkout of the FEBio test suite (
FEBIO_TEST_SUITE) and are skipped without one, so CI does not run them; they ran here. No small input is generated: the suite is the reference.Devices the full tier ran on (CPU, and the GPU model if CUDA; say so clearly if no GPU was used):
test_linear_constraints_bc,test_reduction,test_constraint_terms,test_gradients_through_anchors,test_activity: CPU, 54 tests, none failed; Tesla P100, 54 tests, none failed.mainat25b5aacon the same GPU and is not of this pull request:tests/test_history_adjoint.py,ForwardSweep.test_the_jacobian_of_a_static_run_goes_through_the_steps(from History in the forward sweep #101; it passes on CPU).Checklist
uvx pre-commit run --all-filespasses. (Run on the files of this change: passes.)FEBIO_WARP_TEST_LEVEL=full uv run -m unittest discover -s tests, and withFEBIO_WARP_TEST_DEVICE=cuda:0for code that runs on the device. (Not run in full; see Validation.)git commit -s).🤖 Generated with Claude Code