Refactor flex strain constraints to be per-cell.

Each mjEQ_FLEXSTRAIN equality now represents a single cell within a flex. This allows for more efficient sparse Jacobian computation by only considering the degrees of freedom of the nodes within each specific cell. This change gives a speedup of about 10x on a 3x3x3 model.

PiperOrigin-RevId: 902164069
Change-Id: I78eedf1d5cf39b8989fe9863c22d164922fc0efb
This commit is contained in:
Alessio Quaglino
2026-04-19 07:20:49 -07:00
committed by Copybara-Service
parent a9e61966b5
commit 3d45a33190
7 changed files with 289 additions and 256 deletions
+4 -1
View File
@@ -4888,8 +4888,11 @@ constraint type is only supported for dimension 3 flexes with trilinear or quadr
:at:`flex`: :at-val:`string, required`
Name of the flex whose strain is being constrained.
.. _equality-flexstrain-cell:
:at:`cell`: :at-val:`int(3), optional`
3D grid index (i, j, k) identifying the cell in the flex object. The grid size is specified in the :ref:`cellcount
<deformable-flex-cellcount>` attribute.
.. _tendon:
+3
View File
@@ -2062,6 +2062,9 @@
.. grid-item::
:ref:`flex<equality-flexstrain-flex>`
.. grid-item::
:ref:`cell<equality-flexstrain-cell>`
.. grid-item::
:ref:`active<equality-flexstrain-active>`
+3
View File
@@ -10,6 +10,9 @@ General
- Added :ref:`multi-cell support<body-flexcomp-cellnum>` for trilinear and quadratic flexes. Note that the implicit
integrator uses a dense solver for the flex degrees of freedom, which can be slow for multi-cell flexes.
- Refactored ``flexstrain`` equality constraints to be instantiated per cell instead of per flex object, reducing the
number of degrees of freedom per constraint row. The equality can be associated with a specific cell with the new
attribute ":ref:`cell <equality-flexstrain-cell>`
Version 3.7.0 (April 14, 2026)
------------------------------