Skip to content

Add mean motion constraint and use rotation vector as default convention#46

Merged
pruliere merged 10 commits into
masterfrom
feature/mean_motion
Jul 10, 2026
Merged

Add mean motion constraint and use rotation vector as default convention#46
pruliere merged 10 commits into
masterfrom
feature/mean_motion

Conversation

@pruliere

@pruliere pruliere commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds a new MeanMotion constraint to control selected mean displacement and rotation components using global DOFs.

MeanMotion can be used for displacement-only control through MeanDisp, rotation control through MeanRot, or mixed mean motion control. When a surface mesh is passed, nodal weights are computed from surface area/length, making it suitable for face-average constraints. For nonlinear geometry with rotational components, finite rotation is enabled automatically and uses a rotation-vector convention.

Main changes

  • Add fd.constraint.MeanMotion.
  • Add automatic finite-rotation handling for mean rotations when nlgeom is active.
  • Update RigidTie to use the rotation-vector convention (using linearization function from simcoon).
  • Add a Sphinx-Gallery example comparing RigidTie and MeanMotion torsion constraints.
  • Add regression tests for mean motion, finite rotations, reciprocal moment/rotation behavior.

Validation

  • tests/test_mean_motion.py
  • tests/test_rigid_tie_rotvec.py
  • examples/02-constraints/mean_rigid_motion_torsion.py

pruliere and others added 10 commits July 8, 2026 14:01
Refactor MeanMotion constraint internals, improve robustness and performance, and add regression tests.

Key changes:
- Vectorize finite-rotation prediction and Jacobian assembly to avoid per-node loops and speed up Newton iterations.
- Replace manual surface-node mapping with scipy.spatial.cKDTree query and validate exact mapping.
- Replace custom element-measure logic with surface_mesh.get_element_volumes() and accumulate weights with np.add.at.
- Introduce _phys_dof_index for fast indexing of physical DOFs and simplify/get_total_physical_values and updates to problem._dU.
- Remove unused mode_matrix and related code paths; fix projection row mapping using _mode_indices when building MPCs.
- Ensure linear-path MPCs pick unique slave DOFs by threading a used_slave_cols set through _make_mpc calls.
- Force relinearization for finite_rotation by setting _update_during_inc = True and mark constraint out-of-balance in the NR loop via _bc_residual_norm so convergence gating accounts for BC residuals.
- Adjust NR rollback/restart semantics: roll back state on too-small dt (to_start) and keep restart True so failed increments are not finalized.
- Misc: small reshapes/array allocation fixes and clearer comments.

Also add tests/tests_mean_motion.py containing regression tests that lock in correct projection-row selection, unique slave selection, and finite-rotation behavior.
When finite_rotation is enabled, force _update_during_inc=True so MPCs are relinearized every Newton iteration (finite rotation is nonlinear even on geometry-linear problems where a user set finite_rotation=True). Also simplified the comment in _finite_tangent_and_prediction to note broadcasted ops for node-independent rotation terms. Removed the tests/test_mean_motion.py file (tests for MeanMotion were deleted or relocated).
@pruliere pruliere merged commit 21d4cfc into master Jul 10, 2026
3 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.

2 participants