Add mean motion constraint and use rotation vector as default convention#46
Merged
Conversation
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.
…nto feature/mean_motion
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).
…nto feature/mean_motion
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.
Summary
This PR adds a new
MeanMotionconstraint to control selected mean displacement and rotation components using global DOFs.MeanMotioncan be used for displacement-only control throughMeanDisp, rotation control throughMeanRot, 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
fd.constraint.MeanMotion.nlgeomis active.RigidTieto use the rotation-vector convention (using linearization function from simcoon).RigidTieandMeanMotiontorsion constraints.Validation
tests/test_mean_motion.pytests/test_rigid_tie_rotvec.pyexamples/02-constraints/mean_rigid_motion_torsion.py