Implement multi-cell finite element method for interpolated flexes.

This change introduces a `flex_cellcount` field to `mjModel` to specify the number of cells in each dimension for interpolated flexes. The stiffness computation, passive force calculation, and Jacobian derivatives are updated to operate on a per-cell basis, significantly improving performance by localizing computations to the nodes within each cell.

PiperOrigin-RevId: 901216393
Change-Id: Ic23132e609de11e71bb7fef8d1f139daad2ec264
This commit is contained in:
Alessio Quaglino
2026-04-17 04:10:54 -07:00
committed by Copybara-Service
parent 8415dff307
commit 6c7ed66781
36 changed files with 1777 additions and 1039 deletions
+21
View File
@@ -2668,6 +2668,14 @@ STRUCTS: Mapping[str, StructDecl] = dict([
doc='interpolation (0: vertex, 1: nodes)',
array_extent=('nflex',),
),
StructFieldDecl(
name='flex_cellnum',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='finite cell num per dimension',
array_extent=('nflex', 3),
),
StructFieldDecl(
name='flex_nodeadr',
type=PointerType(
@@ -8237,6 +8245,19 @@ STRUCTS: Mapping[str, StructDecl] = dict([
type=ValueType(name='int'),
doc='2D passive forces; 0: none, 1: bending, 2: stretching, 3: both', # pylint: disable=line-too-long
),
StructFieldDecl(
name='cellcount',
type=ArrayType(
inner_type=ValueType(name='int'),
extents=(3,),
),
doc='grid cell count for finite cell method',
),
StructFieldDecl(
name='order',
type=ValueType(name='int'),
doc='interpolation order (1: trilinear, 2: quadratic)',
),
StructFieldDecl(
name='nodebody',
type=PointerType(