nphysics icon indicating copy to clipboard operation
nphysics copied to clipboard

FEMVolume `renumber_dofs` breaks kinematic indices

Open werner291 opened this issue 3 years ago • 0 comments

Hello,

the boundary_collider_desc in FEMVolume method calls renumber_dofs under the hood, which appears to neglect to update the kinematic_nodes, causing the kinematic nodes to be scattered throughout the volume.

Minimal code example:

let mut fem_body = FEMVolumeDesc::cube(5, 2, 2)
        .scale(Vector3::new(10.0, 0.5, 0.5))
        .young_modulus(1.0e3)
        .poisson_ratio(0.2)
        .mass_damping(0.2)
        .build();

    let to_be_kinematized = fem_body.positions().iter().enumerate().filter_map(|(i,p)| {
        if i % 3 == 0 && *p == -5.0 {
            dbg!(p);
            Some(i/3)
        } else {
            None
        }
    }).collect::<Vec<_>>();

    for i in to_be_kinematized.iter() {
        fem_body.set_node_kinematic(*i, true);
    }

    let co = fem_body.boundary_collider_desc();

    {
        let pp = fem_body.positions();
        dbg!(to_be_kinematized.iter().map(|i| {
            [pp[i * 3], pp[i * 3 + 1], pp[i * 3 + 2]]
        }).collect::<Vec<_>>());
    }

Observe, in the output from dbg!, that the x-coordinates are all over the place.

werner291 avatar Feb 11 '21 12:02 werner291